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