ATLAS Offline Software
Loading...
Searching...
No Matches
DrawCanvasObject.cxx
Go to the documentation of this file.
1
2
3#include "DrawCanvasObject.h"
4
5
10
11 inline constexpr void expand(const double v, Range_t& r) {
12 r[0] = std::min(r[0], v);
13 r[1] = std::max(r[1], v);
14 }
15 inline void assignIfNotEmpty(const std::string& inStr, std::string& outStr) {
16 if (!inStr.empty()){
17 outStr = inStr;
18 }
19 }
20
21 DrawCanvasObject::DrawCanvasObject(const std::string& canvasName,
22 const std::size_t evtNumber):
23 m_name{canvasName},
24 m_evt{evtNumber}{}
25
27 const double deltaX = 0.5*(m_axisRanges[0][1] - m_axisRanges[0][0]) * m_axisScale;
28 const double deltaY = 0.5*(m_axisRanges[1][1] - m_axisRanges[1][0]) * m_axisScale;
29 switch (r) {
30 using enum AxisRanges;
31 case xLow:
32 case xHigh: {
33 const double mid = 0.5*(m_axisRanges[0][1] + m_axisRanges[0][0]);
34 return mid + (r == xLow ? -1. : 1.) * std::max(deltaX, deltaY * (1. -2.*m_quadCan));
35 } case yLow:
36 case yHigh: {
37 const double mid = 0.5*(m_axisRanges[1][1] + m_axisRanges[1][0]);
38 return mid + (r == yLow ? -1. : 1.) * std::max(deltaY, deltaX * (1. -2.*m_quadCan));
39 }
40 }
41 return s_dblMax;
42 }
43 void DrawCanvasObject::setRangeScale(const double s, bool quadCan) {
44 m_axisScale = std::max(1., s);
45 m_quadCan = quadCan;
46 }
48 bool DrawCanvasObject::trashed() const { return m_isTrashed; }
49 const std::string& DrawCanvasObject::name() const { return m_name; }
50 std::size_t DrawCanvasObject::event() const { return m_evt; }
51 const std::string& DrawCanvasObject::xTitle() const { return m_xTitle; }
52 const std::string& DrawCanvasObject::yTitle() const { return m_yTitle; }
53 const std::string& DrawCanvasObject::zTitle() const { return m_zTitle; }
56 void DrawCanvasObject::expandPad(const double x, const double y) {
59 }
60 void DrawCanvasObject::add(PrimitivePtr_t&& drawMe, const std::string& drawOpt) {
61 m_primitives.emplace_back(std::move(drawMe), drawOpt);
62 }
63 void DrawCanvasObject::add(std::vector<PrimitivePtr_t> && drawMe) {
64 for (PrimitivePtr_t& obj : drawMe) {
65 add(std::move(obj));
66 }
67 }
68 void DrawCanvasObject::setAxisTitles(const std::string& xTitle,
69 const std::string& yTitle,
70 const std::string& zTitle){
74 }
75}
#define y
#define x
virtual double corner(const AxisRanges r) const override final
Retrieves a corner coordinate of the drawn canvas.
std::size_t event() const
Event number in which the canvas has been created.
IRootVisualizationService::PrimitivePtr_t PrimitivePtr_t
const std::string & zTitle() const
Returns the title of the z-axis.
DrawCanvasObject(const std::string &canvasName, const std::size_t evtNumber)
virtual void add(PrimitivePtr_t &&drawMe, const std::string &drawOpt="") override final
Add a TObject to the ICanvasObject for later drawing onto a TCanvas.
const std::string & name() const
Name of the canvas.
virtual void setRangeScale(const double s, bool quadCan) override final
To ensure that the drawn objects are not cut by the axis limits, a flat scale-factor on the drawn axi...
bool trashed() const
Returns whether the canvas has been trashed.
const std::string & yTitle() const
Returns the title of the y-axis.
std::vector< std::pair< PrimitivePtr_t, std::string > > PrimitiveVec_t
const PrimitiveVec_t & primitives() const
const std::string & xTitle() const
Returns the title of the x-axis.
virtual void setAxisTitles(const std::string &xTitle, const std::string &yTitle, const std::string &zTitle) override final
Define the titles of the Canvas axes.
virtual void trash() override final
If no object has been drawn mark the plot as junk.
virtual void expandPad(const double x, const double y) override final
Expands the axes of the pad such that the coordinates are guaranteed to appear at least at the Canvas...
int r
Definition globals.cxx:22
void assignIfNotEmpty(const std::string &inStr, std::string &outStr)
DrawCanvasObject::Range_t Range_t
DrawCanvasObject::PrimitiveVec_t PrimitiveVec_t
DrawCanvasObject::PrimitivePtr_t PrimitivePtr_t
constexpr void expand(const double v, Range_t &r)
AxisRanges
Enum to select the corner coordinates shown by the plot.