Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RPadPos.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_RPadPos
10 #define ROOT7_RPadPos
11 
12 #include "ROOT/RPadExtent.hxx"
13 
14 #include <array>
15 #include <string>
16 
17 namespace ROOT {
18 namespace Experimental {
19 
20 /** \class ROOT::Experimental::RPadPos
21 \ingroup GpadROOT7
22 \brief A position (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 
28 class RPadPos {
29 
30  RPadLength fHoriz; ///< horizontal part
31 
32  RPadLength fVert; ///< vertical part
33 
34 public:
35 
36  RPadPos() = default;
37 
38  RPadPos(const RPadLength& horiz, const RPadLength& vert) : RPadPos()
39  {
40  fHoriz = horiz;
41  fVert = vert;
42  }
43 
44  RPadPos(const RPadExtent &rhs) : RPadPos()
45  {
46  fHoriz = rhs.Horiz();
47  fVert = rhs.Vert();
48  }
49 
50  RPadLength &Horiz() { return fHoriz; }
51  const RPadLength &Horiz() const { return fHoriz; }
52 
53  RPadLength &Vert() { return fVert; }
54  const RPadLength &Vert() const { return fVert; }
55 
56 
57  /// Add two `RPadPos`s.
58  RPadPos &operator=(const RPadExtent &rhs)
59  {
60  fHoriz = rhs.Horiz();
61  fVert = rhs.Vert();
62  return *this;
63  }
64 
65 
66  /// Add two `RPadPos`s.
67  friend RPadPos operator+(RPadPos lhs, const RPadExtent &rhs)
68  {
69  return {lhs.fHoriz + rhs.Horiz(), lhs.fVert + rhs.Vert()};
70  }
71 
72  /// Subtract two `RPadPos`s.
73  friend RPadPos operator-(RPadPos lhs, const RPadExtent &rhs)
74  {
75  return {lhs.fHoriz - rhs.Horiz(), lhs.fVert - rhs.Vert()};
76  }
77 
78  /// Add a `RPadPos`.
79  RPadPos &operator+=(const RPadExtent &rhs)
80  {
81  fHoriz += rhs.Horiz();
82  fVert += rhs.Vert();
83  return *this;
84  };
85 
86  /// Subtract a `RPadPos`.
87  RPadPos &operator-=(const RPadExtent &rhs)
88  {
89  fHoriz -= rhs.Horiz();
90  fVert -= rhs.Vert();
91  return *this;
92  };
93 
94  /** \class ScaleFactor
95  \ingroup GpadROOT7
96  \brief A scale factor (separate factors for horizontal and vertical) for scaling a `RPadLength`.
97  */
98  struct ScaleFactor {
99  double fHoriz; ///< Horizontal scale factor
100  double fVert; ///< Vertical scale factor
101  };
102 
103  /// Scale a horizontally and vertically.
104  /// \param scale - the scale factor,
105  RPadPos &operator*=(const ScaleFactor &scale)
106  {
107  fHoriz *= scale.fHoriz;
108  fVert *= scale.fVert;
109  return *this;
110  };
111 };
112 
113 }
114 }
115 
116 #endif