Doxygen
Loading...
Searching...
No Matches
diagram.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include "diagram.h"
#include "image.h"
#include "classdef.h"
#include "config.h"
#include "message.h"
#include "util.h"
#include "doxygen.h"
#include "portable.h"
#include "indexlist.h"
#include "classlist.h"
#include "textstream.h"
#include "growbuf.h"
#include "dir.h"
+ Include dependency graph for diagram.cpp:

Go to the source code of this file.

Classes

class  DiagramItem
 Class representing a single node in the built-in class diagram. More...
 
class  DiagramRow
 Class representing a row in the built-in class diagram. More...
 
class  TreeDiagram
 Class representing the tree layout for the built-in class diagram. More...
 
class  DualDirIterator< C, I >
 helper class representing an iterator that can iterate forwards or backwards More...
 
struct  ClassDiagram::Private
 

Macros

#define IMAGE_EXT   ".png"
 

Typedefs

using DiagramItemList = std::vector<DiagramItem*>
 

Functions

static uint32_t protToMask (Protection p)
 
static uint8_t protToColor (Protection p)
 
static QCString protToString (Protection p)
 
static uint32_t virtToMask (Specifier p)
 
static QCString convertToPSString (const QCString &s)
 
static Protection getMinProtectionLevel (const DiagramItemList &dil)
 
static void writeBitmapBox (DiagramItem *di, Image *image, uint32_t x, uint32_t y, uint32_t w, uint32_t h, bool firstRow, bool hasDocs, bool children=FALSE)
 
static void writeVectorBox (TextStream &t, DiagramItem *di, float x, float y, bool children=FALSE)
 
