Logo ROOT   6.18/05
Reference Guide
RPadExtent.hxx
Go to the documentation of this file.
1/// \file ROOT/RPadExtent.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_RPadExtent
17#define ROOT7_RPadExtent
18
19#include "ROOT/RPadLength.hxx"
20
21#include <array>
22#include <string>
23
24namespace ROOT {
25namespace Experimental {
26
27namespace Internal {
28/** \class ROOT::Experimental::Internal::RPadHorizVert
29 A 2D (horizontal and vertical) combination of `RPadLength`s.
30 */
31
33 RPadLength fHoriz; ///< Horizontal position
34 RPadLength fVert; ///< Vertical position
35
36 RPadHorizVert() = default;
37 RPadHorizVert(const std::array<RPadLength, 2> &hv): fHoriz(hv[0]), fVert(hv[1]) {}
38 RPadHorizVert(const RPadLength &horiz, const RPadLength &vert): fHoriz(horiz), fVert(vert) {}
39
40 void SetFromAttrString(const std::string &val, const std::string &name);
41};
42}; // namespace Internal
43
44/** \class ROOT::Experimental::RPadExtent
45 An extent / size (horizontal and vertical) in a `RPad`.
46 */
49
50 /// Add two `RPadExtent`s.
51 friend RPadExtent operator+(RPadExtent lhs, const RPadExtent &rhs)
52 {
53 return {lhs.fHoriz + rhs.fHoriz, lhs.fVert + rhs.fVert};
54 }
55
56 /// Subtract two `RPadExtent`s.
57 friend RPadExtent operator-(RPadExtent lhs, const RPadExtent &rhs)
58 {
59 return {lhs.fHoriz - rhs.fHoriz, lhs.fVert - rhs.fVert};
60 }
61
62 /// Add a `RPadExtent`.
64 {
65 fHoriz += rhs.fHoriz;
66 fVert += rhs.fVert;
67 return *this;
68 };
69
70 /// Subtract a `RPadExtent`.
72 {
73 fHoriz -= rhs.fHoriz;
74 fVert -= rhs.fVert;
75 return *this;
76 };
77
78 /** \class ScaleFactor
79 A scale factor (separate factors for horizontal and vertical) for scaling a `RPadLength`.
80 */
81 struct ScaleFactor {
82 double fHoriz; ///< Horizontal scale factor
83 double fVert; ///< Vertical scale factor
84 };
85
86 /// Scale a `RPadHorizVert` horizonally and vertically.
87 /// \param scale - the scale factor,
89 {
90 fHoriz *= scale.fHoriz;
91 fVert *= scale.fVert;
92 return *this;
93 };
94};
95
96/// Initialize a RPadExtent from a style string.
97/// Syntax: X, Y
98/// where X and Y are a series of numbers separated by "+", where each number is followed by one of
99/// `px`, `user`, `normal` to specify an extent in pixel, user or normal coordinates. Spaces between
100/// any part is allowed.
101/// Example: `100 px + 0.1 user, 0.5 normal` is a `RPadExtent{100_px + 0.1_user, 0.5_normal}`.
102
103RPadExtent FromAttributeString(const std::string &val, const std::string &name, RPadExtent*);
104
105std::string ToAttributeString(const RPadExtent &extent);
106
107} // namespace Experimental
108} // namespace ROOT
109
110#endif
char name[80]
Definition: TGX11.cxx:109
A coordinate in a RPad.
Definition: RPadLength.hxx:28
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
void SetFromAttrString(const std::string &val, const std::string &name)
Initialize a RPadHorizVert from a style string.
Definition: RPadExtent.cxx:55
RPadHorizVert(const RPadLength &horiz, const RPadLength &vert)
Definition: RPadExtent.hxx:38
RPadHorizVert(const std::array< RPadLength, 2 > &hv)
Definition: RPadExtent.hxx:37
RPadLength fHoriz
Horizontal position.
Definition: RPadExtent.hxx:33
RPadLength fVert
Vertical position.
Definition: RPadExtent.hxx:34
A scale factor (separate factors for horizontal and vertical) for scaling a RPadLength.
Definition: RPadExtent.hxx:81
double fHoriz
Horizontal scale factor.
Definition: RPadExtent.hxx:82
double fVert
Vertical scale factor.
Definition: RPadExtent.hxx:83
An extent / size (horizontal and vertical) in a RPad.
Definition: RPadExtent.hxx:47
friend RPadExtent operator-(RPadExtent lhs, const RPadExtent &rhs)
Subtract two RPadExtents.
Definition: RPadExtent.hxx:57
RPadExtent & operator*=(const ScaleFactor &scale)
Scale a RPadHorizVert horizonally and vertically.
Definition: RPadExtent.hxx:88
RPadExtent & operator-=(const RPadExtent &rhs)
Subtract a RPadExtent.
Definition: RPadExtent.hxx:71
RPadExtent & operator+=(const RPadExtent &rhs)
Add a RPadExtent.
Definition: RPadExtent.hxx:63
friend RPadExtent operator+(RPadExtent lhs, const RPadExtent &rhs)
Add two RPadExtents.
Definition: RPadExtent.hxx:51