Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

SvgPrinter.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 
37 
38 #include <list>
39 #include <sstream>
40 
41 namespace ogdf {
42 
52 class SvgPrinter {
53 public:
60  SvgPrinter(const GraphAttributes& attr, const GraphIO::SVGSettings& settings)
61  : m_attr(attr), m_clsAttr(nullptr), m_settings(settings) { }
62 
70  : m_attr(attr), m_clsAttr(&attr), m_settings(settings) { }
71 
77  bool draw(std::ostream& os);
78 
79 private:
82 
85 
88 
91 
97  void drawClusters(pugi::xml_node xmlNode);
98 
104  void drawEdges(pugi::xml_node xmlNode);
105 
113  void drawEdge(pugi::xml_node xmlNode, edge e);
114 
128 
136  void drawLine(std::stringstream& ss, const DPoint& p1, const DPoint& p2);
137 
144  void drawBezierPath(std::stringstream& ss, List<DPoint>& points);
145 
152  void drawRoundPath(std::stringstream& ss, List<DPoint>& points);
153 
160  void drawLines(std::stringstream& ss, List<DPoint>& points);
161 
171  void drawBezier(std::stringstream& ss, const DPoint& p1, const DPoint& p2, const DPoint& c1,
172  const DPoint& c2);
173 
179  void drawNodes(pugi::xml_node xmlNode);
180 
188 
196  void writeDashArray(pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth);
197 
204  void drawNode(pugi::xml_node xmlNode, node v);
205 
212  void drawCluster(pugi::xml_node xmlNode, cluster c);
213 
220  bool isCoveredBy(const DPoint& point, adjEntry adj) const;
221 
231  void drawArrowHead(pugi::xml_node xmlNode, const DPoint& start, DPoint& end, adjEntry adj);
232 
238  bool isArrowEnabled(adjEntry adj);
239 
246  double getArrowSize(adjEntry adj);
247 
255  void appendLineStyle(pugi::xml_node line, edge e, bool isArrowHead = false);
256 
264  pugi::xml_node drawPolygon(pugi::xml_node xmlNode, const std::list<double> points);
265 };
266 
267 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
ogdf::SvgPrinter::writeDashArray
void writeDashArray(pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth)
Generates a string that describes the requested dash type.
ogdf::GenericPoint< double >
ogdf::SvgPrinter::writeHeader
pugi::xml_node writeHeader(pugi::xml_document &doc)
Writes the header including the bounding box as the viewport.
ogdf::StrokeType
StrokeType
Line types of strokes.
Definition: graphics.h:46
ogdf::SvgPrinter::drawCurve
pugi::xml_node drawCurve(pugi::xml_node xmlNode, edge e, List< DPoint > &points)
Draws the curve depicting a particular edge.
ogdf::SvgPrinter
SVG Writer.
Definition: SvgPrinter.h:52
ogdf::SvgPrinter::drawRoundPath
void drawRoundPath(std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines connected by circular arcs.
ogdf::SvgPrinter::drawArrowHead
void drawArrowHead(pugi::xml_node xmlNode, const DPoint &start, DPoint &end, adjEntry adj)
Draws an arrow head at the end of the edge.
pugixml.h
ogdf::SvgPrinter::drawEdge
void drawEdge(pugi::xml_node xmlNode, edge e)
Draws a sequence of lines for an edge.
ogdf::SvgPrinter::m_bbox
DRect m_bbox
cached bounding box of the graph to be visualized
Definition: SvgPrinter.h:87
ogdf::SvgPrinter::drawBezier
void drawBezier(std::stringstream &ss, const DPoint &p1, const DPoint &p2, const DPoint &c1, const DPoint &c2)
Draws a cubic Bezíer path.
ogdf::SvgPrinter::drawLine
void drawLine(std::stringstream &ss, const DPoint &p1, const DPoint &p2)
Draws the path corresponding to a single line to the stream.
ogdf::SvgPrinter::drawPolygon
pugi::xml_node drawPolygon(pugi::xml_node xmlNode, const std::list< double > points)
Draws a polygon with the respective points.
ogdf::SvgPrinter::drawLines
void drawLines(std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines.
ogdf::SvgPrinter::drawClusters
void drawClusters(pugi::xml_node xmlNode)
Draws a rectangle for each cluster in the ogdf::ClusterGraph.
ogdf::SvgPrinter::draw
bool draw(std::ostream &os)
Prints the graph and attributes of this printer to the given output stream.
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::SvgPrinter::isArrowEnabled
bool isArrowEnabled(adjEntry adj)
Returns whether an edge arrow is to be drawn.
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:46
ogdf::SvgPrinter::drawEdges
void drawEdges(pugi::xml_node xmlNode)
Draws a sequence of lines for each edge in the graph.
ogdf::GraphIO::SVGSettings
Condensed settings for drawing SVGs.
Definition: GraphIO.h:116
ogdf::DRect
Rectangles with real coordinates.
Definition: geometry.h:791
GraphIO.h
Declares class GraphIO which provides access to all graph read and write functionality.
pugi::xml_node
Definition: pugixml.h:401
ogdf::SvgPrinter::m_clsAttr
const ClusterGraphAttributes * m_clsAttr
attributes of the cluster graph (nullptr if no cluster graph)
Definition: SvgPrinter.h:84
ogdf::SvgPrinter::appendLineStyle
void appendLineStyle(pugi::xml_node line, edge e, bool isArrowHead=false)
Writes the requested line style to the line's XML-node.
ogdf::SvgPrinter::SvgPrinter
SvgPrinter(const ClusterGraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::ClusterGraph.
Definition: SvgPrinter.h:69
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::SvgPrinter::isCoveredBy
bool isCoveredBy(const DPoint &point, adjEntry adj) const
Determines whether a candidate arrow tip lies inside the rectangle of the node.
ogdf::SvgPrinter::SvgPrinter
SvgPrinter(const GraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::Graph.
Definition: SvgPrinter.h:60
ogdf::SvgPrinter::drawBezierPath
void drawBezierPath(std::stringstream &ss, List< DPoint > &points)
Draws a list of points using cubic Bézier interpolation.
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
pugi::xml_document
Definition: pugixml.h:943
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::SvgPrinter::m_attr
const GraphAttributes & m_attr
attributes of the graph to be visualized
Definition: SvgPrinter.h:81
ogdf::SvgPrinter::drawNodes
void drawNodes(pugi::xml_node xmlNode)
Draws all nodes of the graph.
ogdf::SvgPrinter::drawCluster
void drawCluster(pugi::xml_node xmlNode, cluster c)
Draws a single cluster as a rectangle.
ogdf::SvgPrinter::getArrowSize
double getArrowSize(adjEntry adj)
Returns the size of the arrow.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::SvgPrinter::m_settings
const GraphIO::SVGSettings & m_settings
SVG configuration.
Definition: SvgPrinter.h:90
ogdf::SvgPrinter::drawNode
void drawNode(pugi::xml_node xmlNode, node v)
Draws a single node.