Belle II Software  release-08-02-06
PrimitivePlotter.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #pragma once
9 
10 #include <tracking/trackFindingCDC/display/BoundingBox.h>
11 #include <tracking/trackFindingCDC/display/AttributeMap.h>
12 
13 #include <vector>
14 #include <array>
15 #include <memory>
16 
17 namespace Belle2 {
22  namespace TrackFindingCDC {
23 
26 
27  public:
29  using AttributeMap = Belle2::TrackFindingCDC::AttributeMap;
30 
31  public:
33  static const float s_defaultCanvasWidth;
34 
36  static const float s_defaultCanvasHeight;
37 
38  public:
41 
43  virtual ~PrimitivePlotter();
44 
45  public:
51  virtual std::unique_ptr<PrimitivePlotter> clone() const;
52 
53  public:
66  virtual void drawLine(float startX,
67  float startY,
68  float endX,
69  float endY,
70  const AttributeMap& attributeMap = AttributeMap());
71 
84  virtual void drawArrow(float startX,
85  float startY,
86  float endX,
87  float endY,
88  const AttributeMap& attributeMap = AttributeMap());
89 
101  virtual void drawCircle(float centerX,
102  float centerY,
103  float radius,
104  const AttributeMap& attributeMap = AttributeMap());
105 
123  virtual void drawCircleArc(float startX,
124  float startY,
125  float endX,
126  float endY,
127  float radius,
128  bool longArc,
129  bool sweepFlag,
130  const AttributeMap& attributeMap = AttributeMap());
131 
142  virtual void drawCurve(const std::vector<std::array<float, 2>>& points,
143  const std::vector<std::array<float, 2>>& tangents,
144  const AttributeMap& attributeMap = AttributeMap());
145 
153  virtual void startGroup(const AttributeMap& attributeMap = AttributeMap());
154 
162  virtual void endGroup();
163 
176  virtual const std::string save(const std::string& fileName);
177 
183  virtual void clear();
184 
186  void clearBoundingBox();
187 
190  {
191  return m_boundingBox;
192  }
193 
195  void setBoundingBox(const BoundingBox& boundingBox)
196  {
197  m_boundingBox = boundingBox;
198  }
199 
200  public:
203  {
204  return m_canvasWidth;
205  }
206 
209  {
210  return m_canvasHeight;
211  }
212 
219  void setCanvasWidth(float width)
220  {
221  m_canvasWidth = width;
222  }
223 
230  void setCanvasHeight(float height)
231  {
232  m_canvasHeight = height;
233  }
234 
235  private:
238 
241 
244  };
245  }
247 }
A two dimensional rectangle that keeps track of the extend of a drawing.
Definition: BoundingBox.h:21
A base class for plots of primitive objects.
BoundingBox m_boundingBox
Bounding box of the currently drawn objects.
void setCanvasHeight(float height)
Setter for the canvas height in pixels The canvas height denotes the size of the image being produced...
void setBoundingBox(const BoundingBox &boundingBox)
Setter for the bounding box of all drawed objects.
virtual ~PrimitivePlotter()
Make destructor virtual to handle polymorphic deconstruction.
float getCanvasWidth()
Getter for the canvas width in pixels.
float m_canvasHeight
Memory for the height of the SVG drawing in pixels.
virtual void startGroup(const AttributeMap &attributeMap=AttributeMap())
Indicates the start of a group of drawn elements.
PrimitivePlotter()
Default constructor for ROOT compatibility.
void setCanvasWidth(float width)
Setter for the canvas width in pixels.
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.
void clearBoundingBox()
Clears the current bounding box. Only following draw calls contribute to the bounding box.
virtual void drawArrow(float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
Adds an arrow to the plot.
virtual const std::string save(const std::string &fileName)
Saves the current plot state to a file.
Belle2::TrackFindingCDC::AttributeMap AttributeMap
A map type for attributes names to values for additional drawing information.
float getCanvasHeight()
Getter for the canvas height in pixels.
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.
virtual std::unique_ptr< PrimitivePlotter > clone() const
Returns a newly created plotter instance containing all information of this.
static const float s_defaultCanvasHeight
The default height of the canvas to be plotted into.
virtual void clear()
Clears all drawed elements from the plotter.
virtual void drawLine(float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
Adds a line to the plot.
static const float s_defaultCanvasWidth
The default width of the canvas to be plotted into.
const BoundingBox & getBoundingBox() const
Getter for the bounding box of all drawed objects.
virtual void drawCircle(float centerX, float centerY, float radius, const AttributeMap &attributeMap=AttributeMap())
Adds a circle to the plot.
float m_canvasWidth
Memory for the width of the SVG drawing in pixels.
virtual void endGroup()
Indicates the end of a group of drawn elements.
Abstract base class for different kinds of events.