Open
Graph Drawing
Framework

 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...
 
void drawArrowHead (pugi::xml_node xmlNode, const DPoint &start, DPoint &end, adjEntry adj)
 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...
 
double getArrowSize (adjEntry adj)
 Returns the size of the arrow. More...
 
bool isArrowEnabled (adjEntry adj)
 Returns whether an edge arrow is to be drawn. More...
 
bool isCoveredBy (const DPoint &point, adjEntry adj)
 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...
 
pugi::xml_node writeHeader (pugi::xml_document &doc)
 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.

Constructor & Destructor Documentation

◆ SvgPrinter() [1/2]

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

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

Parameters
attrThe attributes of the graph
settingsThe 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
attrThe attributes of the graph
settingsThe SVG configuration

Definition at line 74 of file SvgPrinter.h.

Member Function Documentation

◆ appendLineStyle()

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

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

Parameters
linethe XML-node depicting the line
ethe 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
osThe stream to print to

◆ drawArrowHead()

void ogdf::SvgPrinter::drawArrowHead ( pugi::xml_node  xmlNode,
const DPoint start,
DPoint end,
adjEntry  adj 
)
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
xmlNodethe XML-node to print to
startthe start point of the edge segment the arrow head will be placed on
endthe end point of the edge segment the arrow head will be placed on, this will usually be modified
adjthe 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
ssthe output stream
p1the first point of the line
p2the second point of the line
c1the first control point of the line
c2the 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
ssthe output stream
pointsthe 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
xmlNodethe XML-node to print to
cthe 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
xmlNodethe 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
xmlNodethe XML-node to print to
pointsthe points along the curve
ethe 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.

Arrow heads are added if requested.

Parameters
xmlNodethe XML-node to print to
ethe 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
xmlNodethe 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
ssthe output stream
p1the first point of the line
p2the 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
ssthe output stream
pointsthe points to be connected by lines

◆ drawNode()

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

Draws a single node.

Parameters
xmlNodethe XML-node to print to
vthe node to be printed

◆ drawNodes()

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

Draws all nodes of the graph.

Parameters
xmlNodethe 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
xmlNodethe XML-node to print to
pointsthe 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
ssthe output stream
pointsthe points to be connected by lines

◆ getArrowSize()

double ogdf::SvgPrinter::getArrowSize ( adjEntry  adj)
private

Returns the size of the arrow.

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

Parameters
adjthe adjacency entry

◆ isArrowEnabled()

bool ogdf::SvgPrinter::isArrowEnabled ( adjEntry  adj)
private

Returns whether an edge arrow is to be drawn.

Parameters
adjthe adjacency entry

◆ isCoveredBy()

bool ogdf::SvgPrinter::isCoveredBy ( const DPoint point,
adjEntry  adj 
)
private

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

Parameters
pointthe candidate arrow tip
adjthe adjacency entry

◆ writeDashArray()

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

Generates a string that describes the requested dash type.

Parameters
xmlNodethe node to append the XML-attribute to
lineStylespecifies the style of the dashes
lineWidththe stroke width of the respective edge

◆ writeHeader()

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

Writes the header including the bounding box as the viewport.

Parameters
docthe XML-document
Returns
the root SVG-node

Member Data Documentation

◆ 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: