Logo ROOT   6.18/05
Reference Guide
RPadPos.hxx
Go to the documentation of this file.
1/// \file ROOT/RPadPos.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_RPadPos
17#define ROOT7_RPadPos
18
19#include "ROOT/RPadExtent.hxx"
20
21namespace ROOT {
22namespace Experimental {
23
24/** \class ROOT::Experimental::RPadPos
25 A position (horizontal and vertical) in a `RPad`.
26 */
29 RPadPos() = default;
30 RPadPos(const RPadExtent& extent): Internal::RPadHorizVert(extent) {}
31
32 /// Add a `RPadExtent`.
33 friend RPadPos operator+(const RPadPos &lhs, const RPadExtent &rhs)
34 {
35 return RPadPos{lhs.fHoriz + rhs.fHoriz, lhs.fVert + rhs.fVert};
36 }
37
38 /// Add to a `RPadExtent`.
39 friend RPadPos operator+(const RPadExtent &lhs, const RPadPos &rhs)
40 {
41 return RPadPos{lhs.fHoriz + rhs.fHoriz, lhs.fVert + rhs.fVert};
42 }
43
44 /// Subtract a `RPadExtent`.
45 friend RPadPos operator-(const RPadPos &lhs, const RPadExtent &rhs)
46 {
47 return RPadPos{lhs.fHoriz - rhs.fHoriz, lhs.fVert - rhs.fVert};
48 }
49
50 /// Subtract from a `RPadPos`s. Is this really needed?
51 /*
52 friend RPadPos operator-(const RPadExtent &rhs, const RPadPos &lhs)
53 {
54 return RPadPos{lhs.fHoriz - rhs.fHoriz, lhs.fVert - rhs.fVert};
55 }
56 */
57
58 /// Add a `RPadExtent`.
60 {
61 fHoriz += rhs.fHoriz;
62 fVert += rhs.fVert;
63 return *this;
64 };
65
66 /// Subtract a `RPadExtent`.
68 {
69 fHoriz -= rhs.fHoriz;
70 fVert -= rhs.fVert;
71 return *this;
72 };
73
74 /** \class ScaleFactor
75 A scale factor (separate factors for horizontal and vertical) for scaling a `RPadLength`.
76 */
77 struct ScaleFactor {
78 double fHoriz; ///< Horizontal scale factor
79 double fVert; ///< Vertical scale factor
80 };
81
82 /// Scale a `RPadHorizVert` horizontally and vertically.
83 /// \param scale - the scale factor,
85 {
86 fHoriz *= scale.fHoriz;
87 fVert *= scale.fVert;
88 return *this;
89 };
90};
91
92/// Initialize a RPadPos from a style string.
93RPadPos FromAttributeString(const std::string &val, const std::string &name, RPadPos*);
94/// Convert a RPadPos to a std::string, suitable for PosFromString().
95std::string ToAttributeString(const RPadPos &pos);
96
97} // namespace Experimental
98} // namespace ROOT
99
100#endif
char name[80]
Definition: TGX11.cxx:109
std::string ToAttributeString(const RColor &val)
Return a std::string representation of a RColor, suitable as input to ColorFromString().
Definition: RColor.cxx:144
RColor FromAttributeString(const std::string &str, const std::string &name, RColor *)
Initialize a RColor from a string value.
Definition: RColor.cxx:132
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
A 2D (horizontal and vertical) combination of RPadLengths.
Definition: RPadExtent.hxx:32
RPadLength fHoriz
Horizontal position.
Definition: RPadExtent.hxx:33
RPadLength fVert
Vertical position.
Definition: RPadExtent.hxx:34
An extent / size (horizontal and vertical) in a RPad.
Definition: RPadExtent.hxx:47
A scale factor (separate factors for horizontal and vertical) for scaling a RPadLength.
Definition: RPadPos.hxx:77
double fVert
Vertical scale factor.
Definition: RPadPos.hxx:79
double fHoriz
Horizontal scale factor.
Definition: RPadPos.hxx:78
A position (horizontal and vertical) in a RPad.
Definition: RPadPos.hxx:27
friend RPadPos operator-(const RPadPos &lhs, const RPadExtent &rhs)
Subtract a RPadExtent.
Definition: RPadPos.hxx:45
friend RPadPos operator+(const RPadExtent &lhs, const RPadPos &rhs)
Add to a RPadExtent.
Definition: RPadPos.hxx:39
RPadPos & operator-=(const RPadExtent &rhs)
Subtract a RPadExtent.
Definition: RPadPos.hxx:67
RPadPos(const RPadExtent &extent)
Definition: RPadPos.hxx:30
RPadPos & operator*=(const ScaleFactor &scale)
Scale a RPadHorizVert horizontally and vertically.
Definition: RPadPos.hxx:84
friend RPadPos operator+(const RPadPos &lhs, const RPadExtent &rhs)
Add a RPadExtent.
Definition: RPadPos.hxx:33
RPadPos & operator+=(const RPadExtent &rhs)
Subtract from a RPadPoss. Is this really needed?
Definition: RPadPos.hxx:59