Belle II Software
release-08-01-10
|
A concrete plotter that can draw primitive objects to standalone SVG files. More...
#include <SVGPrimitivePlotter.h>
Public Types | |
using | AttributeMap = Belle2::TrackFindingCDC::AttributeMap |
A map type for attributes names to values for additional drawing information. | |
Public Member Functions | |
SVGPrimitivePlotter () | |
Default constructor for ROOT compatibility. | |
SVGPrimitivePlotter (const AttributeMap &svgAttributes) | |
Constructor taking additional attributes that go into the toplevel svg tag. More... | |
SVGPrimitivePlotter (const SVGPrimitivePlotter &plotter) | |
Copy constructor. | |
std::unique_ptr< PrimitivePlotter > | clone () const override |
Returns a newly created plotter instance containing all information of this. More... | |
void | drawLine (float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap()) override |
Adds a line to the plot. More... | |
void | drawArrow (float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap()) override |
Adds an arrow to the plot. More... | |
void | drawCircle (float centerX, float centerY, float radius, const AttributeMap &attributeMap=AttributeMap()) override |
Adds a circle to the plot. More... | |
void | drawCircleArc (float startX, float startY, float endX, float endY, float radius, bool longArc, bool sweepFlag, const AttributeMap &attributeMap=AttributeMap()) override |
Adds a circle arc to the plot. More... | |
void | drawCurve (const std::vector< std::array< float, 2 >> &points, const std::vector< std::array< float, 2 >> &tangents, const AttributeMap &attributeMap=AttributeMap()) override |
Adds a smooth curve to the plot. More... | |
void | startGroup (const AttributeMap &attributeMap=AttributeMap()) override |
Indicates the start of a group of drawn elements. More... | |
void | endGroup () override |
Indicates the end of a group of drawn elements. More... | |
const std::string | save (const std::string &fileName) override |
Saves the current plot state to a file. More... | |
void | clear () override |
Clears all drawed elements from the plotter. | |
void | clearBoundingBox () |
Clears the current bounding box. Only following draw calls contribute to the bounding box. | |
const BoundingBox & | getBoundingBox () const |
Getter for the bounding box of all drawed objects. | |
void | setBoundingBox (const BoundingBox &boundingBox) |
Setter for the bounding box of all drawed objects. | |
float | getCanvasWidth () |
Getter for the canvas width in pixels. | |
float | getCanvasHeight () |
Getter for the canvas height in pixels. | |
void | setCanvasWidth (float width) |
Setter for the canvas width in pixels. More... | |
void | setCanvasHeight (float height) |
Setter for the canvas height in pixels The canvas height denotes the size of the image being produced. More... | |
Static Public Attributes | |
static const float | s_defaultCanvasWidth = 1120.0 |
The default width of the canvas to be plotted into. | |
static const float | s_defaultCanvasHeight = 1120.0 |
The default height of the canvas to be plotted into. | |
Private Member Functions | |
void | indent () |
Increases the current indention by one. | |
void | dedent () |
Decreases the current indention by one. | |
void | writeSVGHeader (std::ostream &outputStream) |
Writes the xml header that indicates that this document will be a SVG document to the given output stream. More... | |
void | writeSVGDefs (std::ostream &outputStream) |
Writes a preamble of definitions that define an arrow cap which can be referenced by lines. | |
void | writeOpeningTag (std::ostream &outputStream, const std::string &tagName, const AttributeMap &geometryAttributeMap=AttributeMap(), const AttributeMap &styleAttributeMap=AttributeMap()) |
Writes an opening xml tag to the given output stream taking attributes from two sources. More... | |
void | writeStandAloneTag (std::ostream &outputStream, const std::string &tagName, const AttributeMap &geometryAttributeMap=AttributeMap(), const AttributeMap &styleAttributeMap=AttributeMap()) |
Writes a stand alone xml tag to the given output stream taking attributes from two sources. More... | |
void | writeTagIntern (std::ostream &outputStream, const std::string &tagName, const AttributeMap &geometryAttributeMap=AttributeMap(), const AttributeMap &styleAttributeMap=AttributeMap()) |
Writes part that belongs between the <, > brakets. More... | |
void | writeAttributes (std::ostream &outputStream, const AttributeMap &attributeMap) |
Writes attribute specification that belongs between the <, > brakets after the tag name. More... | |
void | writeClosingTag (std::ostream &outputStream, const std::string &tagName) |
Writes a closing xml tag to the given output stream. More... | |
Private Attributes | |
std::ostringstream | m_svgContentStream |
Memory for the plotted elements. This contains only the fragment that is inbetween the svg tags and comes after the global svg definitions. | |
int | m_nIndentationSpaces |
Memory for the number of spaces that shall be prepended to each line. | |
AttributeMap | m_svgAttributes |
Memory for additional attributes to the toplevel svg element. | |
BoundingBox | m_boundingBox |
Bounding box of the currently drawn objects. | |
float | m_canvasWidth |
Memory for the width of the SVG drawing in pixels. | |
float | m_canvasHeight |
Memory for the height of the SVG drawing in pixels. | |
Static Private Attributes | |
static const int | s_defaultNIndentationSpaces = 2 |
Constant for the number of indention space to be used within the svg block. | |
static const int | s_addtionalNIndentationSpaces = 2 |
Constant for the additional number of space to be prepended with each open tag group. | |
A concrete plotter that can draw primitive objects to standalone SVG files.
Definition at line 21 of file SVGPrimitivePlotter.h.
|
explicit |
Constructor taking additional attributes that go into the toplevel svg tag.
svgAttributes | A map of attributes that goes into the toplevel svg tag. |
Definition at line 28 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Returns a newly created plotter instance containing all information of this.
The new object is created on the heap. The ownership is to the caller who has the responsibility to destroy it.
Reimplemented from PrimitivePlotter.
Definition at line 44 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Adds an arrow to the plot.
startX | x coordinate where the arrow starts. |
startY | y coordinate where the arrow starts. |
endX | x coordinate where the arrow ends. |
endY | y coordinate where the arrow ends. |
attributeMap | A map of sting keys and values that describe the drawing properties of the line. |
Reimplemented from PrimitivePlotter.
Definition at line 69 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Adds a circle to the plot.
centerX | x coordinate of the circle center. |
centerY | y coordinate of the circle center. |
radius | radius of the circle |
attributeMap | A map of sting keys and values that describe the drawing properties of the line. |
Reimplemented from PrimitivePlotter.
Definition at line 89 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Adds a circle arc to the plot.
startX | x coordinate where the line starts. |
startY | y coordinate where the line starts. |
endX | x coordinate where the line end. |
endY | y coordinate where the line end. |
radius | Radius of the circle |
longArc | Boolean indicator if the long arc or the short arc is traversed from one point to the other. |
sweepFlag | Boolean indicator related to the curvature perceived one the circle arc. False means negative curvature. True mean positive curvature. |
attributeMap | A map of sting keys and values that describe the drawing properties of the line. |
Reimplemented from PrimitivePlotter.
Definition at line 107 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Adds a smooth curve to the plot.
Current implementation approxiamtes circle arcs between the points with cubic splines.
points | X,Y points on the curve |
tangents | Tangent vector at each point. Length of tangents does not matter. |
attributeMap | A map of sting keys and values that describe the drawing properties of the line. |
Reimplemented from PrimitivePlotter.
Definition at line 152 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Adds a line to the plot.
startX | x coordinate where the line starts. |
startY | y coordinate where the line starts. |
endX | x coordinate where the line ends. |
endY | y coordinate where the line ends. |
attributeMap | A map of sting keys and values that describe the drawing properties of the line. |
Reimplemented from PrimitivePlotter.
Definition at line 49 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Indicates the end of a group of drawn elements.
Meaning depends on the actual implementation.
Reimplemented from PrimitivePlotter.
Definition at line 231 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Saves the current plot state to a file.
Deriving instances may should implement the approriate thing here and may return a modified string indicating the file name to which the plot as been written. It is allowed to append or change the file extension if the concret implementation decides to do so.
fileName | fileName where the plot shall be saved |
Reimplemented from PrimitivePlotter.
Definition at line 236 of file SVGPrimitivePlotter.cc.
|
inlineinherited |
Setter for the canvas height in pixels The canvas height denotes the size of the image being produced.
The coordinates space that is visible in the picture is a seperate concept which is stored in the bounding box (getBoundingBox()).
Definition at line 230 of file PrimitivePlotter.h.
|
inlineinherited |
Setter for the canvas width in pixels.
The canvas height denotes the size of the image being produced. The coordinates space that is visible in the picture is a seperate concept which is stored in the bounding box (getBoundingBox()).
Definition at line 219 of file PrimitivePlotter.h.
|
overridevirtual |
Indicates the start of a group of drawn elements.
Meaning depends on the actual implementation.
Reimplemented from PrimitivePlotter.
Definition at line 226 of file SVGPrimitivePlotter.cc.
|
private |
Writes attribute specification that belongs between the <, > brakets after the tag name.
[out] | outputStream | The output stream to which the result is written. |
[in] | attributeMap | A map of attribute keys to attribute values that shall be attached to the tag. |
Definition at line 435 of file SVGPrimitivePlotter.cc.
|
private |
Writes a closing xml tag to the given output stream.
[out] | outputStream | The output stream to which the result is written. |
[in] | tagName | Name of the xml tag to be written |
Definition at line 463 of file SVGPrimitivePlotter.cc.
|
private |
Writes an opening xml tag to the given output stream taking attributes from two sources.
[out] | outputStream | The output stream to which the result is written. |
[in] | tagName | Name of the xml tag to be written |
[in] | geometryAttributeMap | A first map of attribute keys to attribute values that shall be attached to the tag. Usually this gives geometrical information but gets essentially treated the same way as the second attribute map |
[in] | styleAttributeMap | A second map of attribute keys to attribute values that shall be attached to the tag. Usually this gives styling information but gets essentially treated the same way as the first attribute map |
Definition at line 348 of file SVGPrimitivePlotter.cc.
|
private |
Writes a stand alone xml tag to the given output stream taking attributes from two sources.
[out] | outputStream | The output stream to which the result is written. |
[in] | tagName | Name of the xml tag to be written |
[in] | geometryAttributeMap | A first map of attribute keys to attribute values that shall be attached to the tag. Usually this gives geometrical information but gets essentially treated the same way as the second attribute map |
[in] | styleAttributeMap | A second map of attribute keys to attribute values that shall be attached to the tag. Usually this gives styling information but gets essentially treated the same way as the first attribute map |
Definition at line 386 of file SVGPrimitivePlotter.cc.
|
private |
Writes the xml header that indicates that this document will be a SVG document to the given output stream.
[out] | outputStream | The output stream to which the result is written. |
Definition at line 313 of file SVGPrimitivePlotter.cc.
|
private |
Writes part that belongs between the <, > brakets.
Used by writeOpeningTag and writeClosing.
Used by writeOpeningTag and writeClosing. Factored to avoid code dublication.
[out] | outputStream | The output stream to which the result is written. |
[in] | tagName | Name of the xml tag to be written |
[in] | geometryAttributeMap | A first map of attribute keys to attribute values that shall be attached to the tag. Usually this gives geometrical information but gets essentially treated the same way as the second attribute map |
[in] | styleAttributeMap | A second map of attribute keys to attribute values that shall be attached to the tag. Usually this gives styling information but gets essentially treated the same way as the first attribute map |
Definition at line 414 of file SVGPrimitivePlotter.cc.