Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RPadExtent.hxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2017, 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_RPadExtent
10 #define ROOT7_RPadExtent
11 
12 #include "ROOT/RPadLength.hxx"
13 
14 #include <array>
15 #include <string>
16 
17 namespace ROOT {
18 namespace Experimental {
19 
20 /** \class RPadExtent
21 \ingroup GpadROOT7
22 \brief An extent / size (horizontal and vertical) in a `RPad`.
23 \author Axel Naumann <axel@cern.ch>
24 \date 2017-07-07
25 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
26 */
27 class RPadExtent {
28 
29  RPadLength fHoriz; ///< horizontal part
30 
31  RPadLength fVert; ///< vertical part
32 
33 public:
34 
35  RPadExtent() = default;
36 
37  RPadExtent(const RPadLength& horiz, const RPadLength& vert) : RPadExtent()
38  {
39  fHoriz = horiz;
40  fVert = vert;
41  }
42 
43  RPadLength &Horiz() { return fHoriz; }
44  const RPadLength &Horiz() const { return fHoriz; }
45 
46  RPadLength &Vert() { return fVert; }
47  const RPadLength &Vert() const { return fVert; }
48 
49 
50  /// Add two `RPadExtent`s.
51  friend RPadExtent operator+(RPadExtent lhs, const RPadExtent &rhs)
52  {
53  return {lhs.fHoriz + rhs.fHoriz, lhs.fVert + rhs.fVert};
54  }
55 
56  /// Subtract two `RPadExtent`s.
57  friend RPadExtent operator-(RPadExtent lhs, const RPadExtent &rhs)
58  {
59  return {lhs.fHoriz - rhs.fHoriz, lhs.fVert - rhs.fVert};
60  }
61 
62  /// Add a `RPadExtent`.
63  RPadExtent &operator+=(const RPadExtent &rhs)
64  {
65  fHoriz += rhs.fHoriz;
66  fVert += rhs.fVert;
67  return *this;
68  };
69 
70  /// Subtract a `RPadExtent`.
71  RPadExtent &operator-=(const RPadExtent &rhs)
72  {
73  fHoriz -= rhs.fHoriz;
74  fVert -= rhs.fVert;
75  return *this;
76  };
77 
78  /** \struct ScaleFactor
79  \ingroup GpadROOT7
80  \brief A scale factor (separate factors for horizontal and vertical) for scaling a `RPadLength`.
81  */
82  struct ScaleFactor {
83  double fHoriz; ///< Horizontal scale factor
84  double fVert; ///< Vertical scale factor
85  };
86 
87  /// Scale a horizontally and vertically.
88  /// \param scale - the scale factor,
89  RPadExtent &operator*=(const ScaleFactor &scale)
90  {
91  fHoriz *= scale.fHoriz;
92  fVert *= scale.fVert;
93  return *this;
94  };
95 };
96 
97 
98 } // namespace Experimental
99 } // namespace ROOT
100 
101 #endif