Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
TikzWriter.h
Go to the documentation of this file.
1
32#pragma once
33
35
36namespace ogdf {
37
44public:
48 enum class LengthUnit {
49 PT,
50 MM,
51 CM,
52 IN,
53 EX,
54 EM,
55 MU
56 };
57
66
75
82 bool draw(std::ostream& os);
83
84private:
94 void wrapHeaderFooter(std::ostream& os, std::string tikzPic, bool uniformStyle,
95 bool uniformWidth, bool uniformHeight) const;
96
102 void drawAllClusters(std::ostream& os);
103
112 void drawAllNodes(std::ostream& os, bool uniformStyle, bool uniformWidth, bool uniformHeight);
113
119 void drawAllEdges(std::ostream& os);
120
127 void drawCluster(std::ostream& os, cluster c);
128
138 void drawNode(std::ostream& os, node v, bool uniformStyle, bool uniformWidth, bool uniformHeight);
139
146 void drawEdge(std::ostream& os, edge e);
147
154 std::string getClusterStyle(cluster c) const;
155
162 std::string getNodeShape(node v) const;
163
170 std::string getNodeStyle(node v) const;
171
178 std::string getNodeLabel(node v) const;
179
186 double getTextWidth(node v) const;
187
194 std::string getEdgeStyle(edge e) const;
195
202 std::string getEdgeArrows(edge e) const;
203
212 std::string getEdgeLabel(edge e, const DPoint& previousPoint, const DPoint& labelPoint) const;
213
222 bool isCoveredBy(const DPoint& p, node v) const;
223
229 double calcArrowSize() const;
230
237 std::string texLength(double f) const;
238
247 std::string getLineStyle(StrokeType strokeType, double strokeWidth, Color strokeColor) const;
248
255 static std::string getColorString(Color c);
256
259
262
265
267 std::vector<std::string> m_nodeStyles;
268
270 std::vector<std::string> m_edgeStyles;
271};
272
273}
Declares class GraphIO which provides access to all graph read and write functionality.
Representation of clusters in a clustered graph.
Stores additional attributes of a clustered graph (like layout information).
Colors represented as RGBA values.
Definition graphics.h:160
Class for the representation of edges.
Definition Graph_d.h:300
Stores additional attributes of a graph (like layout information).
Class for the representation of nodes.
Definition Graph_d.h:177
LaTeX+TikZ Writer.
Definition TikzWriter.h:43
LengthUnit
Units of length available in LaTeX.
Definition TikzWriter.h:48
@ EM
roughly the width of an 'M' (uppercase) in the current font (it depends on the font used)
@ EX
roughly the height of an 'x' (lowercase) in the current font (it depends on the font used)
@ MU
math unit equal to 1/18 em, where em is taken from the math symbols family
bool isCoveredBy(const DPoint &p, node v) const
Check whether a point (e.g.
std::string getEdgeArrows(edge e) const
Get the arrows of an edge in TikZ syntax.
std::string getNodeStyle(node v) const
Get the style of a node in TikZ syntax.
bool draw(std::ostream &os)
Output the member graph to an output stream in LaTeX+TikZ format.
const GraphAttributes & m_attr
attributes of the graph to be visualized
Definition TikzWriter.h:258
void drawAllEdges(std::ostream &os)
Draws a sequence of lines for each edge in the graph.
std::string getLineStyle(StrokeType strokeType, double strokeWidth, Color strokeColor) const
Convert an ogdf::StrokeType, strokeWidth and ogdf::Color to a a line style string in TikZ syntax.
std::vector< std::string > m_edgeStyles
to avoid as much redundancy as possible, any occurring edge style will be predefined and reused
Definition TikzWriter.h:270
std::string getEdgeStyle(edge e) const
Get the style of an edge in TikZ syntax.
TikzWriter(const ClusterGraphAttributes &attr, LengthUnit unit=LengthUnit::MM)
Construct a new writer for drawing cluster graphs using graph attributes.
Definition TikzWriter.h:73
std::string getNodeLabel(node v) const
Get the label of a node in TikZ syntax.
void drawNode(std::ostream &os, node v, bool uniformStyle, bool uniformWidth, bool uniformHeight)
Draws a node using its shape, size and style properties.
std::string getEdgeLabel(edge e, const DPoint &previousPoint, const DPoint &labelPoint) const
Get the label of an edge in TikZ syntax, positioned as a node on the edge path.
std::vector< std::string > m_nodeStyles
to avoid as much redundancy as possible, any occurring node style will be predefined and reused
Definition TikzWriter.h:267
double calcArrowSize() const
Calculates the arrow size to be used for TikZ arrows.
std::string getNodeShape(node v) const
Get the shape of a node in TikZ syntax.
void drawCluster(std::ostream &os, cluster c)
Draws a cluster as a rectangle, using its size and style properties.
TikzWriter(const GraphAttributes &attr, LengthUnit unit=LengthUnit::MM)
Construct a new writer for drawing graphs using graph attributes.
Definition TikzWriter.h:64
void drawAllNodes(std::ostream &os, bool uniformStyle, bool uniformWidth, bool uniformHeight)
Draws each node of the graph.
static std::string getColorString(Color c)
Convert an ogdf::Color to a string in TikZ syntax.
std::string texLength(double f) const
Mainly avoid scientific notation (not handled by LaTeX) and add length unit mm.
void drawAllClusters(std::ostream &os)
Draws a rectangle for each cluster in the ogdf::ClusterGraph.
std::string getClusterStyle(cluster c) const
Get the style of a cluster in TikZ syntax.
void drawEdge(std::ostream &os, edge e)
Draws a sequence of lines for each edge in the graph.
void wrapHeaderFooter(std::ostream &os, std::string tikzPic, bool uniformStyle, bool uniformWidth, bool uniformHeight) const
Wrap LaTeX/TikZ header/footer around a tikzpicture and write to output stream.
LengthUnit m_unit
The LaTeX unit to use for all ocurring lengths.
Definition TikzWriter.h:264
double getTextWidth(node v) const
Get the total width the node text may occupy.
const ClusterGraphAttributes * m_clsAttr
attributes of the cluster graph (nullptr if no cluster graph given)
Definition TikzWriter.h:261
StrokeType
Line types of strokes.
Definition graphics.h:46
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.