Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RAttrAxis.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RAttrAxis
10#define ROOT7_RAttrAxis
11
13#include <ROOT/RAttrLine.hxx>
14#include <ROOT/RAttrText.hxx>
15#include <ROOT/RAttrValue.hxx>
16#include <ROOT/RPadLength.hxx>
17#include <cmath>
18
19namespace ROOT {
20namespace Experimental {
21
22/** \class RAttrAxisLabels
23\ingroup GpadROOT7
24\author Sergey Linev <s.linev@gsi.de>
25\date 2021-06-28
26\brief Axis labels drawing attributes
27\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
28*/
29
30class RAttrAxisLabels : public RAttrText {
31
33
34public:
35
36 RAttrValue<RPadLength> offset{this, "offset", {}}; ///<! labels offset - relative to "default" position
37 RAttrValue<bool> center{this, "center", false}; ///<! center labels
38 RAttrValue<bool> hide{this, "hide", false}; ///<! hide labels
39};
40
41/** \class RAttrAxisTitle
42\ingroup GpadROOT7
43\author Sergey Linev <s.linev@gsi.de>
44\date 2021-06-28
45\brief Axis title and its drawing attributes
46\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
47*/
48
49class RAttrAxisTitle : public RAttrText {
50
52
53public:
54
55 RAttrValue<std::string> value{this, "value", ""}; ///<! axis title value
56 RAttrValue<std::string> position{this, "position", "right"}; ///<! axis title position - left, right, center
57 RAttrValue<RPadLength> offset{this, "offset", {}}; ///<! axis title offset - relative to "default" position
58
59 RAttrAxisTitle& operator=(const std::string &_title) { value = _title; return *this; }
60
61 void SetLeft() { position = "left"; }
62 void SetCenter() { position = "center"; }
63 void SetRight() { position = "right"; }
64};
65
66/** \class RAttrAxisTicks
67\ingroup GpadROOT7
68\author Sergey Linev <s.linev@gsi.de>
69\date 2021-06-28
70\brief Axis ticks attributes
71\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
72*/
73
75
77
78public:
79
80 RAttrValue<std::string> side{this, "side", "normal"}; ///<! ticks position - normal, invert, both
81 RAttrValue<RPadLength> size{this, "size", 0.02_normal}; ///<! ticks size
82 RAttrValue<RColor> color{this, "color", RColor::kBlack}; ///<! ticks color
83 RAttrValue<int> width{this, "width", 1}; ///<! ticks width
84
85 void SetNormal() { side = "normal"; }
86 void SetInvert() { side = "invert"; }
87 void SetBoth() { side = "both"; }
88
89};
90
91/** \class RAttrAxis
92\ingroup GpadROOT7
93\author Sergey Linev <s.linev@gsi.de>
94\date 2020-02-20
95\brief All supported axes attributes for: line, ticks, labels, title, min/max, log, reverse, ...
96\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
97*/
98
100
102
103public:
104
105 RAttrLine line{this, "line"}; ///<! line attributes
106 RAttrLineEnding ending{this, "ending"}; ///<! ending attributes
107 RAttrAxisLabels labels{this, "labels"}; ///<! labels attributes
108 RAttrAxisTitle title{this, "title"}; ///<! title attributes
109 RAttrAxisTicks ticks{this, "ticks"}; ///<! ticks attributes
110 RAttrValue<double> min{this, "min", 0.}; ///<! axis min
111 RAttrValue<double> max{this, "max", 0.}; ///<! axis max
112 RAttrValue<double> zoomMin{this, "zoomMin", 0.}; ///<! axis zoom min
113 RAttrValue<double> zoomMax{this, "zoomMax", 0.}; ///<! axis zoom max
114 RAttrValue<double> log{this, "log", 0}; ///<! log scale, <1 off, 1 - base10, 2 - base 2, 2.71 - exp, 3, 4, ...
115 RAttrValue<double> symlog{this, "symlog", 0}; ///<! symlog scale constant, 0 - off
116 RAttrValue<bool> reverse{this, "reverse", false}; ///<! reverse scale
117 RAttrValue<bool> time{this, "time", false}; ///<! time scale
118 RAttrValue<double> timeOffset{this, "timeOffset", 0}; ///<! offset for time axis values
119 RAttrValue<std::string> timeFormat{this, "timeFormat", ""}; ///<! time format
120
121 RAttrAxis &SetMinMax(double _min, double _max) { min = _min; max = _max; return *this; }
122 RAttrAxis &ClearMinMax() { min.Clear(); max.Clear(); return *this; }
123
124 RAttrAxis &SetZoom(double _zoomMin, double _zoomMax) { zoomMin = _zoomMin; zoomMax = _zoomMax; return *this; }
125 RAttrAxis &ClearZoom() { zoomMin.Clear(); zoomMax.Clear(); return *this; }
126
127 bool IsLogScale() const { return this->log > 0.999999; }
128 bool IsLog10() const { auto l = this->log; return (std::fabs(l-1.) < 1e-6) || (std::fabs(l-10.) < 1e-6); }
129 bool IsLog2() const { return std::fabs(this->log - 2.) < 1e-6; }
130 bool IsLn() const { return std::fabs(this->log - 2.71828) < 0.1; }
131
132 RAttrAxis &SetTimeDisplay(const std::string &fmt = "", double offset = -1)
133 {
134 this->time = true;
135 if (!fmt.empty())
136 timeFormat = fmt;
137 else
139 if (offset >= 0)
140 timeOffset = offset;
141 else
143 return *this;
144 }
145
147 {
148 this->time.Clear();
151 }
152
153 RAttrAxis &SetTitle(const std::string &_title) { title.value = _title; return *this; }
154 std::string GetTitle() const { return title.value; }
155};
156
157} // namespace Experimental
158} // namespace ROOT
159
160#endif
#define R__ATTR_CLASS_DERIVED(ClassName, dflt_prefix, BaseClass)
#define e(i)
Definition RSha256.hxx:103
Base class for attributes aggregations like lines or fill attributes.
Axis labels drawing attributes.
Definition RAttrAxis.hxx:30
RAttrValue< bool > hide
! hide labels
Definition RAttrAxis.hxx:38
RAttrValue< bool > center
! center labels
Definition RAttrAxis.hxx:37
RAttrValue< RPadLength > offset
! labels offset - relative to "default" position
Definition RAttrAxis.hxx:36
RAttrValue< int > width
! ticks width
Definition RAttrAxis.hxx:83
R__ATTR_CLASS(RAttrAxisTicks, "ticks")
RAttrValue< RPadLength > size
! ticks size
Definition RAttrAxis.hxx:81
RAttrValue< std::string > side
! ticks position - normal, invert, both
Definition RAttrAxis.hxx:80
RAttrValue< RColor > color
! ticks color
Definition RAttrAxis.hxx:82
Axis title and its drawing attributes.
Definition RAttrAxis.hxx:49
RAttrAxisTitle & operator=(const std::string &_title)
Definition RAttrAxis.hxx:59
RAttrValue< std::string > position
! axis title position - left, right, center
Definition RAttrAxis.hxx:56
RAttrValue< std::string > value
! axis title value
Definition RAttrAxis.hxx:55
RAttrValue< RPadLength > offset
! axis title offset - relative to "default" position
Definition RAttrAxis.hxx:57
All supported axes attributes for: line, ticks, labels, title, min/max, log, reverse,...
Definition RAttrAxis.hxx:99
RAttrValue< double > symlog
! symlog scale constant, 0 - off
RAttrAxisTicks ticks
! ticks attributes
RAttrAxisLabels labels
! labels attributes
RAttrAxis & SetZoom(double _zoomMin, double _zoomMax)
RAttrAxisTitle title
! title attributes
RAttrValue< double > zoomMin
! axis zoom min
RAttrValue< double > log
! log scale, <1 off, 1 - base10, 2 - base 2, 2.71 - exp, 3, 4, ...
RAttrAxis & SetTimeDisplay(const std::string &fmt="", double offset=-1)
RAttrAxis & SetMinMax(double _min, double _max)
RAttrValue< double > max
! axis max
RAttrValue< bool > reverse
! reverse scale
RAttrLine line
! line attributes
std::string GetTitle() const
RAttrValue< double > timeOffset
! offset for time axis values
RAttrValue< std::string > timeFormat
! time format
RAttrValue< double > zoomMax
! axis zoom max
R__ATTR_CLASS(RAttrAxis, "axis")
RAttrAxis & SetTitle(const std::string &_title)
RAttrValue< bool > time
! time scale
RAttrLineEnding ending
! ending attributes
RAttrValue< double > min
! axis min
Attributes for line ending.
Definition RAttrLine.hxx:73
Drawing line attributes for different objects.
Definition RAttrLine.hxx:26
Template class to access single value from drawable or other attributes.
static R__DLLEXPORT constexpr RGB_t kBlack
Definition RColor.hxx:178
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
auto * l
Definition textangle.C:4