Belle II Software  release-05-02-19
PrimitivePlotter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/display/BoundingBox.h>
13 #include <tracking/trackFindingCDC/display/AttributeMap.h>
14 
15 #include <vector>
16 #include <array>
17 #include <memory>
18 
19 namespace Belle2 {
24  namespace TrackFindingCDC {
25 
27  class PrimitivePlotter {
28 
29  public:
31  using AttributeMap = Belle2::TrackFindingCDC::AttributeMap;
32 
33  public:
35  static const float s_defaultCanvasWidth;
36 
38  static const float s_defaultCanvasHeight;
39 
40  public:
43 
45  virtual ~PrimitivePlotter();
46 
47  public:
53  virtual std::unique_ptr<PrimitivePlotter> clone() const;
54 
55  public:
68  virtual void drawLine(float startX,
69  float startY,
70  float endX,
71  float endY,
72  const AttributeMap& attributeMap = AttributeMap());
73 
86  virtual void drawArrow(float startX,
87  float startY,
88  float endX,
89  float endY,
90  const AttributeMap& attributeMap = AttributeMap());
91 
103  virtual void drawCircle(float centerX,
104  float centerY,
105  float radius,
106  const AttributeMap& attributeMap = AttributeMap());
107 
125  virtual void drawCircleArc(float startX,
126  float startY,
127  float endX,
128  float endY,
129  float radius,
130  bool longArc,
131  bool sweepFlag,
132  const AttributeMap& attributeMap = AttributeMap());
133 
144  virtual void drawCurve(const std::vector<std::array<float, 2>>& points,
145  const std::vector<std::array<float, 2>>& tangents,
146  const AttributeMap& attributeMap = AttributeMap());
147 
155  virtual void startGroup(const AttributeMap& attributeMap = AttributeMap());
156 
164  virtual void endGroup();
165 
178  virtual const std::string save(const std::string& fileName);
179 
185  virtual void clear();
186 
188  void clearBoundingBox();
189 
191  const BoundingBox& getBoundingBox() const
192  {
193  return m_boundingBox;
194  }
195 
197  void setBoundingBox(const BoundingBox& boundingBox)
198  {
199  m_boundingBox = boundingBox;
200  }
201 
202  public:
204  float getCanvasWidth()
205  {
206  return m_canvasWidth;
207  }
208 
210  float getCanvasHeight()
211  {
213  }
214 
221  void setCanvasWidth(float width)
222  {
223  m_canvasWidth = width;
224  }
225 
232  void setCanvasHeight(float height)
233  {
234  m_canvasHeight = height;
235  }
236 
237  private:
239  BoundingBox m_boundingBox;
240 
242  float m_canvasWidth;
243 
245  float m_canvasHeight;
246  };
247  }
249 }
Belle2::TrackFindingCDC::PrimitivePlotter::drawCircle
virtual void drawCircle(float centerX, float centerY, float radius, const AttributeMap &attributeMap=AttributeMap())
Adds a circle to the plot.
Definition: PrimitivePlotter.cc:54
Belle2::TrackFindingCDC::PrimitivePlotter::m_canvasWidth
float m_canvasWidth
Memory for the width of the SVG drawing in pixels.
Definition: PrimitivePlotter.h:250
Belle2::TrackFindingCDC::PrimitivePlotter::getCanvasHeight
float getCanvasHeight()
Getter for the canvas height in pixels.
Definition: PrimitivePlotter.h:218
Belle2::TrackFindingCDC::PrimitivePlotter::endGroup
virtual void endGroup()
Indicates the end of a group of drawn elements.
Definition: PrimitivePlotter.cc:102
Belle2::TrackFindingCDC::PrimitivePlotter::s_defaultCanvasWidth
static const float s_defaultCanvasWidth
The default width of the canvas to be plotted into.
Definition: PrimitivePlotter.h:43
Belle2::TrackFindingCDC::PrimitivePlotter::s_defaultCanvasHeight
static const float s_defaultCanvasHeight
The default height of the canvas to be plotted into.
Definition: PrimitivePlotter.h:46
Belle2::TrackFindingCDC::PrimitivePlotter::clone
virtual std::unique_ptr< PrimitivePlotter > clone() const
Returns a newly created plotter instance containing all information of this.
Definition: PrimitivePlotter.cc:27
Belle2::TrackFindingCDC::PrimitivePlotter::drawCircleArc
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.
Definition: PrimitivePlotter.cc:68
Belle2::TrackFindingCDC::PrimitivePlotter::drawCurve
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.
Definition: PrimitivePlotter.cc:82
Belle2::TrackFindingCDC::PrimitivePlotter::AttributeMap
Belle2::TrackFindingCDC::AttributeMap AttributeMap
A map type for attributes names to values for additional drawing information.
Definition: PrimitivePlotter.h:39
Belle2::TrackFindingCDC::PrimitivePlotter::getBoundingBox
const BoundingBox & getBoundingBox() const
Getter for the bounding box of all drawed objects.
Definition: PrimitivePlotter.h:199
Belle2::TrackFindingCDC::PrimitivePlotter::setCanvasHeight
void setCanvasHeight(float height)
Setter for the canvas height in pixels The canvas height denotes the size of the image being produced...
Definition: PrimitivePlotter.h:240
Belle2::TrackFindingCDC::PrimitivePlotter::m_boundingBox
BoundingBox m_boundingBox
Bounding box of the currently drawn objects.
Definition: PrimitivePlotter.h:247
Belle2::TrackFindingCDC::PrimitivePlotter::setCanvasWidth
void setCanvasWidth(float width)
Setter for the canvas width in pixels.
Definition: PrimitivePlotter.h:229
Belle2::TrackFindingCDC::PrimitivePlotter::drawArrow
virtual void drawArrow(float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
Adds an arrow to the plot.
Definition: PrimitivePlotter.cc:44
Belle2::TrackFindingCDC::PrimitivePlotter::PrimitivePlotter
PrimitivePlotter()
Default constructor for ROOT compatibility.
Definition: PrimitivePlotter.cc:18
Belle2::TrackFindingCDC::PrimitivePlotter::m_canvasHeight
float m_canvasHeight
Memory for the height of the SVG drawing in pixels.
Definition: PrimitivePlotter.h:253
Belle2::TrackFindingCDC::PrimitivePlotter::startGroup
virtual void startGroup(const AttributeMap &attributeMap=AttributeMap())
Indicates the start of a group of drawn elements.
Definition: PrimitivePlotter.cc:97
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::PrimitivePlotter::drawLine
virtual void drawLine(float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
Adds a line to the plot.
Definition: PrimitivePlotter.cc:34
Belle2::TrackFindingCDC::PrimitivePlotter::~PrimitivePlotter
virtual ~PrimitivePlotter()
Make destructor virtual to handle polymorphic deconstruction.
Belle2::TrackFindingCDC::PrimitivePlotter::setBoundingBox
void setBoundingBox(const BoundingBox &boundingBox)
Setter for the bounding box of all drawed objects.
Definition: PrimitivePlotter.h:205
Belle2::TrackFindingCDC::BoundingBox
A two dimensional rectangle that keeps track of the extend of a drawing.
Definition: BoundingBox.h:31
Belle2::TrackFindingCDC::PrimitivePlotter::getCanvasWidth
float getCanvasWidth()
Getter for the canvas width in pixels.
Definition: PrimitivePlotter.h:212
Belle2::TrackFindingCDC::PrimitivePlotter::clearBoundingBox
void clearBoundingBox()
Clears the current bounding box. Only following draw calls contribute to the bounding box.
Definition: PrimitivePlotter.cc:117
Belle2::TrackFindingCDC::PrimitivePlotter::save
virtual const std::string save(const std::string &fileName)
Saves the current plot state to a file.
Definition: PrimitivePlotter.cc:107
Belle2::TrackFindingCDC::PrimitivePlotter::clear
virtual void clear()
Clears all drawed elements from the plotter.
Definition: PrimitivePlotter.cc:113