Belle II Software development
|
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. | |
SVGPrimitivePlotter (const SVGPrimitivePlotter &plotter) | |
Copy constructor. | |
std::unique_ptr< PrimitivePlotter > | clone () const override |
Returns a newly created plotter instance containing all information of this. | |
void | drawLine (float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap()) override |
Adds a line to the plot. | |
void | drawArrow (float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap()) override |
Adds an arrow to the plot. | |
void | drawCircle (float centerX, float centerY, float radius, const AttributeMap &attributeMap=AttributeMap()) override |
Adds a circle to the plot. | |
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. | |
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. | |
void | startGroup (const AttributeMap &attributeMap=AttributeMap()) override |
Indicates the start of a group of drawn elements. | |
void | endGroup () override |
Indicates the end of a group of drawn elements. | |
const std::string | save (const std::string &fileName) override |
Saves the current plot state to a file. | |
void | clear () override |
Clears all drawn 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 drawn objects. | |
void | setBoundingBox (const BoundingBox &boundingBox) |
Setter for the bounding box of all drawn 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. | |
void | setCanvasHeight (float height) |
Setter for the canvas height in pixels The canvas height denotes the size of the image being produced. | |
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 indentation by one. | |
void | dedent () |
Decreases the current indentation 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. | |
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. | |
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. | |
void | writeTagIntern (std::ostream &outputStream, const std::string &tagName, const AttributeMap &geometryAttributeMap=AttributeMap(), const AttributeMap &styleAttributeMap=AttributeMap()) |
Writes part that belongs between the <, > brackets. | |
void | writeAttributes (std::ostream &outputStream, const AttributeMap &attributeMap) |
Writes attribute specification that belongs between the <, > brackets after the tag name. | |
void | writeClosingTag (std::ostream &outputStream, const std::string &tagName) |
Writes a closing xml tag to the given output stream. | |
Private Attributes | |
std::ostringstream | m_svgContentStream |
Memory for the plotted elements. This contains only the fragment that is in-between 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 top-level 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 indentation 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.
|
inherited |
A map type for attributes names to values for additional drawing information.
Definition at line 29 of file PrimitivePlotter.h.
Default constructor for ROOT compatibility.
Definition at line 20 of file SVGPrimitivePlotter.cc.
|
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.
SVGPrimitivePlotter | ( | const SVGPrimitivePlotter & | plotter | ) |
Copy constructor.
Definition at line 36 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Clears all drawn elements from the plotter.
Reimplemented from PrimitivePlotter.
Definition at line 296 of file SVGPrimitivePlotter.cc.
|
inherited |
Clears the current bounding box. Only following draw calls contribute to the bounding box.
Definition at line 115 of file PrimitivePlotter.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.
|
private |
Decreases the current indentation by one.
Definition at line 308 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 string 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 string 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 string 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 approximates 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 string 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 string 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.
|
inlineinherited |
Getter for the bounding box of all drawn objects.
Definition at line 189 of file PrimitivePlotter.h.
|
inlineinherited |
Getter for the canvas height in pixels.
Definition at line 208 of file PrimitivePlotter.h.
|
inlineinherited |
Getter for the canvas width in pixels.
Definition at line 202 of file PrimitivePlotter.h.
|
private |
Increases the current indentation by one.
Definition at line 303 of file SVGPrimitivePlotter.cc.
|
overridevirtual |
Saves the current plot state to a file.
Deriving instances should implement the appropriate 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 concrete 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 bounding box of all drawn objects.
Definition at line 195 of file PrimitivePlotter.h.
|
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 separate 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 separate 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 <, > brackets 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 a preamble of definitions that define an arrow cap which can be referenced by lines.
Definition at line 319 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 <, > brackets.
Used by writeOpeningTag and writeClosing.
Used by writeOpeningTag and writeClosing. Factored to avoid code duplication.
[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.
|
privateinherited |
Bounding box of the currently drawn objects.
Definition at line 237 of file PrimitivePlotter.h.
|
privateinherited |
Memory for the height of the SVG drawing in pixels.
Definition at line 243 of file PrimitivePlotter.h.
|
privateinherited |
Memory for the width of the SVG drawing in pixels.
Definition at line 240 of file PrimitivePlotter.h.
|
private |
Memory for the number of spaces that shall be prepended to each line.
Definition at line 242 of file SVGPrimitivePlotter.h.
|
private |
Memory for additional attributes to the top-level svg element.
Definition at line 245 of file SVGPrimitivePlotter.h.
|
private |
Memory for the plotted elements. This contains only the fragment that is in-between the svg tags and comes after the global svg definitions.
Definition at line 239 of file SVGPrimitivePlotter.h.
|
staticprivate |
Constant for the additional number of space to be prepended with each open tag group.
Definition at line 28 of file SVGPrimitivePlotter.h.
|
staticinherited |
The default height of the canvas to be plotted into.
Definition at line 36 of file PrimitivePlotter.h.
|
staticinherited |
The default width of the canvas to be plotted into.
Definition at line 33 of file PrimitivePlotter.h.
|
staticprivate |
Constant for the number of indentation space to be used within the svg block.
Definition at line 25 of file SVGPrimitivePlotter.h.