Logo ROOT   6.16/01
Reference Guide
RFrame.hxx
Go to the documentation of this file.
1/// \file ROOT/RFrame.hxx
2/// \ingroup Gpad ROOT7
3/// \author Axel Naumann <axel@cern.ch>
4/// \date 2017-09-26
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_RFrame
17#define ROOT7_RFrame
18
19#include "ROOT/RDrawingAttr.hxx"
20#include "ROOT/RDrawingOptsBase.hxx"
21#include "ROOT/RPadExtent.hxx"
22#include "ROOT/RPadPos.hxx"
23#include "ROOT/RPadUserAxis.hxx"
24#include "ROOT/RPalette.hxx"
25
26#include <memory>
27
28namespace ROOT {
29namespace Experimental {
30
31/** \class ROOT::Experimental::RFrame
32 Holds a user coordinate system with a palette.
33 */
34
35class RFrame {
36public:
37 class DrawingOpts: public RDrawingOptsBase {
38 public:
39 /// Position of the frame in parent RPad coordinates.
40 RDrawingAttr<RPadPos> fPos{*this, "frame.pos", 0.1_normal, 0.1_normal};
41 /// Size of the frame in parent RPad coordinates.
42 RDrawingAttr<RPadExtent> fSize{*this, "frame.size", 0.8_normal, 0.8_normal};
43 };
44
45private:
46 /// Mapping of user coordinates to normal coordinates, one entry per dimension.
47 std::vector<std::unique_ptr<RPadUserAxisBase>> fUserCoord;
48
49 /// Palette used to visualize user coordinates.
50 RPalette fPalette;
51
52 /// Offset with respect to parent RPad.
54
55 /// Size of the frame, in parent RPad coordinates.
57
58public:
59 // Default constructor
61 {
63 }
64
65 /// Constructor taking user coordinate system, position and extent.
66 explicit RFrame(std::vector<std::unique_ptr<RPadUserAxisBase>> &&coords, const DrawingOpts &opts);
67
68 // Constructor taking position and extent.
69 explicit RFrame(const DrawingOpts &opts)
70 : RFrame({}, opts)
71 {}
72
73 /// Create `nDimensions` default axes for the user coordinate system.
74 void GrowToDimensions(size_t nDimensions);
75
76 /// Get the number of axes.
77 size_t GetNDimensions() const { return fUserCoord.size(); }
78
79 /// Get the current user coordinate system for a given dimension.
80 RPadUserAxisBase &GetUserAxis(size_t dimension) const { return *fUserCoord[dimension]; }
81
82 /// Set the user coordinate system.
83 void SetUserAxis(std::vector<std::unique_ptr<RPadUserAxisBase>> &&axes) { fUserCoord = std::move(axes); }
84
85 /// Convert user coordinates to normal coordinates.
86 std::array<RPadLength::Normal, 2> UserToNormal(const std::array<RPadLength::User, 2> &pos) const
87 {
88 return {{fUserCoord[0]->ToNormal(pos[0]), fUserCoord[1]->ToNormal(pos[1])}};
89 }
90};
91
92} // namespace Experimental
93} // namespace ROOT
94
95#endif
RDrawingAttr< RPadExtent > fSize
Size of the frame in parent RPad coordinates.
Definition: RFrame.hxx:42
RDrawingAttr< RPadPos > fPos
Position of the frame in parent RPad coordinates.
Definition: RFrame.hxx:40
Holds a user coordinate system with a palette.
Definition: RFrame.hxx:35
std::array< RPadLength::Normal, 2 > UserToNormal(const std::array< RPadLength::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
Definition: RFrame.hxx:86
void GrowToDimensions(size_t nDimensions)
Create nDimensions default axes for the user coordinate system.
Definition: RFrame.cxx:27
RPadPos fPos
Offset with respect to parent RPad.
Definition: RFrame.hxx:53
RPalette fPalette
Palette used to visualize user coordinates.
Definition: RFrame.hxx:50
size_t GetNDimensions() const
Get the number of axes.
Definition: RFrame.hxx:77
void SetUserAxis(std::vector< std::unique_ptr< RPadUserAxisBase > > &&axes)
Set the user coordinate system.
Definition: RFrame.hxx:83
RPadExtent fSize
Size of the frame, in parent RPad coordinates.
Definition: RFrame.hxx:56
std::vector< std::unique_ptr< RPadUserAxisBase > > fUserCoord
Mapping of user coordinates to normal coordinates, one entry per dimension.
Definition: RFrame.hxx:47
RPadUserAxisBase & GetUserAxis(size_t dimension) const
Get the current user coordinate system for a given dimension.
Definition: RFrame.hxx:80
RFrame(const DrawingOpts &opts)
Definition: RFrame.hxx:69
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
An extent / size (horizontal and vertical) in a RPad.
Definition: RPadExtent.hxx:47
A position (horizontal and vertical) in a RPad.
Definition: RPadPos.hxx:27