Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RFrame.cxx
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#include "ROOT/RFrame.hxx"
10
11#include "ROOT/RLogger.hxx"
12#include "ROOT/RPadUserAxis.hxx"
13#include "ROOT/RMenuItems.hxx"
14
15#include "TROOT.h"
16
17#include <cassert>
18#include <sstream>
19
20using namespace ROOT::Experimental;
21
22////////////////////////////////////////////////////////////////////////////
23/// Deprecated constructor, to be removed soon
24
25RFrame::RFrame(std::vector<std::unique_ptr<RPadUserAxisBase>> &&coords) : RFrame()
26{
27 fUserCoord = std::move(coords);
28}
29
30////////////////////////////////////////////////////////////////////////////
31/// Internal - extract range for specified axis
32
33void RFrame::GetAxisRanges(unsigned ndim, const RAttrAxis &axis, RUserRanges &ranges) const
34{
35 if (axis.HasZoomMin())
36 ranges.AssignMin(ndim, axis.GetZoomMin());
37
38 if (axis.HasZoomMax())
39 ranges.AssignMax(ndim, axis.GetZoomMax());
40}
41
42////////////////////////////////////////////////////////////////////////////
43/// Internal - assign client zoomed range to specified axis
44
45void RFrame::AssignZoomRange(unsigned ndim, RAttrAxis &axis, const RUserRanges &ranges)
46{
47 if (ranges.IsUnzoom(ndim)) {
48 axis.ClearZoom();
49 } else {
50 if (ranges.HasMin(ndim))
51 axis.SetZoomMin(ranges.GetMin(ndim));
52 if (ranges.HasMax(ndim))
53 axis.SetZoomMax(ranges.GetMax(ndim));
54 }
55}
56
57////////////////////////////////////////////////////////////////////////////
58/// Deprecated, to be removed soon
59
60void RFrame::GrowToDimensions(size_t nDimensions)
61{
62 std::size_t oldSize = fUserCoord.size();
63 if (oldSize >= nDimensions)
64 return;
65 fUserCoord.resize(nDimensions);
66 for (std::size_t idx = oldSize; idx < nDimensions; ++idx)
67 if (!fUserCoord[idx])
68 fUserCoord[idx].reset(new RPadCartesianUserAxis);
69}
70
71////////////////////////////////////////////////////////////////////////////
72/// Provide context menu items
73
75{
76 // do not use online context menu for frame - make it fully client side
77/* auto is_x = items.GetSpecifier() == "x";
78 auto is_y = items.GetSpecifier() == "y";
79
80 if (is_x || is_y) {
81 RAttrAxis &attr = is_x ? AttrX() : AttrY();
82 std::string name = is_x ? "AttrX()" : "AttrY()";
83 auto cl = TClass::GetClass<RAttrAxis>();
84 auto log = attr.GetLog();
85 items.AddChkMenuItem("Linear scale", "Set linear scale", !log, name + ".SetLog(0)", cl);
86 items.AddChkMenuItem("Log scale", "Logarithmic scale", !log, name + ".SetLog(10)", cl);
87 }
88*/
89}
90
91////////////////////////////////////////////////////////////////////////////
92/// Remember client range, can be used for drawing or stats box calculations
93
94void RFrame::SetClientRanges(unsigned connid, const RUserRanges &ranges, bool ismainconn)
95{
96 if (ismainconn) {
97 AssignZoomRange(0, AttrX(), ranges);
98 AssignZoomRange(1, AttrY(), ranges);
99 AssignZoomRange(2, AttrZ(), ranges);
100 }
101
102 if (fClientRanges.find(connid) == fClientRanges.end()) {
103 RUserRanges ranges0;
104 GetClientRanges(connid, ranges0);
105 fClientRanges[connid] = ranges0;
106 }
107
108 fClientRanges[connid].Update(ranges);
109}
110
111////////////////////////////////////////////////////////////////////////////
112/// Return ranges configured for the client
113
114void RFrame::GetClientRanges(unsigned connid, RUserRanges &ranges)
115{
116 auto iter = fClientRanges.find(connid);
117
118 if (iter != fClientRanges.end()) {
119 ranges = iter->second;
120 } else {
121 GetAxisRanges(0, GetAttrX(), ranges);
122 GetAxisRanges(1, GetAttrY(), ranges);
123 GetAxisRanges(2, GetAttrZ(), ranges);
124 }
125}
126
All supported axes attributes for: line, ticks, labels, title, min/max, log, reverse,...
Definition RAttrAxis.hxx:29
RAttrAxis & SetZoomMax(double max)
Definition RAttrAxis.hxx:55
RAttrAxis & SetZoomMin(double min)
Definition RAttrAxis.hxx:54
bool IsUnzoom(unsigned ndim) const
Returns true if axis configured as unzoomed, can be specified from client.
Definition RFrame.hxx:122
bool HasMin(unsigned ndim) const
Definition RFrame.hxx:90
void Update(const RUserRanges &src)
Definition RFrame.hxx:137
void AssignMin(unsigned ndim, double value)
Definition RFrame.hxx:94
bool HasMax(unsigned ndim) const
Definition RFrame.hxx:101
double GetMax(unsigned ndim) const
Definition RFrame.hxx:102
double GetMin(unsigned ndim) const
Definition RFrame.hxx:91
void AssignMax(unsigned ndim, double value)
Definition RFrame.hxx:105
Holds an area where drawing on user coordinate-system can be performed.
Definition RFrame.hxx:39
std::map< unsigned, RUserRanges > fClientRanges
! individual client ranges
Definition RFrame.hxx:159
const RAttrAxis & GetAttrY() const
Definition RFrame.hxx:218
const RAttrAxis & GetAttrZ() const
Definition RFrame.hxx:222
void AssignZoomRange(unsigned ndim, RAttrAxis &axis, const RUserRanges &ranges)
Internal - assign client zoomed range to specified axis.
Definition RFrame.cxx:45
void GetAxisRanges(unsigned ndim, const RAttrAxis &axis, RUserRanges &ranges) const
Internal - extract range for specified axis.
Definition RFrame.cxx:33
const RAttrAxis & GetAttrX() const
Definition RFrame.hxx:214
void GetClientRanges(unsigned connid, RUserRanges &ranges)
Return ranges configured for the client.
Definition RFrame.cxx:114
std::vector< std::unique_ptr< RPadUserAxisBase > > fUserCoord
Mapping of user coordinates to normal coordinates, one entry per dimension.
Definition RFrame.hxx:162
void SetClientRanges(unsigned connid, const RUserRanges &ranges, bool ismainconn)
Remember client range, can be used for drawing or stats box calculations.
Definition RFrame.cxx:94
void PopulateMenu(RMenuItems &) override
Provide context menu items.
Definition RFrame.cxx:74
void GrowToDimensions(size_t nDimensions)
Create nDimensions default axes for the user coordinate system.
Definition RFrame.cxx:60
List of items for object context menu.