File indexing completed on 2025-01-18 10:10:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_RAttrAxis
0010 #define ROOT7_RAttrAxis
0011
0012 #include <ROOT/RAttrAggregation.hxx>
0013 #include <ROOT/RAttrLine.hxx>
0014 #include <ROOT/RAttrText.hxx>
0015 #include <ROOT/RAttrValue.hxx>
0016 #include <ROOT/RPadLength.hxx>
0017 #include <cmath>
0018
0019 namespace ROOT {
0020 namespace Experimental {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 class RAttrAxisLabels : public RAttrText {
0031
0032 R__ATTR_CLASS_DERIVED(RAttrAxisLabels, "labels", RAttrText)
0033
0034 public:
0035
0036 RAttrValue<RPadLength> offset{this, "offset", {}};
0037 RAttrValue<bool> center{this, "center", false};
0038 RAttrValue<bool> hide{this, "hide", false};
0039 };
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 class RAttrAxisTitle : public RAttrText {
0050
0051 R__ATTR_CLASS_DERIVED(RAttrAxisTitle, "title", RAttrText)
0052
0053 public:
0054
0055 RAttrValue<std::string> value{this, "value", ""};
0056 RAttrValue<std::string> position{this, "position", "right"};
0057 RAttrValue<RPadLength> offset{this, "offset", {}};
0058
0059 RAttrAxisTitle& operator=(const std::string &_title) { value = _title; return *this; }
0060
0061 void SetLeft() { position = "left"; }
0062 void SetCenter() { position = "center"; }
0063 void SetRight() { position = "right"; }
0064 };
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 class RAttrAxisTicks : public RAttrAggregation {
0075
0076 R__ATTR_CLASS(RAttrAxisTicks, "ticks");
0077
0078 public:
0079
0080 RAttrValue<std::string> side{this, "side", "normal"};
0081 RAttrValue<RPadLength> size{this, "size", 0.02_normal};
0082 RAttrValue<RColor> color{this, "color", RColor::kBlack};
0083 RAttrValue<int> width{this, "width", 1};
0084
0085 void SetNormal() { side = "normal"; }
0086 void SetInvert() { side = "invert"; }
0087 void SetBoth() { side = "both"; }
0088
0089 };
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 class RAttrAxis : public RAttrAggregation {
0100
0101 R__ATTR_CLASS(RAttrAxis, "axis");
0102
0103 public:
0104
0105 RAttrLine line{this, "line"};
0106 RAttrLineEnding ending{this, "ending"};
0107 RAttrAxisLabels labels{this, "labels"};
0108 RAttrAxisTitle title{this, "title"};
0109 RAttrAxisTicks ticks{this, "ticks"};
0110 RAttrValue<double> min{this, "min", 0.};
0111 RAttrValue<double> max{this, "max", 0.};
0112 RAttrValue<double> zoomMin{this, "zoomMin", 0.};
0113 RAttrValue<double> zoomMax{this, "zoomMax", 0.};
0114 RAttrValue<double> log{this, "log", 0};
0115 RAttrValue<double> symlog{this, "symlog", 0};
0116 RAttrValue<bool> reverse{this, "reverse", false};
0117 RAttrValue<bool> time{this, "time", false};
0118 RAttrValue<double> timeOffset{this, "timeOffset", 0};
0119 RAttrValue<std::string> timeFormat{this, "timeFormat", ""};
0120
0121 RAttrAxis &SetMinMax(double _min, double _max) { min = _min; max = _max; return *this; }
0122 RAttrAxis &ClearMinMax() { min.Clear(); max.Clear(); return *this; }
0123
0124 RAttrAxis &SetZoom(double _zoomMin, double _zoomMax) { zoomMin = _zoomMin; zoomMax = _zoomMax; return *this; }
0125 RAttrAxis &ClearZoom() { zoomMin.Clear(); zoomMax.Clear(); return *this; }
0126
0127 bool IsLogScale() const { return this->log > 0.999999; }
0128 bool IsLog10() const { auto l = this->log; return (std::fabs(l-1.) < 1e-6) || (std::fabs(l-10.) < 1e-6); }
0129 bool IsLog2() const { return std::fabs(this->log - 2.) < 1e-6; }
0130 bool IsLn() const { return std::fabs(this->log - 2.71828) < 0.1; }
0131
0132 RAttrAxis &SetTimeDisplay(const std::string &fmt = "", double offset = -1)
0133 {
0134 this->time = true;
0135 if (!fmt.empty())
0136 timeFormat = fmt;
0137 else
0138 timeFormat.Clear();
0139 if (offset >= 0)
0140 timeOffset = offset;
0141 else
0142 timeOffset.Clear();
0143 return *this;
0144 }
0145
0146 void ClearTimeDisplay()
0147 {
0148 this->time.Clear();
0149 timeOffset.Clear();
0150 timeFormat.Clear();
0151 }
0152
0153 RAttrAxis &SetTitle(const std::string &_title) { title.value = _title; return *this; }
0154 std::string GetTitle() const { return title.value; }
0155 };
0156
0157 }
0158 }
0159
0160 #endif