static void writeMapArea (TextStream &t, const ClassDef *cd, QCString relPath, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 

Variables

const uint32_t maxTreeWidth = 8
 
const uint32_t gridWidth = 100
 
const uint32_t gridHeight = 100
 
const uint32_t labelHorSpacing = 10
 
const uint32_t labelVertSpacing = 32
 
const uint32_t labelHorMargin = 6
 
const uint32_t fontHeight = 12
 

Macro Definition Documentation

◆ IMAGE_EXT

#define IMAGE_EXT   ".png"

Typedef Documentation

◆ DiagramItemList

using DiagramItemList = std::vector<DiagramItem*>

Definition at line 38 of file diagram.cpp.

Function Documentation

◆ convertToPSString()

static QCString convertToPSString ( const QCString & s)
static

Definition at line 195 of file diagram.cpp.

196{
197 if (s.isEmpty()) return s;
198 GrowBuf growBuf;
199 const char *p=s.data();
200 char c=0;
201 while ((c=*p++))
202 {
203 switch (c)
204 {
205 case '(': growBuf.addStr("\\("); break;
206 case ')': growBuf.addStr("\\)"); break;
207 default: growBuf.addChar(c); break;
208 }
209 }
210 growBuf.addChar(0);
211 return growBuf.get();
212}
Class representing a string buffer optimized for growing.
Definition growbuf.h:28
void addChar(char c)
Definition growbuf.h:69
void addStr(const QCString &s)
Definition growbuf.h:72
char * get()
Definition growbuf.h:114
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159

References GrowBuf::addChar(), GrowBuf::addStr(), QCString::data(), GrowBuf::get(), and QCString::isEmpty().

Referenced by ClassDiagram::writeFigure(), and writeVectorBox().

◆ getMinProtectionLevel()

static Protection getMinProtectionLevel ( const DiagramItemList & dil)
static

Definition at line 215 of file diagram.cpp.

216{
217 auto it = dil.begin();
219 if (it!=dil.end())
220 {
221 result=(*it)->protection();
222 for (++it;it!=dil.end();++it)
223 {
224 Protection p=(*it)->protection();
225 if (p!=result)
226 {
227 if (result==Protection::Protected && p==Protection::Public) result=p;
228 else if (result==Protection::Private) result=p;
229 }
230 }
231 }
232 return result;
233}
Protection
Protection level of members.
Definition types.h:26
@ Public
Definition types.h:26
@ Private
Definition types.h:26
@ Protected
Definition types.h:26

References Private, Protected, and Public.

Referenced by TreeDiagram::drawConnectors().

◆ protToColor()

static uint8_t protToColor ( Protection p)
static

Definition at line 160 of file diagram.cpp.

161{
162 switch(p)
163 {
164 case Protection::Public: return 6;
165 case Protection::Package: // package is not possible!
166 case Protection::Protected: return 5;
167 case Protection::Private: return 4;
168 }
169 return 0;
170}
@ Package
Definition types.h:26

References Package, Private, Protected, and Public.

Referenced by TreeDiagram::drawConnectors().

◆ protToMask()

static uint32_t protToMask ( Protection p)
static

Definition at line 148 of file diagram.cpp.

149{
150 switch(p)
151 {
152 case Protection::Public: return 0xffffffff;
153 case Protection::Package: // package is not possible!
154 case Protection::Protected: return 0xcccccccc;
155 case Protection::Private: return 0xaaaaaaaa;
156 }
157 return 0;
158}

References Package, Private, Protected, and Public.

Referenced by TreeDiagram::drawConnectors().

◆ protToString()

static QCString protToString ( Protection p)
static

Definition at line 172 of file diagram.cpp.

173{
174 switch(p)
175 {
176 case Protection::Public: return "solid";
177 case Protection::Package: // package is not possible!
178 case Protection::Protected: return "dashed";
179 case Protection::Private: return "dotted";
180 }
181 return QCString();
182}
This is an alternative implementation of QCString.
Definition qcstring.h:101

References Package, Private, Protected, and Public.

Referenced by TreeDiagram::drawConnectors().

◆ virtToMask()

static uint32_t virtToMask ( Specifier p)
static

Definition at line 184 of file diagram.cpp.

185{
186 switch(p)
187 {
188 case Specifier::Normal: return 0xffffffff;
189 case Specifier::Virtual: return 0xf0f0f0f0;
190 default: break;
191 }
192 return 0;
193}
@ Virtual
Definition types.h:29
@ Normal
Definition types.h:29

References Normal, and Virtual.

Referenced by writeBitmapBox().

◆ writeBitmapBox()

static void writeBitmapBox ( DiagramItem * di,
Image * image,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
bool firstRow,
bool hasDocs,
bool children = FALSE )
static

Definition at line 235 of file diagram.cpp.

238{
239 uint8_t colFill = hasDocs ? (firstRow ? 8 : 2) : 7;
240 uint8_t colBorder = (firstRow || !hasDocs) ? 1 : 3;
241 uint32_t l = Image::stringLength(di->label());
242 uint32_t mask=virtToMask(di->virtualness());
243 image->fillRect(x+1,y+1,w-2,h-2,colFill,mask);
244 image->drawRect(x,y,w,h,colBorder,mask);
245 image->writeString(x+(w-l)/2, y+(h-fontHeight)/2, di->label(),1);
246 if (children)
247 {
248 for (uint32_t i=0;i<5;i++)
249 {
250 image->drawHorzLine(y+h+i-6,x+w-2-i,x+w-2,firstRow?1:3,0xffffffff);
251 }
252 }
253}
Specifier virtualness() const
Definition diagram.cpp:60
QCString label() const
Definition diagram.cpp:303
void drawHorzLine(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
Definition image.cpp:289
void fillRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
Definition image.cpp:336
void drawRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
Definition image.cpp:328
void writeString(uint32_t x, uint32_t y, const QCString &s, uint8_t fg)
Definition image.cpp:263
friend uint32_t stringLength(const QCString &s)
Definition image.cpp:277
const uint32_t fontHeight
Definition diagram.cpp:146
static uint32_t virtToMask(Specifier p)
Definition diagram.cpp:184

References Image::drawHorzLine(), Image::drawRect(), FALSE, Image::fillRect(), fontHeight, DiagramItem::label(), Image::stringLength, virtToMask(), DiagramItem::virtualness(), and Image::writeString().

Referenced by TreeDiagram::drawBoxes().

◆ writeMapArea()

static void writeMapArea ( TextStream & t,
const ClassDef * cd,
QCString relPath,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h )
static

Definition at line 264 of file diagram.cpp.

266{
267 if (cd->isLinkable())
268 {
269 QCString ref=cd->getReference();
270 t << "<area ";
271 if (!ref.isEmpty())
272 {
273 t << externalLinkTarget(true);
274 }
275 t << "href=\"";
276 t << externalRef(relPath,ref,TRUE);
277 QCString fn = cd->getOutputFileBase();
279 t << fn;
280 if (!cd->anchor().isEmpty())
281 {
282 t << "#" << cd->anchor();
283 }
284 t << "\" ";
285 QCString tooltip = cd->briefDescriptionAsTooltip();
286 if (!tooltip.isEmpty())
287 {
288 t << "title=\"" << convertToHtml(tooltip) << "\" ";
289 }
290 t << "alt=\"" << convertToXML(cd->displayName());
291 t << "\" shape=\"rect\" coords=\"" << x << "," << y << ",";
292 t << (x+w) << "," << (y+h) << "\"/>\n";
293 }
294}
virtual bool isLinkable() const =0
virtual QCString anchor() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual QCString getReference() const =0
virtual QCString displayName(bool includeScope=TRUE) const =0
virtual QCString getOutputFileBase() const =0
#define TRUE
Definition qcstring.h:37
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition util.cpp:6065
QCString convertToHtml(const QCString &s, bool keepEntities)
Definition util.cpp:4317
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4266
QCString externalLinkTarget(const bool parent)
Definition util.cpp:6021
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5243

References addHtmlExtensionIfMissing(), Definition::anchor(), Definition::briefDescriptionAsTooltip(), convertToHtml(), convertToXML(), Definition::displayName(), externalLinkTarget(), externalRef(), Definition::getOutputFileBase(), Definition::getReference(), QCString::isEmpty(), Definition::isLinkable(), and TRUE.

Referenced by TreeDiagram::drawBoxes().

◆ writeVectorBox()

static void writeVectorBox ( TextStream & t,
DiagramItem * di,
float x,
float y,
bool children = FALSE )
static

Definition at line 255 of file diagram.cpp.

257{
258 if (di->virtualness()==Specifier::Virtual) t << "dashed\n";
259 t << " (" << convertToPSString(di->label()) << ") " << x << " " << y << " box\n";
260 if (children) t << x << " " << y << " mark\n";
261 if (di->virtualness()==Specifier::Virtual) t << "solid\n";
262}
static QCString convertToPSString(const QCString &s)
Definition diagram.cpp:195

References convertToPSString(), FALSE, DiagramItem::label(), Virtual, and DiagramItem::virtualness().

Referenced by TreeDiagram::drawBoxes().

Variable Documentation

◆ fontHeight

const uint32_t fontHeight = 12

Definition at line 146 of file diagram.cpp.

Referenced by writeBitmapBox(), and ClassDiagram::writeImage().

◆ gridHeight

const uint32_t gridHeight = 100

◆ gridWidth

◆ labelHorMargin

const uint32_t labelHorMargin = 6

Definition at line 145 of file diagram.cpp.

Referenced by ClassDiagram::writeImage().

◆ labelHorSpacing

const uint32_t labelHorSpacing = 10

◆ labelVertSpacing

const uint32_t labelVertSpacing = 32

◆ maxTreeWidth

const uint32_t maxTreeWidth = 8

Definition at line 139 of file diagram.cpp.

Referenced by TreeDiagram::computeLayout().