SVG Writer. More...
#include <ogdf/fileformats/SvgPrinter.h>
Public Member Functions | |
SvgPrinter (const ClusterGraphAttributes &attr, const GraphIO::SVGSettings &settings) | |
Creates a new SVG Printer for a ogdf::ClusterGraph. | |
SvgPrinter (const GraphAttributes &attr, const GraphIO::SVGSettings &settings) | |
Creates a new SVG Printer for a ogdf::Graph. | |
bool | draw (std::ostream &os) |
Prints the graph and attributes of this printer to the given output stream. | |
Private Member Functions | |
void | appendLineStyle (pugi::xml_node line, edge e, bool isArrowHead=false) |
Writes the requested line style to the line's XML-node. | |
void | drawArrowHead (pugi::xml_node xmlNode, const DPoint &start, DPoint &end, adjEntry adj) |
Draws an arrow head at the end of the edge. | |
void | drawBezier (std::stringstream &ss, const DPoint &p1, const DPoint &p2, const DPoint &c1, const DPoint &c2) |
Draws a cubic Bezíer path. | |
void | drawBezierPath (std::stringstream &ss, List< DPoint > &points) |
Draws a list of points using cubic Bézier interpolation. | |
void | drawCluster (pugi::xml_node xmlNode, cluster c) |
Draws a single cluster as a rectangle. | |
void | drawClusters (pugi::xml_node xmlNode) |
Draws a rectangle for each cluster in the ogdf::ClusterGraph. | |
pugi::xml_node | drawCurve (pugi::xml_node xmlNode, edge e, List< DPoint > &points) |
Draws the curve depicting a particular edge. | |
void | drawEdge (pugi::xml_node xmlNode, edge e) |
Draws a sequence of lines for an edge. | |
void | drawEdges (pugi::xml_node xmlNode) |
Draws a sequence of lines for each edge in the graph. | |
void | drawLine (std::stringstream &ss, const DPoint &p1, const DPoint &p2) |
Draws the path corresponding to a single line to the stream. | |
void | drawLines (std::stringstream &ss, List< DPoint > &points) |
Draws a list of points as straight lines. | |
void | drawNode (pugi::xml_node xmlNode, node v) |
Draws a single node. | |
void | drawNodes (pugi::xml_node xmlNode) |
Draws all nodes of the graph. | |
pugi::xml_node | drawPolygon (pugi::xml_node xmlNode, const std::list< double > points) |
Draws a polygon with the respective points. | |
void | drawRoundPath (std::stringstream &ss, List< DPoint > &points) |
Draws a list of points as straight lines connected by circular arcs. | |
double | getArrowSize (adjEntry adj) |
Returns the size of the arrow. | |
bool | isArrowEnabled (adjEntry adj) |
Returns whether an edge arrow is to be drawn. | |
bool | isCoveredBy (const DPoint &point, adjEntry adj) |
Determines whether a candidate arrow tip lies inside the rectangle of the node. | |
void | writeDashArray (pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth) |
Generates a string that describes the requested dash type. | |
pugi::xml_node | writeHeader (pugi::xml_document &doc) |
Writes the header including the bounding box as the viewport. | |
Private Attributes | |
const GraphAttributes & | m_attr |
attributes of the graph to be visualized | |
DRect | m_bbox |
cached bounding box of the graph to be visualized | |
const ClusterGraphAttributes * | m_clsAttr |
attributes of the cluster graph (nullptr if no cluster graph) | |
const GraphIO::SVGSettings & | m_settings |
SVG configuration. | |
SVG Writer.
Generates and outputs XML-based SVG files depicting the layout of a (cluster-)graph.
Curved edges will be drawn if specified by ogdf::GraphIO::SVGSettings. Set the curviness to a value greater than 0 to obtain curved edges. There are two modes for drawing curved edges: Bézier curves and circular arcs.
Definition at line 52 of file SvgPrinter.h.
|
inline |
Creates a new SVG Printer for a ogdf::Graph.
attr | The attributes of the graph |
settings | The SVG configuration |
Definition at line 60 of file SvgPrinter.h.
|
inline |
Creates a new SVG Printer for a ogdf::ClusterGraph.
attr | The attributes of the graph |
settings | The SVG configuration |
Definition at line 69 of file SvgPrinter.h.
|
private |
Writes the requested line style to the line's XML-node.
line | the XML-node depicting the line |
e | the edge associated with that line |
isArrowHead | whether line is an arrow head polygon |
bool ogdf::SvgPrinter::draw | ( | std::ostream & | os | ) |
Prints the graph and attributes of this printer to the given output stream.
os | The stream to print to |
|
private |
Draws an arrow head at the end of the edge.
Sets the end point of the respective edge segment to the arrow head's tip.
xmlNode | the XML-node to print to |
start | the start point of the edge segment the arrow head will be placed on |
end | the end point of the edge segment the arrow head will be placed on, this will usually be modified |
adj | the adjacency entry |
|
private |
Draws a cubic Bezíer path.
ss | the output stream |
p1 | the first point of the line |
p2 | the second point of the line |
c1 | the first control point of the line |
c2 | the second control point of the line |
Draws a list of points using cubic Bézier interpolation.
ss | the output stream |
points | the points to be connected by lines |
|
private |
Draws a single cluster as a rectangle.
xmlNode | the XML-node to print to |
c | the cluster to be printed |
|
private |
Draws a rectangle for each cluster in the ogdf::ClusterGraph.
xmlNode | the XML-node to print to |
|
private |
Draws the curve depicting a particular edge.
Draws a sequence of cubic Bézier curves if requested. Falls back to straight lines if there are exactly two points or the curviness is set to 0.
Note that this method clears the list of points.
xmlNode | the XML-node to print to |
points | the points along the curve |
e | the edge depicted by the curve |
|
private |
Draws a sequence of lines for an edge.
Arrow heads are added if requested.
xmlNode | the XML-node to print to |
e | the edge to be visualized |
|
private |
Draws a sequence of lines for each edge in the graph.
xmlNode | the XML-node to print to |
|
private |
Draws the path corresponding to a single line to the stream.
ss | the output stream |
p1 | the first point of the line |
p2 | the second point of the line |
Draws a list of points as straight lines.
ss | the output stream |
points | the points to be connected by lines |
|
private |
Draws a single node.
xmlNode | the XML-node to print to |
v | the node to be printed |
|
private |
Draws all nodes of the graph.
xmlNode | the XML-node to print to |
|
private |
Draws a polygon with the respective points.
xmlNode | the XML-node to print to |
points | the list of coordinates |
Draws a list of points as straight lines connected by circular arcs.
ss | the output stream |
points | the points to be connected by lines |
Returns the size of the arrow.
The result is zero if the respective arrow is disabled (not to be drawn).
adj | the adjacency entry |
Returns whether an edge arrow is to be drawn.
adj | the adjacency entry |
Determines whether a candidate arrow tip lies inside the rectangle of the node.
point | the candidate arrow tip |
adj | the adjacency entry |
|
private |
Generates a string that describes the requested dash type.
xmlNode | the node to append the XML-attribute to |
lineStyle | specifies the style of the dashes |
lineWidth | the stroke width of the respective edge |
|
private |
Writes the header including the bounding box as the viewport.
doc | the XML-document |
|
private |
attributes of the graph to be visualized
Definition at line 81 of file SvgPrinter.h.
|
private |
cached bounding box of the graph to be visualized
Definition at line 87 of file SvgPrinter.h.
|
private |
attributes of the cluster graph (nullptr
if no cluster graph)
Definition at line 84 of file SvgPrinter.h.
|
private |
SVG configuration.
Definition at line 90 of file SvgPrinter.h.