Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RFrame.hxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
3  * All rights reserved. *
4  * *
5  * For the licensing terms see $ROOTSYS/LICENSE. *
6  * For the list of contributors see $ROOTSYS/README/CREDITS. *
7  *************************************************************************/
8 
9 #ifndef ROOT7_RFrame
10 #define ROOT7_RFrame
11 
12 #include "ROOT/RDrawable.hxx"
13 
14 #include "ROOT/RAttrBox.hxx"
15 #include "ROOT/RPadUserAxis.hxx"
16 #include "ROOT/RPalette.hxx"
17 
18 #include <memory>
19 
20 namespace ROOT {
21 namespace Experimental {
22 
23 /** \class RFrame
24 \ingroup GpadROOT7
25 \brief Holds a user coordinate system with a palette.
26 \author Axel Naumann <axel@cern.ch>
27 \date 2017-09-26
28 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
29 */
30 
31 class RFrame : public RDrawable {
32 public:
33 
34 private:
35  /// Mapping of user coordinates to normal coordinates, one entry per dimension.
36  std::vector<std::unique_ptr<RPadUserAxisBase>> fUserCoord;
37 
38  /// Palette used to visualize user coordinates.
39  RPalette fPalette;
40 
41 public:
42  // Default constructor
43  RFrame() : RDrawable("frame")
44  {
45  GrowToDimensions(2);
46  }
47 
48  /// Constructor taking user coordinate system, position and extent.
49  explicit RFrame(std::vector<std::unique_ptr<RPadUserAxisBase>> &&coords);
50 
51  /// Create `nDimensions` default axes for the user coordinate system.
52  void GrowToDimensions(size_t nDimensions);
53 
54  /// Get the number of axes.
55  size_t GetNDimensions() const { return fUserCoord.size(); }
56 
57  /// Get the current user coordinate system for a given dimension.
58  RPadUserAxisBase &GetUserAxis(size_t dimension) const { return *fUserCoord[dimension]; }
59 
60  /// Set the user coordinate system.
61  void SetUserAxis(std::vector<std::unique_ptr<RPadUserAxisBase>> &&axes) { fUserCoord = std::move(axes); }
62 
63  /// Convert user coordinates to normal coordinates.
64  std::array<RPadLength::Normal, 2> UserToNormal(const std::array<RPadLength::User, 2> &pos) const
65  {
66  return {{fUserCoord[0]->ToNormal(pos[0]), fUserCoord[1]->ToNormal(pos[1])}};
67  }
68 };
69 
70 } // namespace Experimental
71 } // namespace ROOT
72 
73 #endif