Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:35

0001 /*************************************************************************
0002  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 /** \class RAttrAxisLabels
0023 \ingroup GpadROOT7
0024 \author Sergey Linev <s.linev@gsi.de>
0025 \date 2021-06-28
0026 \brief Axis labels drawing attributes
0027 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
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", {}};      ///<! labels offset - relative to "default" position
0037    RAttrValue<bool> center{this, "center", false};         ///<! center labels
0038    RAttrValue<bool> hide{this, "hide", false};             ///<! hide labels
0039 };
0040 
0041 /** \class RAttrAxisTitle
0042 \ingroup GpadROOT7
0043 \author Sergey Linev <s.linev@gsi.de>
0044 \date 2021-06-28
0045 \brief Axis title and its drawing attributes
0046 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
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", ""};            ///<! axis title value
0056    RAttrValue<std::string> position{this, "position", "right"}; ///<! axis title position - left, right, center
0057    RAttrValue<RPadLength> offset{this, "offset", {}};           ///<! axis title offset - relative to "default" position
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 /** \class RAttrAxisTicks
0067 \ingroup GpadROOT7
0068 \author Sergey Linev <s.linev@gsi.de>
0069 \date 2021-06-28
0070 \brief Axis ticks attributes
0071 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
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"};     ///<! ticks position - normal, invert, both
0081    RAttrValue<RPadLength> size{this, "size", 0.02_normal};   ///<! ticks size
0082    RAttrValue<RColor> color{this, "color", RColor::kBlack};  ///<! ticks color
0083    RAttrValue<int> width{this, "width", 1};                  ///<! ticks width
0084 
0085    void SetNormal() { side = "normal"; }
0086    void SetInvert() { side = "invert"; }
0087    void SetBoth() { side = "both"; }
0088 
0089 };
0090 
0091 /** \class RAttrAxis
0092 \ingroup GpadROOT7
0093 \author Sergey Linev <s.linev@gsi.de>
0094 \date 2020-02-20
0095 \brief All supported axes attributes for: line, ticks, labels, title, min/max, log, reverse, ...
0096 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0097 */
0098 
0099 class RAttrAxis : public RAttrAggregation {
0100 
0101    R__ATTR_CLASS(RAttrAxis, "axis");
0102 
0103 public:
0104 
0105    RAttrLine line{this, "line"};                                    ///<! line attributes
0106    RAttrLineEnding ending{this, "ending"};                          ///<! ending attributes
0107    RAttrAxisLabels labels{this, "labels"};                          ///<! labels attributes
0108    RAttrAxisTitle title{this, "title"};                             ///<! title attributes
0109    RAttrAxisTicks ticks{this, "ticks"};                             ///<! ticks attributes
0110    RAttrValue<double> min{this, "min", 0.};                         ///<! axis min
0111    RAttrValue<double> max{this, "max", 0.};                         ///<! axis max
0112    RAttrValue<double> zoomMin{this, "zoomMin", 0.};                 ///<! axis zoom min
0113    RAttrValue<double> zoomMax{this, "zoomMax", 0.};                 ///<! axis zoom max
0114    RAttrValue<double> log{this, "log", 0};                          ///<! log scale, <1 off, 1 - base10, 2 - base 2, 2.71 - exp, 3, 4, ...
0115    RAttrValue<double> symlog{this, "symlog", 0};                    ///<! symlog scale constant, 0 - off
0116    RAttrValue<bool> reverse{this, "reverse", false};                ///<! reverse scale
0117    RAttrValue<bool> time{this, "time", false};                      ///<! time scale
0118    RAttrValue<double> timeOffset{this, "timeOffset", 0};            ///<! offset for time axis values
0119    RAttrValue<std::string> timeFormat{this, "timeFormat", ""};      ///<! time format
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 } // namespace Experimental
0158 } // namespace ROOT
0159 
0160 #endif