Logo ROOT   6.16/01
Reference Guide
RPadExtent.cxx
Go to the documentation of this file.
1/// \file RPadExtent.cxx
2/// \ingroup Gpad ROOT7
3/// \author Axel Naumann <axel@cern.ch>
4/// \date 2018-02-08
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-2018, 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#include "ROOT/RPadExtent.hxx"
17
18#include <ROOT/TLogger.hxx>
19
20////////////////////////////////////////////////////////////////////////////////
21/// Initialize a RPadExtent from a style string.
22/// Syntax: X, Y
23/// where X and Y are a series of numbers separated by "+", where each number is
24/// followed by one of `px`, `user`, `normal` to specify an extent in pixel,
25/// user or normal coordinates. Spaces between any part is allowed.
26/// Example: `100 px + 0.1 user, 0.5 normal` is a `RPadExtent{100_px + 0.1_user, 0.5_normal}`.
27
28void ROOT::Experimental::InitializeAttrFromString(const std::string &name, const std::string &attrStrVal,
30{
31 val.SetFromAttrString(name, attrStrVal);
32}
33
34////////////////////////////////////////////////////////////////////////////////
35/// Initialize a RPadHorizVert from a style string.
36/// Syntax: X, Y
37/// where X and Y are a series of numbers separated by "+", where each number is
38/// followed by one of `px`, `user`, `normal` to specify an extent in pixel,
39/// user or normal coordinates. Spaces between any part is allowed.
40/// Example: `100 px + 0.1 user, 0.5 normal` is a `RPadExtent{100_px + 0.1_user, 0.5_normal}`.
41
43 const std::string &attrStrVal)
44{
45 if (attrStrVal.empty()) {
46 // Leave it at its default value.
47 return;
48 }
49 auto posComma = attrStrVal.find(',');
50 if (posComma == std::string::npos) {
51 R__ERROR_HERE("Gpad") << "Parsing attribute for " << name << ": "
52 << "expected two coordinate dimensions but found only one in " << attrStrVal;
53 return;
54 }
55 if (attrStrVal.find(',', posComma + 1) != std::string::npos) {
56 R__ERROR_HERE("Gpad") << "Parsing attribute for " << name << ": "
57 << "found more than the expected two coordinate dimensions in " << attrStrVal;
58 return;
59 }
60 fHoriz.SetFromAttrString(name, attrStrVal.substr(0, posComma));
61 fVert.SetFromAttrString(name, attrStrVal.substr(posComma + 1));
62}
#define R__ERROR_HERE(GROUP)
Definition: TLogger.hxx:182
void SetFromAttrString(const std::string &name, const std::string &attrStrVal)
Initialize a RPadLength from a style string.
Definition: RPadLength.cxx:163
void InitializeAttrFromString(const std::string &name, const std::string &attrStrVal, RPadExtent &val)
Initialize a RPadExtent from a style string.
Definition: RPadExtent.cxx:28
void SetFromAttrString(const std::string &name, const std::string &attrStrVal)
Initialize a RPadHorizVert from a style string.
Definition: RPadExtent.cxx:42
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