Logo ROOT   6.12/07
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/TPadCoord.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 `TPadCoord`s.
29  */
30 
31 struct TPadHorizVert {
32  TPadCoord fHoriz; ///< Horizontal position
33  TPadCoord fVert; ///< Vertical position
34 
35  TPadHorizVert() = default;
36  TPadHorizVert(const std::array<TPadCoord, 2> &hv): fHoriz(hv[0]), fVert(hv[1]) {}
37  TPadHorizVert(const TPadCoord &horiz, const TPadCoord &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 `TPadCoord`.
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 } // namespace Experimental
94 } // namespace ROOT
95 
96 #endif
double fHoriz
Horizontal scale factor.
Definition: TPadExtent.hxx:79
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
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 TPadCoord.
Definition: TPadExtent.hxx:78
TPadExtent & operator*=(const ScaleFactor &scale)
Scale a TPadHorizVert horizonally and vertically.
Definition: TPadExtent.hxx:85
TPadCoord fVert
Vertical position.
Definition: TPadExtent.hxx:33
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
TPadHorizVert(const std::array< TPadCoord, 2 > &hv)
Definition: TPadExtent.hxx:36
friend TPadExtent operator-(TPadExtent lhs, const TPadExtent &rhs)
Subtract two TPadExtents.
Definition: TPadExtent.hxx:54
TPadHorizVert(const TPadCoord &horiz, const TPadCoord &vert)
Definition: TPadExtent.hxx:37
TPadCoord fHoriz
Horizontal position.
Definition: TPadExtent.hxx:32
A coordinate in a TPad.
Definition: TPadCoord.hxx:26
A 2D (horizontal and vertical) combination of TPadCoords.
Definition: TPadExtent.hxx:31