Belle II Software  release-08-01-10
PrimitivePlotter.cc
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 #include <tracking/trackFindingCDC/display/PrimitivePlotter.h>
9 
10 using namespace Belle2;
11 using namespace TrackFindingCDC;
12 
13 const float PrimitivePlotter::s_defaultCanvasWidth = 1120.0;
14 const float PrimitivePlotter::s_defaultCanvasHeight = 1120.0;
15 
17  m_boundingBox(),
18  m_canvasWidth(s_defaultCanvasWidth),
19  m_canvasHeight(s_defaultCanvasHeight)
20 {
21 }
22 
24 
25 std::unique_ptr<PrimitivePlotter> PrimitivePlotter::clone() const
26 {
27  return std::make_unique<PrimitivePlotter>(*this);
28 }
29 
30 
31 
32 void PrimitivePlotter::drawLine(float startX,
33  float startY,
34  float endX,
35  float endY,
36  const AttributeMap& attributeMap __attribute__((unused)))
37 {
38  m_boundingBox &= BoundingBox(startX, startY, endX, endY);
39 }
40 
41 
42 void PrimitivePlotter::drawArrow(float startX,
43  float startY,
44  float endX,
45  float endY,
46  const AttributeMap& attributeMap __attribute__((unused)))
47 {
48  m_boundingBox &= BoundingBox(startX, startY, endX, endY);
49 }
50 
51 
52 void PrimitivePlotter::drawCircle(float centerX,
53  float centerY,
54  float radius,
55  const AttributeMap& attributeMap __attribute__((unused)))
56 {
57  const float left = centerX - radius;
58  const float bottom = centerY - radius;
59  const float right = centerX + radius;
60  const float top = centerY + radius;
61 
62  m_boundingBox &= BoundingBox(left, bottom, right, top);
63 }
64 
65 
67  float startY,
68  float endX,
69  float endY,
70  float radius __attribute__((unused)),
71  bool longArc __attribute__((unused)),
72  bool sweepFlag __attribute__((unused)),
73  const AttributeMap& attributeMap __attribute__((unused)))
74 {
75  // The actual extend of the circle arc is more complicating.
76  // Please fill in the soultion if you have one.
77  m_boundingBox &= BoundingBox(startX, startY, endX, endY);
78 }
79 
80 void PrimitivePlotter::drawCurve(const std::vector<std::array<float, 2> >& points,
81  const std::vector<std::array<float, 2> >& tangents __attribute__((unused)),
82  const AttributeMap& /*attributeMap */)
83 {
84  for (size_t i = 0; i < points.size() - 1; ++i) {
85  float startX = points[i][0];
86  float startY = points[i][1];
87  float endX = points[i + 1][0];
88  float endY = points[i + 1][1];
89  m_boundingBox &= BoundingBox(startX, startY, endX, endY);
90  }
91 }
92 
93 
94 
95 void PrimitivePlotter::startGroup(const AttributeMap& attributeMap __attribute__((unused)))
96 {
97 }
98 
99 
101 {
102 }
103 
104 
105 const std::string PrimitivePlotter::save(const std::string& fileName __attribute__((unused)))
106 {
107  return "";
108 }
109 
110 
112 {
113 }
114 
116 {
118 }
119 
A two dimensional rectangle that keeps track of the extend of a drawing.
Definition: BoundingBox.h:21
void clear()
Clears all bounds to NAN.
Definition: BoundingBox.h:87
BoundingBox m_boundingBox
Bounding box of the currently drawn objects.
virtual ~PrimitivePlotter()
Make destructor virtual to handle polymorphic deconstruction.
virtual void startGroup(const AttributeMap &attributeMap=AttributeMap())
Indicates the start of a group of drawn elements.
PrimitivePlotter()
Default constructor for ROOT compatibility.
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.
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.
virtual void drawCircle(float centerX, float centerY, float radius, const AttributeMap &attributeMap=AttributeMap())
Adds a circle to the plot.
virtual void endGroup()
Indicates the end of a group of drawn elements.
Abstract base class for different kinds of events.