Logo ROOT  
Reference Guide
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.
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`.
80  {
81  fHoriz += rhs.Horiz();
82  fVert += rhs.Vert();
83  return *this;
84  };
85 
86  /// Subtract a `RPadPos`.
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,
106  {
107  fHoriz *= scale.fHoriz;
108  fVert *= scale.fVert;
109  return *this;
110  };
111 };
112 
113 }
114 }
115 
116 #endif
ROOT::Experimental::RPadPos::ScaleFactor
A scale factor (separate factors for horizontal and vertical) for scaling a RPadLength.
Definition: RPadPos.hxx:98
ROOT::Experimental::RPadPos::RPadPos
RPadPos()=default
ROOT::Experimental::RPadPos::operator*=
RPadPos & operator*=(const ScaleFactor &scale)
Scale a horizontally and vertically.
Definition: RPadPos.hxx:105
RPadExtent.hxx
ROOT::Experimental::RPadPos::operator+
friend RPadPos operator+(RPadPos lhs, const RPadExtent &rhs)
Add two RPadPoss.
Definition: RPadPos.hxx:67
ROOT::Experimental::RPadPos::operator=
RPadPos & operator=(const RPadExtent &rhs)
Add two RPadPoss.
Definition: RPadPos.hxx:58
ROOT::Experimental::RPadPos::Horiz
const RPadLength & Horiz() const
Definition: RPadPos.hxx:51
ROOT::Experimental::RPadPos::RPadPos
RPadPos(const RPadExtent &rhs)
Definition: RPadPos.hxx:44
ROOT::Experimental::RPadLength
A length in RPad.
Definition: RPadLength.hxx:31
ROOT::Experimental::RPadPos::fHoriz
RPadLength fHoriz
horizontal part
Definition: RPadPos.hxx:30
ROOT::Experimental::RPadPos::fVert
RPadLength fVert
vertical part
Definition: RPadPos.hxx:32
ROOT::Experimental::RPadPos::Vert
RPadLength & Vert()
Definition: RPadPos.hxx:53
ROOT::Experimental::RPadExtent::Vert
RPadLength & Vert()
Definition: RPadExtent.hxx:46
ROOT::Experimental::RPadExtent::Horiz
RPadLength & Horiz()
Definition: RPadExtent.hxx:43
ROOT::Experimental::RPadPos::RPadPos
RPadPos(const RPadLength &horiz, const RPadLength &vert)
Definition: RPadPos.hxx:38
ROOT::Experimental::RPadPos::operator-=
RPadPos & operator-=(const RPadExtent &rhs)
Subtract a RPadPos.
Definition: RPadPos.hxx:87
ROOT::Experimental::RPadExtent
An extent / size (horizontal and vertical) in a RPad.
Definition: RPadExtent.hxx:27
ROOT::Experimental::RPadPos::operator-
friend RPadPos operator-(RPadPos lhs, const RPadExtent &rhs)
Subtract two RPadPoss.
Definition: RPadPos.hxx:73
ROOT::Experimental::RPadPos::ScaleFactor::fHoriz
double fHoriz
Horizontal scale factor.
Definition: RPadPos.hxx:99
ROOT::Experimental::RPadPos::Vert
const RPadLength & Vert() const
Definition: RPadPos.hxx:54
ROOT::Experimental::RPadPos::operator+=
RPadPos & operator+=(const RPadExtent &rhs)
Add a RPadPos.
Definition: RPadPos.hxx:79
ROOT::Experimental::RPadPos::ScaleFactor::fVert
double fVert
Vertical scale factor.
Definition: RPadPos.hxx:100
ROOT::Experimental::RPadPos::Horiz
RPadLength & Horiz()
Definition: RPadPos.hxx:50
ROOT::Experimental::RPadPos
A position (horizontal and vertical) in a RPad.
Definition: RPadPos.hxx:28
ROOT
VSD Structures.
Definition: StringConv.hxx:21