Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
SvgPrinter.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/geometry.h>
39
41
42#include <list>
43#include <sstream>
44
45namespace ogdf {
46class GraphAttributes;
47enum class StrokeType : unsigned char;
48template<class E>
49class List;
50
61public:
68 SvgPrinter(const GraphAttributes& attr, const GraphIO::SVGSettings& settings)
69 : m_attr(attr), m_clsAttr(nullptr), m_settings(settings) { }
70
78 : m_attr(attr), m_clsAttr(&attr), m_settings(settings) { }
79
85 bool draw(std::ostream& os);
86
87private:
90
93
96
99
106
113
121 void drawEdge(pugi::xml_node xmlNode, edge e);
122
136
144 void drawLine(std::stringstream& ss, const DPoint& p1, const DPoint& p2);
145
152 void drawBezierPath(std::stringstream& ss, List<DPoint>& points);
153
160 void drawRoundPath(std::stringstream& ss, List<DPoint>& points);
161
168 void drawLines(std::stringstream& ss, List<DPoint>& points);
169
179 void drawBezier(std::stringstream& ss, const DPoint& p1, const DPoint& p2, const DPoint& c1,
180 const DPoint& c2);
181
188
196
204 void writeDashArray(pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth);
205
212 void drawNode(pugi::xml_node xmlNode, node v);
213
221
228 bool isCoveredBy(const DPoint& point, adjEntry adj) const;
229
239 void drawArrowHead(pugi::xml_node xmlNode, const DPoint& start, DPoint& end, adjEntry adj);
240
247
255
263 void appendLineStyle(pugi::xml_node line, edge e, bool isArrowHead = false);
264
272 pugi::xml_node drawPolygon(pugi::xml_node xmlNode, const std::list<double> points);
273};
274
275}
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
Includes declaration of graph class.
Declares class GraphIO which provides access to all graph read and write functionality.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Class for adjacency list elements.
Definition Graph_d.h:143
Representation of clusters in a clustered graph.
Stores additional attributes of a clustered graph (like layout information).
Rectangles with real coordinates.
Definition geometry.h:798
Class for the representation of edges.
Definition Graph_d.h:364
Stores additional attributes of a graph (like layout information).
Condensed settings for drawing SVGs.
Definition GraphIO.h:128
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
SVG Writer.
Definition SvgPrinter.h:60
SvgPrinter(const GraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::Graph.
Definition SvgPrinter.h:68
void drawLines(std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines.
bool isArrowEnabled(adjEntry adj)
Returns whether an edge arrow is to be drawn.
pugi::xml_node writeHeader(pugi::xml_document &doc)
Writes the header including the bounding box as the viewport.
void appendLineStyle(pugi::xml_node line, edge e, bool isArrowHead=false)
Writes the requested line style to the line's XML-node.
void drawBezierPath(std::stringstream &ss, List< DPoint > &points)
Draws a list of points using cubic Bézier interpolation.
void drawBezier(std::stringstream &ss, const DPoint &p1, const DPoint &p2, const DPoint &c1, const DPoint &c2)
Draws a cubic Bezíer path.
bool isCoveredBy(const DPoint &point, adjEntry adj) const
Determines whether a candidate arrow tip lies inside the rectangle of the node.
const ClusterGraphAttributes * m_clsAttr
attributes of the cluster graph (nullptr if no cluster graph)
Definition SvgPrinter.h:92
void writeDashArray(pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth)
Generates a string that describes the requested dash type.
DRect m_bbox
cached bounding box of the graph to be visualized
Definition SvgPrinter.h:95
double getArrowSize(adjEntry adj)
Returns the size of the arrow.
const GraphIO::SVGSettings & m_settings
SVG configuration.
Definition SvgPrinter.h:98
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 drawRoundPath(std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines connected by circular arcs.
void drawEdges(pugi::xml_node xmlNode)
Draws a sequence of lines for each edge in the graph.
void drawArrowHead(pugi::xml_node xmlNode, const DPoint &start, DPoint &end, adjEntry adj)
Draws an arrow head at the end of the edge.
void drawClusters(pugi::xml_node xmlNode)
Draws a rectangle for each cluster in the ogdf::ClusterGraph.
void drawCluster(pugi::xml_node xmlNode, cluster c)
Draws a single cluster as a rectangle.
void drawNodes(pugi::xml_node xmlNode)
Draws all nodes of the graph.
const GraphAttributes & m_attr
attributes of the graph to be visualized
Definition SvgPrinter.h:89
void drawNode(pugi::xml_node xmlNode, node v)
Draws a single node.
SvgPrinter(const ClusterGraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::ClusterGraph.
Definition SvgPrinter.h:77
pugi::xml_node drawPolygon(pugi::xml_node xmlNode, const std::list< double > points)
Draws a polygon with the respective points.
void drawLine(std::stringstream &ss, const DPoint &p1, const DPoint &p2)
Draws the path corresponding to a single line to the stream.
pugi::xml_node drawCurve(pugi::xml_node xmlNode, edge e, List< DPoint > &points)
Draws the curve depicting a particular edge.
StrokeType
Line types of strokes.
Definition graphics.h:50
The namespace for all OGDF objects.
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)