# OpenGraph DrawingFramework

v. 2022.02 (Dogwood)

ogdf::SvgPrinter Class Reference

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. More...

SvgPrinter (const GraphAttributes &attr, const GraphIO::SVGSettings &settings)
Creates a new SVG Printer for a ogdf::Graph. More...

bool draw (std::ostream &os)
Prints the graph and attributes of this printer to the given output stream. More...

## Private Member Functions

void appendLineStyle (pugi::xml_node line, edge e)
Writes the requested line style to the line's XML-node. More...

Draws an arrow head at the end of the edge. More...

void drawBezier (std::stringstream &ss, const DPoint &p1, const DPoint &p2, const DPoint &c1, const DPoint &c2)
Draws a cubic Bezíer path. More...

void drawBezierPath (std::stringstream &ss, List< DPoint > &points)
Draws a list of points using cubic Bézier interpolation. More...

void drawCluster (pugi::xml_node xmlNode, cluster c)
Draws a single cluster as a rectangle. More...

void drawClusters (pugi::xml_node xmlNode)
Draws a rectangle for each cluster in the ogdf::ClusterGraph. More...

pugi::xml_node drawCurve (pugi::xml_node xmlNode, edge e, List< DPoint > &points)
Draws the curve depicting a particular edge. More...

void drawEdge (pugi::xml_node xmlNode, edge e)
Draws a sequence of lines for an edge. More...

void drawEdges (pugi::xml_node xmlNode)
Draws a sequence of lines for each edge in the graph. More...

void drawLine (std::stringstream &ss, const DPoint &p1, const DPoint &p2)
Draws the path corresponding to a single line to the stream. More...

