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/RMenuItems.hxx"
13
14#include "TROOT.h"
15
16#include <cassert>
17#include <sstream>
18
19using namespace ROOT::Experimental;
20
21////////////////////////////////////////////////////////////////////////////
22/// Internal - extract range for specified axis
23
24void RFrame::GetAxisRanges(unsigned ndim, const RAttrAxis &axis, RUserRanges &ranges) const
25{
26 if (axis.zoomMin.Has())
27 ranges.AssignMin(ndim, axis.zoomMin);
28
29 if (axis.zoomMax.Has())
30 ranges.AssignMax(ndim, axis.zoomMax);
31}
32
33////////////////////////////////////////////////////////////////////////////
34/// Internal - assign client zoomed range to specified axis
35
36void RFrame::AssignZoomRange(unsigned ndim, RAttrAxis &axis, const RUserRanges &ranges)
37{
38 if (ranges.IsUnzoom(ndim)) {
39 axis.zoomMin.Clear();
40 axis.zoomMax.Clear();
41 } else {
42 if (ranges.HasMin(ndim))
43 axis.zoomMin = ranges.GetMin(ndim);
44 if (ranges.HasMax(ndim))
45 axis.zoomMax = ranges.GetMax(ndim);
46 }
47}
48
49////////////////////////////////////////////////////////////////////////////
50/// Provide context menu items
51
53{
54 // do not use online context menu for frame - make it fully client side
55/* auto is_x = items.GetSpecifier() == "x";
56 auto is_y = items.GetSpecifier() == "y";
57
58 if (is_x || is_y) {
59 RAttrAxis &attr = is_x ? x : y;
60 std::string name = is_x ? "x" : "y";
61 auto cl = TClass::GetClass<RAttrAxis>();
62 auto log = attr.GetLog();
63 items.AddChkMenuItem("Linear scale", "Set linear scale", !log, name + ".log = 0", cl);
64 items.AddChkMenuItem("Log scale", "Logarithmic scale", !log, name + ".log = 10", cl);
65 }
66*/
67}
68
69////////////////////////////////////////////////////////////////////////////
70/// Remember client range, can be used for drawing or stats box calculations
71
72void RFrame::SetClientRanges(unsigned connid, const RUserRanges &ranges, bool ismainconn)
73{
74 if (ismainconn) {
75 AssignZoomRange(0, x, ranges);
76 AssignZoomRange(1, y, ranges);
77 AssignZoomRange(2, z, ranges);
78 AssignZoomRange(3, x2, ranges);
79 AssignZoomRange(4, y2, ranges);
80 }
81
82 if (fClientRanges.find(connid) == fClientRanges.end()) {
83 RUserRanges ranges0;
84 GetClientRanges(connid, ranges0);
85 fClientRanges[connid] = ranges0;
86 }
87
88 fClientRanges[connid].Update(ranges);
89}
90
91////////////////////////////////////////////////////////////////////////////
92/// Return ranges configured for the client
93
94void RFrame::GetClientRanges(unsigned connid, RUserRanges &ranges)
95{
96 auto iter = fClientRanges.find(connid);
97
98 if (iter != fClientRanges.end()) {
99 ranges = iter->second;
100 } else {
101 GetAxisRanges(0, x, ranges);
102 GetAxisRanges(1, y, ranges);
103 GetAxisRanges(2, z, ranges);
104 }
105}
106
All supported axes attributes for: line, ticks, labels, title, min/max, log, reverse,...
Definition RAttrAxis.hxx:99
RAttrValue< double > zoomMin
! axis zoom min
RAttrValue< double > zoomMax
! axis zoom max
bool IsUnzoom(unsigned ndim) const
Returns true if axis configured as unzoomed, can be specified from client.
Definition RFrame.hxx:121
bool HasMin(unsigned ndim) const
Definition RFrame.hxx:89
void Update(const RUserRanges &src)
Definition RFrame.hxx:136
void AssignMin(unsigned ndim, double value)
Definition RFrame.hxx:93
bool HasMax(unsigned ndim) const
Definition RFrame.hxx:100
double GetMax(unsigned ndim) const
Definition RFrame.hxx:101
double GetMin(unsigned ndim) const
Definition RFrame.hxx:90
void AssignMax(unsigned ndim, double value)
Definition RFrame.hxx:104
std::map< unsigned, RUserRanges > fClientRanges
! individual client ranges
Definition RFrame.hxx:147
RAttrAxis z
! drawing attributes for Z axis
Definition RFrame.hxx:185
RAttrAxis y
! drawing attributes for Y axis
Definition RFrame.hxx:184
void AssignZoomRange(unsigned ndim, RAttrAxis &axis, const RUserRanges &ranges)
Internal - assign client zoomed range to specified axis.
Definition RFrame.cxx:36
void GetAxisRanges(unsigned ndim, const RAttrAxis &axis, RUserRanges &ranges) const
Internal - extract range for specified axis.
Definition RFrame.cxx:24
void GetClientRanges(unsigned connid, RUserRanges &ranges)
Return ranges configured for the client.
Definition RFrame.cxx:94
RAttrAxis x2
! drawing attributes for X2 axis
Definition RFrame.hxx:186
RAttrAxis y2
! drawing attributes for Y2 axis
Definition RFrame.hxx:187
void SetClientRanges(unsigned connid, const RUserRanges &ranges, bool ismainconn)
Remember client range, can be used for drawing or stats box calculations.
Definition RFrame.cxx:72
RAttrAxis x
! drawing attributes for X axis
Definition RFrame.hxx:183
void PopulateMenu(RMenuItems &) override
Provide context menu items.
Definition RFrame.cxx:52
List of items for object context menu.