Belle II Software  release-08-01-10
PrimitivePlotter Class Reference

A base class for plots of primitive objects. More...

#include <PrimitivePlotter.h>

Inheritance diagram for PrimitivePlotter:
Collaboration diagram for PrimitivePlotter:

Public Types

using AttributeMap = Belle2::TrackFindingCDC::AttributeMap
 A map type for attributes names to values for additional drawing information.
 

Public Member Functions

 PrimitivePlotter ()
 Default constructor for ROOT compatibility.
 
virtual ~PrimitivePlotter ()
 Make destructor virtual to handle polymorphic deconstruction.
 
virtual std::unique_ptr< PrimitivePlotterclone () const
 Returns a newly created plotter instance containing all information of this. More...
 
virtual void drawLine (float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
 Adds a line to the plot. More...
 
virtual void drawArrow (float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
 Adds an arrow to the plot. More...
 
virtual void drawCircle (float centerX, float centerY, float radius, const AttributeMap &attributeMap=AttributeMap())
 Adds a circle to the plot. More...
 
virtual void drawCircleArc (float startX, float startY, float endX, float endY, float radius, bool longArc, bool sweepFlag, const AttributeMap &attributeMap=AttributeMap())
 Adds a circle arc to the plot. More...
 
virtual void drawCurve (const std::vector< std::array< float, 2 >> &points, const std::vector< std::array< float, 2 >> &tangents, const AttributeMap &attributeMap=AttributeMap())
 Adds a smooth curve to the plot. More...
 
virtual void startGroup (const AttributeMap &attributeMap=AttributeMap())
 Indicates the start of a group of drawn elements. More...
 
virtual void endGroup ()
 Indicates the end of a group of drawn elements. More...
 
virtual const std::string save (const std::string &fileName)
 Saves the current plot state to a file. More...
 
virtual void clear ()
 Clears all drawed elements from the plotter. More...
 
void clearBoundingBox ()
 Clears the current bounding box. Only following draw calls contribute to the bounding box.
 
const BoundingBoxgetBoundingBox () 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 Attributes

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.
 

Detailed Description

A base class for plots of primitive objects.

Definition at line 25 of file PrimitivePlotter.h.

Member Function Documentation

◆ clear()

void clear ( void  )
virtual

Clears all drawed elements from the plotter.

Base implementation only updates the bounding box.

Reimplemented in SVGPrimitivePlotter.

Definition at line 111 of file PrimitivePlotter.cc.

112 {
113 }

◆ clone()

std::unique_ptr< PrimitivePlotter > clone ( ) const
virtual

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 in SVGPrimitivePlotter.

Definition at line 25 of file PrimitivePlotter.cc.

◆ drawArrow()

void drawArrow ( float  startX,
float  startY,
float  endX,
float  endY,
const AttributeMap attributeMap = AttributeMap() 
)
virtual

Adds an arrow to the plot.

Base implementation only updates the bounding box.

Parameters
startXx coordinate where the arrow starts.
startYy coordinate where the arrow starts.
endXx coordinate where the arrow ends.
endYy coordinate where the arrow ends.
attributeMapA map of sting keys and values that describe the drawing properties of the line.

Reimplemented in SVGPrimitivePlotter.

Definition at line 42 of file PrimitivePlotter.cc.

◆ drawCircle()

void drawCircle ( float  centerX,
float  centerY,
float  radius,
const AttributeMap attributeMap = AttributeMap() 
)
virtual

Adds a circle to the plot.

Base implementation only updates the bounding box.

Parameters
centerXx coordinate of the circle center.
centerYy coordinate of the circle center.
radiusradius of the circle
attributeMapA map of sting keys and values that describe the drawing properties of the line.

Reimplemented in SVGPrimitivePlotter.

Definition at line 52 of file PrimitivePlotter.cc.

◆ drawCircleArc()

void drawCircleArc ( float  startX,
float  startY,
float  endX,
float  endY,
float  radius,
bool  longArc,
bool  sweepFlag,
const AttributeMap attributeMap = AttributeMap() 
)
virtual

Adds a circle arc to the plot.

Base implementation only updates the bounding box.

Parameters
startXx coordinate where the line starts.
startYy coordinate where the line starts.
endXx coordinate where the line end.
endYy coordinate where the line end.
radiusRadius of the circle
longArcBoolean indicator if the long arc or the short arc is traversed from one point to the other.
sweepFlagBoolean indicator related to the curvature perceived one the circle arc. False means negative curvature. True mean positive curvature.
attributeMapA map of sting keys and values that describe the drawing properties of the line.

Reimplemented in SVGPrimitivePlotter.

Definition at line 66 of file PrimitivePlotter.cc.

◆ drawCurve()

void drawCurve ( const std::vector< std::array< float, 2 >> &  points,
const std::vector< std::array< float, 2 >> &  tangents,
const AttributeMap attributeMap = AttributeMap() 
)
virtual

Adds a smooth curve to the plot.

Base implementation only updates the bounding box.

Parameters
pointsX,Y points on the curve
tangentsTangent vector at each point. Length of tangents does not matter.
attributeMapA map of sting keys and values that describe the drawing properties of the line.

Reimplemented in SVGPrimitivePlotter.

Definition at line 80 of file PrimitivePlotter.cc.

◆ drawLine()

void drawLine ( float  startX,
float  startY,
float  endX,
float  endY,
const AttributeMap attributeMap = AttributeMap() 
)
virtual

Adds a line to the plot.

Base implementation only updates the bounding box.

Parameters
startXx coordinate where the line starts.
startYy coordinate where the line starts.
endXx coordinate where the line ends.
endYy coordinate where the line ends.
attributeMapA map of sting keys and values that describe the drawing properties of the line.

Reimplemented in SVGPrimitivePlotter.

Definition at line 32 of file PrimitivePlotter.cc.

◆ endGroup()

void endGroup ( )
virtual

Indicates the end of a group of drawn elements.

Meaning depends on the actual implementation.

Does nothing in the base implementation

Reimplemented in SVGPrimitivePlotter.

Definition at line 100 of file PrimitivePlotter.cc.

◆ save()

const std::string save ( const std::string &  fileName)
virtual

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.

Parameters
fileNameFile name where the plot shall be saved
Returns
Potentially modifed file name where the file has actually been written to.

Reimplemented in SVGPrimitivePlotter.

Definition at line 105 of file PrimitivePlotter.cc.

◆ setCanvasHeight()

void setCanvasHeight ( float  height)
inline

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.

231  {
232  m_canvasHeight = height;
233  }
float m_canvasHeight
Memory for the height of the SVG drawing in pixels.

◆ setCanvasWidth()

void setCanvasWidth ( float  width)
inline

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.

◆ startGroup()

void startGroup ( const AttributeMap attributeMap = AttributeMap())
virtual

Indicates the start of a group of drawn elements.

Meaning depends on the actual implementation.

Does nothing in the base implementation

Reimplemented in SVGPrimitivePlotter.

Definition at line 95 of file PrimitivePlotter.cc.


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