Logo ROOT   6.14/05
Reference Guide
TPadExtent.hxx
Go to the documentation of this file.
1 /// \file ROOT/TPadExtent.hxx
2 /// \ingroup Gpad ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2017-07-07
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT7_TPadExtent
17 #define ROOT7_TPadExtent
18 
19 #include "ROOT/TPadLength.hxx"
20 
21 #include <array>
22 
23 namespace ROOT {
24 namespace Experimental {
25 
26 namespace Internal {
27 /** \class ROOT::Experimental::Internal::TPadHorizVert
28  A 2D (horizontal and vertical) combination of `TPadLength`s.
29  */
30 
31 struct TPadHorizVert {
32  TPadLength fHoriz; ///< Horizontal position
33  TPadLength fVert; ///< Vertical position
34 
35  TPadHorizVert() = default;
36  TPadHorizVert(const std::array<TPadLength, 2> &hv): fHoriz(hv[0]), fVert(hv[1]) {}
37  TPadHorizVert(const TPadLength &horiz, const TPadLength &vert): fHoriz(horiz), fVert(vert) {}
38 };
39 }; // namespace Internal
40 
41 /** \class ROOT::Experimental::TPadExtent
42  An extent / size (horizontal and vertical) in a `TPad`.
43  */
46 
47  /// Add two `TPadExtent`s.
48  friend TPadExtent operator+(TPadExtent lhs, const TPadExtent &rhs)
49  {
50  return {lhs.fHoriz + rhs.fHoriz, lhs.fVert + rhs.fVert};
51  }
52 
53  /// Subtract two `TPadExtent`s.
54  friend TPadExtent operator-(TPadExtent lhs, const TPadExtent &rhs)
55  {
56  return {lhs.fHoriz - rhs.fHoriz, lhs.fVert - rhs.fVert};
57  }
58 
59  /// Add a `TPadExtent`.
61  {
62  fHoriz += rhs.fHoriz;
63  fVert += rhs.fVert;
64  return *this;
65  };
66 
67  /// Subtract a `TPadExtent`.
69  {
70  fHoriz -= rhs.fHoriz;
71  fVert -= rhs.fVert;
72  return *this;
73  };
74 
75  /** \class ScaleFactor
76  A scale factor (separate factors for horizontal and vertical) for scaling a `TPadLength`.
77  */
78  struct ScaleFactor {
79  double fHoriz; ///< Horizontal scale factor
80  double fVert; ///< Vertical scale factor
81  };
82 
83  /// Scale a `TPadHorizVert` horizonally and vertically.
84  /// \param scale - the scale factor,
86  {
87  fHoriz *= scale.fHoriz;
88  fVert *= scale.fVert;
89  return *this;
90  };
91 };
92 
93 /// Initialize a TPadExtent from a style string.
94 /// Syntax: X, Y
95 /// where X and Y are a series of numbers separated by "+", where each number is followed by one of
96 /// `px`, `user`, `normal` to specify an extent in pixel, user or normal coordinates. Spaces between
97 /// any part is allowed.
98 /// Example: `100 px + 0.1 user, 0.5 normal` is a `TPadExtent{100_px + 0.1_user, 0.5_normal}`.
99 
100 void InitializeAttrFromString(const std::string &name, const std::string &attrStrVal, TPadExtent& val);
101 
102 } // namespace Experimental
103 } // namespace ROOT
104 
105 #endif
double fHoriz
Horizontal scale factor.
Definition: TPadExtent.hxx:79
TPadLength fVert
Vertical position.
Definition: TPadExtent.hxx:33
TPadHorizVert(const std::array< TPadLength, 2 > &hv)
Definition: TPadExtent.hxx:36
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
friend TPadExtent operator+(TPadExtent lhs, const TPadExtent &rhs)
Add two TPadExtents.
Definition: TPadExtent.hxx:48
TPadHorizVert(const TPadLength &horiz, const TPadLength &vert)
Definition: TPadExtent.hxx:37
TPadLength fHoriz
Horizontal position.
Definition: TPadExtent.hxx:32
TPadExtent & operator-=(const TPadExtent &rhs)
Subtract a TPadExtent.
Definition: TPadExtent.hxx:68
double fVert
Vertical scale factor.
Definition: TPadExtent.hxx:80
A scale factor (separate factors for horizontal and vertical) for scaling a TPadLength.
Definition: TPadExtent.hxx:78
TPadExtent & operator*=(const ScaleFactor &scale)
Scale a TPadHorizVert horizonally and vertically.
Definition: TPadExtent.hxx:85
An extent / size (horizontal and vertical) in a TPad.
Definition: TPadExtent.hxx:44
TPadExtent & operator+=(const TPadExtent &rhs)
Add a TPadExtent.
Definition: TPadExtent.hxx:60
friend TPadExtent operator-(TPadExtent lhs, const TPadExtent &rhs)
Subtract two TPadExtents.
Definition: TPadExtent.hxx:54
A coordinate in a TPad.
Definition: TPadLength.hxx:26
void InitializeAttrFromString(const std::string &name, const std::string &attrStrVal, TPadExtent &val)
Initialize a TPadExtent from a style string.
Definition: TPadExtent.cxx:28
char name[80]
Definition: TGX11.cxx:109
A 2D (horizontal and vertical) combination of TPadLengths.
Definition: TPadExtent.hxx:31