Logo ROOT   6.14/05
Reference Guide
TFrame.hxx
Go to the documentation of this file.
1 /// \file ROOT/TFrame.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_TFrame
17 #define ROOT7_TFrame
18 
19 #include "ROOT/TDrawingAttr.hxx"
20 #include "ROOT/TDrawingOptsBase.hxx"
21 #include "ROOT/TPadExtent.hxx"
22 #include "ROOT/TPadPos.hxx"
23 #include "ROOT/TPadUserAxis.hxx"
24 #include "ROOT/TPalette.hxx"
25 
26 #include <memory>
27 
28 namespace ROOT {
29 namespace Experimental {
30 
31 /** \class ROOT::Experimental::TFrame
32  Holds a user coordinate system with a palette.
33  */
34 
35 class TFrame {
36 public:
37  class DrawingOpts: public TDrawingOptsBase {
38  public:
39  /// Position of the frame in parent TPad coordinates.
40  TDrawingAttr<TPadPos> fPos{*this, "frame.pos", 0.1_normal, 0.1_normal};
41  /// Size of the frame in parent TPad coordinates.
42  TDrawingAttr<TPadExtent> fSize{*this, "frame.size", 0.8_normal, 0.8_normal};
43  };
44 
45 private:
46  /// Mapping of user coordinates to normal coordinates, one entry per dimension.
47  std::vector<std::unique_ptr<TPadUserAxisBase>> fUserCoord;
48 
49  /// Palette used to visualize user coordinates.
50  TPalette fPalette;
51 
52  /// Offset with respect to parent TPad.
54 
55  /// Size of the frame, in parent TPad coordinates.
57 
58 public:
59  // Default constructor
61  {
63  }
64 
65  /// Constructor taking user coordinate system, position and extent.
66  explicit TFrame(std::vector<std::unique_ptr<TPadUserAxisBase>> &&coords, const DrawingOpts &opts);
67 
68  // Constructor taking position and extent.
69  explicit TFrame(const DrawingOpts &opts)
70  : TFrame({}, 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  TPadUserAxisBase &GetUserAxis(size_t dimension) const { return *fUserCoord[dimension]; }
81 
82  /// Set the user coordinate system.
83  void SetUserAxis(std::vector<std::unique_ptr<TPadUserAxisBase>> &&axes) { fUserCoord = std::move(axes); }
84 
85  /// Convert user coordinates to normal coordinates.
86  std::array<TPadLength::Normal, 2> UserToNormal(const std::array<TPadLength::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
size_t GetNDimensions() const
Get the number of axes.
Definition: TFrame.hxx:77
std::array< TPadLength::Normal, 2 > UserToNormal(const std::array< TPadLength::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
Definition: TFrame.hxx:86
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
TPadUserAxisBase & GetUserAxis(size_t dimension) const
Get the current user coordinate system for a given dimension.
Definition: TFrame.hxx:80
TPadExtent fSize
Size of the frame, in parent TPad coordinates.
Definition: TFrame.hxx:56
A position (horizontal and vertical) in a TPad.
Definition: TPadPos.hxx:27
TDrawingAttr< TPadExtent > fSize
Size of the frame in parent TPad coordinates.
Definition: TFrame.hxx:42
TPalette fPalette
Palette used to visualize user coordinates.
Definition: TFrame.hxx:50
TPadPos fPos
Offset with respect to parent TPad.
Definition: TFrame.hxx:53
void SetUserAxis(std::vector< std::unique_ptr< TPadUserAxisBase >> &&axes)
Set the user coordinate system.
Definition: TFrame.hxx:83
void GrowToDimensions(size_t nDimensions)
Create nDimensions default axes for the user coordinate system.
Definition: TFrame.cxx:27
TDrawingAttr< TPadPos > fPos
Position of the frame in parent TPad coordinates.
Definition: TFrame.hxx:40
Holds a user coordinate system with a palette.
Definition: TFrame.hxx:35
std::vector< std::unique_ptr< TPadUserAxisBase > > fUserCoord
Mapping of user coordinates to normal coordinates, one entry per dimension.
Definition: TFrame.hxx:47
An extent / size (horizontal and vertical) in a TPad.
Definition: TPadExtent.hxx:44
TFrame(const DrawingOpts &opts)
Definition: TFrame.hxx:69