Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

SvgPrinter.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <list>
35 #include <sstream>
38 
39 namespace ogdf
40 {
41 
52 {
53 public:
54 
61  SvgPrinter(const GraphAttributes &attr, const GraphIO::SVGSettings &settings)
62  : m_attr(attr)
63  , m_clsAttr(nullptr)
64  , m_settings(settings)
65  {
66  }
67 
75  : m_attr(attr)
76  , m_clsAttr(&attr)
77  , m_settings(settings)
78  {
79  }
80 
86  bool draw(std::ostream &os);
87 
88 private:
91 
94 
97 
103  void drawClusters(pugi::xml_node xmlNode);
104 
110  void drawEdges(pugi::xml_node xmlNode);
111 
119  void drawEdge(pugi::xml_node xmlNode, edge e);
120 
134 
142  void drawLine(std::stringstream &ss, const DPoint &p1, const DPoint &p2);
143 
150  void drawBezierPath(std::stringstream &ss, List<DPoint> &points);
151 
158  void drawRoundPath(std::stringstream &ss, List<DPoint> &points);
159 
166  void drawLines(std::stringstream &ss, List<DPoint> &points);
167 
177  void drawBezier(std::stringstream &ss, const DPoint &p1, const DPoint &p2, const DPoint &c1, const DPoint &c2);
178 
184  void drawNodes(pugi::xml_node xmlNode);
185 
193 
201  void writeDashArray(pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth);
202 
209  void drawNode(pugi::xml_node xmlNode, node v);
210 
217  void drawCluster(pugi::xml_node xmlNode, cluster c);
218 
225  bool isCoveredBy(const DPoint &point, adjEntry adj);
226 
236  void drawArrowHead(pugi::xml_node xmlNode, const DPoint &start, DPoint &end, adjEntry adj);
237 
243  bool isArrowEnabled(adjEntry adj);
244 
251  double getArrowSize(adjEntry adj);
252 
259  void appendLineStyle(pugi::xml_node line, edge e);
260 
268  pugi::xml_node drawPolygon(pugi::xml_node xmlNode, const std::list<double> points);
269 };
270 
271 }
const GraphIO::SVGSettings & m_settings
SVG configuration.
Definition: SvgPrinter.h:96
void drawBezierPath(std::stringstream &ss, List< DPoint > &points)
Draws a list of points using cubic Bézier interpolation.
bool draw(std::ostream &os)
Prints the graph and attributes of this printer to the given output stream.
void drawEdge(pugi::xml_node xmlNode, edge e)
Draws a sequence of lines for an edge.
void drawClusters(pugi::xml_node xmlNode)
Draws a rectangle for each cluster in the ogdf::ClusterGraph.
void drawEdges(pugi::xml_node xmlNode)
Draws a sequence of lines for each edge in the graph.
void drawCluster(pugi::xml_node xmlNode, cluster c)
Draws a single cluster as a rectangle.
const GraphAttributes & m_attr
attributes of the graph to be visualized
Definition: SvgPrinter.h:90
const ClusterGraphAttributes * m_clsAttr
attributes of the cluster graph (nullptr if no cluster graph)
Definition: SvgPrinter.h:93
void drawNodes(pugi::xml_node xmlNode)
Draws all nodes of the graph.
SvgPrinter(const GraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::Graph.
Definition: SvgPrinter.h:61
void writeDashArray(pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth)
Generates a string that describes the requested dash type.
void drawArrowHead(pugi::xml_node xmlNode, const DPoint &start, DPoint &end, adjEntry adj)
Draws an arrow head at the end of the edge.
void appendLineStyle(pugi::xml_node line, edge e)
Writes the requested line style to the line&#39;s XML-node.
bool isCoveredBy(const DPoint &point, adjEntry adj)
Determines whether a candidate arrow tip lies inside the rectangle of the node.
pugi::xml_node writeHeader(pugi::xml_document &doc)
Writes the header including the bounding box as the viewport.
Stores additional attributes of a graph (like layout information).
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
pugi::xml_node drawPolygon(pugi::xml_node xmlNode, const std::list< double > points)
Draws a polygon with the respective points.
Class for the representation of edges.
Definition: Graph_d.h:292
Stores additional attributes of a clustered graph (like layout information).
Class for the representation of nodes.
Definition: Graph_d.h:169
void drawBezier(std::stringstream &ss, const DPoint &p1, const DPoint &p2, const DPoint &c1, const DPoint &c2)
Draws a cubic Bezíer path.
void drawLines(std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines.
void drawLine(std::stringstream &ss, const DPoint &p1, const DPoint &p2)
Draws the path corresponding to a single line to the stream.
SVG Writer.
Definition: SvgPrinter.h:51
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
Condensed settings for drawing SVGs.
Definition: GraphIO.h:79
StrokeType
Line types of strokes.
Definition: graphics.h:46
void drawRoundPath(std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines connected by circular arcs.
The namespace for all OGDF objects.
Declares class GraphIO which provides access to all graph read and write functionality.
bool isArrowEnabled(adjEntry adj)
Returns whether an edge arrow is to be drawn.
SvgPrinter(const ClusterGraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::ClusterGraph.
Definition: SvgPrinter.h:74
double getArrowSize(adjEntry adj)
Returns the size of the arrow.
Class for adjacency list elements.
Definition: Graph_d.h:79
pugi::xml_node drawCurve(pugi::xml_node xmlNode, edge e, List< DPoint > &points)
Draws the curve depicting a particular edge.
void drawNode(pugi::xml_node xmlNode, node v)
Draws a single node.