Logo ROOT   6.12/07
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 
20 #include "ROOT/TPadExtent.hxx"
21 #include "ROOT/TPadPos.hxx"
23 #include "ROOT/TPalette.hxx"
24 
25 #include <memory>
26 
27 namespace ROOT {
28 namespace Experimental {
29 
30 /** \class ROOT::Experimental::TFrame
31  Holds a user coordinate system with a palette.
32  */
33 
34 class TFrame {
35 public:
36  class DrawingOpts: public TDrawingOptsBase<DrawingOpts> {
37  public:
38  /// Position of the frame in parent TPad coordinates.
39  TPadPos fPos = {0.1_normal, 0.1_normal};
40  /// Size of the frame in parent TPad coordinates.
41  TPadExtent fSize = {0.8_normal, 0.8_normal};
42 
44  };
45 
46 private:
47  /// Mapping of user coordinates to normal coordinates.
48  std::unique_ptr<Detail::TPadUserCoordBase> fUserCoord;
49 
50  /// Palette used to visualize user coordinates.
52 
53  /// Offset with respect to parent TPad.
55 
56  /// Size of the frame, in parent TPad coordinates.
58 
59 public:
60  /// Constructor taking user coordinate system, position and extent.
61  explicit TFrame(std::unique_ptr<Detail::TPadUserCoordBase> &&coords, const TPadPos &pos = DrawingOpts::Default().fPos,
62  const TPadExtent &size = DrawingOpts::Default().fSize);
63 
64  // Constructor taking position and extent.
65  explicit TFrame(const TPadPos &pos = DrawingOpts::Default().fPos, const TPadExtent &size = DrawingOpts::Default().fSize)
66  : TFrame(nullptr, pos, size)
67  {}
68 
69  /// Get the current user coordinate system.
70  Detail::TPadUserCoordBase &GetUserCoord() const;
71 
72  /// Get the current user coordinate system.
73  std::unique_ptr<Detail::TPadUserCoordBase> SwapUserCoordSystem(std::unique_ptr<Detail::TPadUserCoordBase> &&newCoord)
74  {
75  std::unique_ptr<Detail::TPadUserCoordBase> ret(std::move(newCoord));
76  std::swap(ret, fUserCoord);
77  return ret;
78  }
79 
80  /// Convert user coordinates to normal coordinates.
81  std::array<TPadCoord::Normal, 2> UserToNormal(const std::array<TPadCoord::User, 2> &pos) const
82  {
83  return fUserCoord->ToNormal(pos);
84  }
85 };
86 
87 } // namespace Experimental
88 } // namespace ROOT
89 
90 #endif
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
std::unique_ptr< Detail::TPadUserCoordBase > SwapUserCoordSystem(std::unique_ptr< Detail::TPadUserCoordBase > &&newCoord)
Get the current user coordinate system.
Definition: TFrame.hxx:73
void swap(TDirectoryEntry &e1, TDirectoryEntry &e2) noexcept
Base class for drawing options.
TPadExtent fSize
Size of the frame, in parent TPad coordinates.
Definition: TFrame.hxx:57
A position (horizontal and vertical) in a TPad.
Definition: TPadPos.hxx:27
Base class for graphic containers for TDrawable-s.
Definition: TPad.hxx:41
std::array< TPadCoord::Normal, 2 > UserToNormal(const std::array< TPadCoord::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
Definition: TFrame.hxx:81
TPadExtent fSize
Size of the frame in parent TPad coordinates.
Definition: TFrame.hxx:41
TPalette fPalette
Palette used to visualize user coordinates.
Definition: TFrame.hxx:51
TPadPos fPos
Offset with respect to parent TPad.
Definition: TFrame.hxx:54
TFrame(const TPadPos &pos=DrawingOpts::Default().fPos, const TPadExtent &size=DrawingOpts::Default().fSize)
Definition: TFrame.hxx:65
A set of colors.
Definition: TPalette.hxx:38
Holds a user coordinate system with a palette.
Definition: TFrame.hxx:34
An extent / size (horizontal and vertical) in a TPad.
Definition: TPadExtent.hxx:44
static DrawingOpts & Default()
Retrieve the default drawing options for DERIVED.
std::unique_ptr< Detail::TPadUserCoordBase > fUserCoord
Mapping of user coordinates to normal coordinates.
Definition: TFrame.hxx:48
TPadPos fPos
Position of the frame in parent TPad coordinates.
Definition: TFrame.hxx:39