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
17namespace ROOT {
18namespace 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
28class RPadPos {
29
30 RPadLength fHoriz; ///< horizontal part
31
32 RPadLength fVert; ///< vertical part
33
34public:
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
An extent / size (horizontal and vertical) in a RPad.
Definition: RPadExtent.hxx:27
A position (horizontal and vertical) in a RPad.
Definition: RPadPos.hxx:28
RPadPos(const RPadLength &horiz, const RPadLength &vert)
Definition: RPadPos.hxx:38
RPadLength fVert
vertical part
Definition: RPadPos.hxx:32
friend RPadPos operator+(RPadPos lhs, const RPadExtent &rhs)
Add two RPadPoss.
Definition: RPadPos.hxx:67
RPadPos & operator-=(const RPadExtent &rhs)
Subtract a RPadPos.
Definition: RPadPos.hxx:87
const RPadLength & Horiz() const
Definition: RPadPos.hxx:51
RPadLength & Horiz()
Definition: RPadPos.hxx:50
RPadPos & operator*=(const ScaleFactor &scale)
Scale a horizontally and vertically.
Definition: RPadPos.hxx:105
RPadPos(const RPadExtent &rhs)
Definition: RPadPos.hxx:44
RPadLength fHoriz
horizontal part
Definition: RPadPos.hxx:30
const RPadLength & Vert() const
Definition: RPadPos.hxx:54
friend RPadPos operator-(RPadPos lhs, const RPadExtent &rhs)
Subtract two RPadPoss.
Definition: RPadPos.hxx:73
RPadPos & operator=(const RPadExtent &rhs)
Add two RPadPoss.
Definition: RPadPos.hxx:58
RPadPos & operator+=(const RPadExtent &rhs)
Add a RPadPos.
Definition: RPadPos.hxx:79
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
A scale factor (separate factors for horizontal and vertical) for scaling a RPadLength.
Definition: RPadPos.hxx:98
double fVert
Vertical scale factor.
Definition: RPadPos.hxx:100
double fHoriz
Horizontal scale factor.
Definition: RPadPos.hxx:99