void drawLines (std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines. More...

void drawNode (pugi::xml_node xmlNode, node v)
Draws a single node. More...

void drawNodes (pugi::xml_node xmlNode)
Draws all nodes of the graph. More...

pugi::xml_node drawPolygon (pugi::xml_node xmlNode, const std::list< double > points)
Draws a polygon with the respective points. More...

void drawRoundPath (std::stringstream &ss, List< DPoint > &points)
Draws a list of points as straight lines connected by circular arcs. More...

Returns the size of the arrow. More...

Returns whether an edge arrow is to be drawn. More...

Determines whether a candidate arrow tip lies inside the rectangle of the node. More...

void writeDashArray (pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth)
Generates a string that describes the requested dash type. More...

Writes the header including the bounding box as the viewport. More...

## Private Attributes

const GraphAttributesm_attr
attributes of the graph to be visualized More...

DRect m_bbox
cached bounding box of the graph to be visualized More...

const ClusterGraphAttributesm_clsAttr
attributes of the cluster graph (nullptr if no cluster graph) More...

const GraphIO::SVGSettingsm_settings
SVG configuration. More...

## Detailed Description

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 51 of file SvgPrinter.h.

## ◆ SvgPrinter() [1/2]

 ogdf::SvgPrinter::SvgPrinter ( const GraphAttributes & attr, const GraphIO::SVGSettings & settings )
inline

Creates a new SVG Printer for a ogdf::Graph.

Parameters
 attr The attributes of the graph settings The SVG configuration

Definition at line 61 of file SvgPrinter.h.

## ◆ SvgPrinter() [2/2]

 ogdf::SvgPrinter::SvgPrinter ( const ClusterGraphAttributes & attr, const GraphIO::SVGSettings & settings )
inline

Creates a new SVG Printer for a ogdf::ClusterGraph.

Parameters
 attr The attributes of the graph settings The SVG configuration

Definition at line 74 of file SvgPrinter.h.

## ◆ appendLineStyle()

 void ogdf::SvgPrinter::appendLineStyle ( pugi::xml_node line, edge e )
private

Writes the requested line style to the line's XML-node.

Parameters
 line the XML-node depicting the line e the edge associated with that line

## ◆ draw()

 bool ogdf::SvgPrinter::draw ( std::ostream & os )

Prints the graph and attributes of this printer to the given output stream.

Parameters
 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.

Parameters
 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

## ◆ drawBezier()

 void ogdf::SvgPrinter::drawBezier ( std::stringstream & ss, const DPoint & p1, const DPoint & p2, const DPoint & c1, const DPoint & c2 )
private

Draws a cubic Bezíer path.

Parameters
 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

## ◆ drawBezierPath()

 void ogdf::SvgPrinter::drawBezierPath ( std::stringstream & ss, List< DPoint > & points )
private

Draws a list of points using cubic Bézier interpolation.

Parameters
 ss the output stream points the points to be connected by lines

## ◆ drawCluster()

 void ogdf::SvgPrinter::drawCluster ( pugi::xml_node xmlNode, cluster c )
private

Draws a single cluster as a rectangle.

Parameters
 xmlNode the XML-node to print to c the cluster to be printed

## ◆ drawClusters()

 void ogdf::SvgPrinter::drawClusters ( pugi::xml_node xmlNode )
private

Draws a rectangle for each cluster in the ogdf::ClusterGraph.

Parameters
 xmlNode the XML-node to print to

## ◆ drawCurve()

 pugi::xml_node ogdf::SvgPrinter::drawCurve ( pugi::xml_node xmlNode, edge e, List< DPoint > & points )
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.

Parameters
 xmlNode the XML-node to print to points the points along the curve e the edge depicted by the curve
Returns
the XML-node of the curve

## ◆ drawEdge()

 void ogdf::SvgPrinter::drawEdge ( pugi::xml_node xmlNode, edge e )
private

Draws a sequence of lines for an edge.

Parameters
 xmlNode the XML-node to print to e the edge to be visualized

## ◆ drawEdges()

 void ogdf::SvgPrinter::drawEdges ( pugi::xml_node xmlNode )
private

Draws a sequence of lines for each edge in the graph.

Parameters
 xmlNode the XML-node to print to

## ◆ drawLine()

 void ogdf::SvgPrinter::drawLine ( std::stringstream & ss, const DPoint & p1, const DPoint & p2 )
private

Draws the path corresponding to a single line to the stream.

Parameters
 ss the output stream p1 the first point of the line p2 the second point of the line

## ◆ drawLines()

 void ogdf::SvgPrinter::drawLines ( std::stringstream & ss, List< DPoint > & points )
private

Draws a list of points as straight lines.

Parameters
 ss the output stream points the points to be connected by lines

## ◆ drawNode()

 void ogdf::SvgPrinter::drawNode ( pugi::xml_node xmlNode, node v )
private

Draws a single node.

Parameters
 xmlNode the XML-node to print to v the node to be printed

## ◆ drawNodes()

 void ogdf::SvgPrinter::drawNodes ( pugi::xml_node xmlNode )
private

Draws all nodes of the graph.

Parameters
 xmlNode the XML-node to print to

## ◆ drawPolygon()

 pugi::xml_node ogdf::SvgPrinter::drawPolygon ( pugi::xml_node xmlNode, const std::list< double > points )
private

Draws a polygon with the respective points.

Parameters
 xmlNode the XML-node to print to points the list of coordinates
Returns
The generated XML-node

## ◆ drawRoundPath()

 void ogdf::SvgPrinter::drawRoundPath ( std::stringstream & ss, List< DPoint > & points )
private

Draws a list of points as straight lines connected by circular arcs.

Parameters
 ss the output stream points the points to be connected by lines

## ◆ getArrowSize()

private

Returns the size of the arrow.

The result is zero if the respective arrow is disabled (not to be drawn).

Parameters

## ◆ isArrowEnabled()

private

Returns whether an edge arrow is to be drawn.

Parameters

## ◆ isCoveredBy()

private

Determines whether a candidate arrow tip lies inside the rectangle of the node.

Parameters

## ◆ writeDashArray()

 void ogdf::SvgPrinter::writeDashArray ( pugi::xml_node xmlNode, StrokeType lineStyle, double lineWidth )
private

Generates a string that describes the requested dash type.

Parameters
 xmlNode the node to append the XML-attribute to lineStyle specifies the style of the dashes lineWidth the stroke width of the respective edge

 pugi::xml_node ogdf::SvgPrinter::writeHeader ( pugi::xml_document & doc )
private

Writes the header including the bounding box as the viewport.

Parameters
 doc the XML-document
Returns
the root SVG-node

## ◆ m_attr

 const GraphAttributes& ogdf::SvgPrinter::m_attr
private

attributes of the graph to be visualized

Definition at line 90 of file SvgPrinter.h.

## ◆ m_bbox

 DRect ogdf::SvgPrinter::m_bbox
private

cached bounding box of the graph to be visualized

Definition at line 96 of file SvgPrinter.h.

## ◆ m_clsAttr

 const ClusterGraphAttributes* ogdf::SvgPrinter::m_clsAttr
private

attributes of the cluster graph (nullptr if no cluster graph)

Definition at line 93 of file SvgPrinter.h.

## ◆ m_settings

 const GraphIO::SVGSettings& ogdf::SvgPrinter::m_settings
private

SVG configuration.

Definition at line 99 of file SvgPrinter.h.

The documentation for this class was generated from the following file: