Logo ROOT  
Reference Guide
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.HasMin())
36 ranges.AssignMin(ndim, axis.GetMin());
37
38 if (axis.HasMax())
39 ranges.AssignMax(ndim, axis.GetMax());
40
41 if (axis.HasZoomMin())
42 ranges.AssignMin(ndim, axis.GetZoomMin(), true);
43
44 if (axis.HasZoomMax())
45 ranges.AssignMax(ndim, axis.GetZoomMax(), true);
46}
47
48////////////////////////////////////////////////////////////////////////////
49/// Internal - assign client zoomed range to specified axis
50
51void RFrame::AssignZoomRange(unsigned ndim, RAttrAxis &axis, const RUserRanges &ranges)
52{
53 if (ranges.IsUnzoom(ndim)) {
54 axis.ClearZoomMinMax();
55 } else {
56 if (ranges.HasMin(ndim))
57 axis.SetZoomMin(ranges.GetMin(ndim));
58 if (ranges.HasMax(ndim))
59 axis.SetZoomMax(ranges.GetMax(ndim));
60 }
61}
62
63////////////////////////////////////////////////////////////////////////////
64/// Deprecated, to be removed soon
65
66void RFrame::GrowToDimensions(size_t nDimensions)
67{
68 std::size_t oldSize = fUserCoord.size();
69 if (oldSize >= nDimensions)
70 return;
71 fUserCoord.resize(nDimensions);
72 for (std::size_t idx = oldSize; idx < nDimensions; ++idx)
73 if (!fUserCoord[idx])
74 fUserCoord[idx].reset(new RPadCartesianUserAxis);
75}
76
77////////////////////////////////////////////////////////////////////////////
78/// Provide context menu items
79
81{
82 auto is_x = items.GetSpecifier() == "x";
83 auto is_y = items.GetSpecifier() == "y";
84
85 if (is_x || is_y) {
86 RAttrAxis &attr = is_x ? AttrX() : AttrY();
87 std::string name = is_x ? "AttrX()" : "AttrY()";
88 items.AddChkMenuItem("Log scale", "Change log scale", attr.GetLog(), name + ".SetLog" + (attr.GetLog() ? "(false)" : "(true)"));
89 }
90}
91
92////////////////////////////////////////////////////////////////////////////
93/// Remember client range, can be used for drawing or stats box calculations
94
95void RFrame::SetClientRanges(unsigned connid, const RUserRanges &ranges, bool ismainconn)
96{
97 fClientRanges[connid] = ranges;
98
99 if (ismainconn) {
100 AssignZoomRange(0, AttrX(), ranges);
101 AssignZoomRange(1, AttrY(), ranges);
102 AssignZoomRange(2, AttrZ(), ranges);
103 }
104}
105
106////////////////////////////////////////////////////////////////////////////
107/// Return ranges configured for the client
108
109void RFrame::GetClientRanges(unsigned connid, RUserRanges &ranges)
110{
111 auto iter = fClientRanges.find(connid);
112
113 if (iter != fClientRanges.end()) {
114 ranges = iter->second;
115 } else {
116 GetAxisRanges(0, GetAttrX(), ranges);
117 GetAxisRanges(1, GetAttrY(), ranges);
118 GetAxisRanges(2, GetAttrZ(), ranges);
119 }
120}
121
char name[80]
Definition: TGX11.cxx:109
All kind of drawing a axis: line, text, ticks, min/max, log, invert, ...
Definition: RAttrAxis.hxx:27
RAttrAxis & SetZoomMax(double max)
Definition: RAttrAxis.hxx:57
RAttrAxis & SetZoomMin(double min)
Definition: RAttrAxis.hxx:56
bool IsUnzoom(unsigned ndim) const
Returns true if axis configured as unzoomed, can be specified from client.
Definition: RFrame.hxx:105
bool HasMin(unsigned ndim) const
Definition: RFrame.hxx:78
void AssignMin(unsigned ndim, double value, bool force=false)
Definition: RFrame.hxx:82
bool HasMax(unsigned ndim) const
Definition: RFrame.hxx:91
double GetMax(unsigned ndim) const
Definition: RFrame.hxx:92
void AssignMax(unsigned ndim, double value, bool force=false)
Definition: RFrame.hxx:95
double GetMin(unsigned ndim) const
Definition: RFrame.hxx:79
Holds an area where drawing on user coordinate-system can be performed.
Definition: RFrame.hxx:40
std::map< unsigned, RUserRanges > fClientRanges
! individual client ranges
Definition: RFrame.hxx:135
const RAttrAxis & GetAttrY() const
Definition: RFrame.hxx:194
const RAttrAxis & GetAttrZ() const
Definition: RFrame.hxx:198
void AssignZoomRange(unsigned ndim, RAttrAxis &axis, const RUserRanges &ranges)
Internal - assign client zoomed range to specified axis.
Definition: RFrame.cxx:51
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:190
void GetClientRanges(unsigned connid, RUserRanges &ranges)
Return ranges configured for the client.
Definition: RFrame.cxx:109
std::vector< std::unique_ptr< RPadUserAxisBase > > fUserCoord
Mapping of user coordinates to normal coordinates, one entry per dimension.
Definition: RFrame.hxx:138
void SetClientRanges(unsigned connid, const RUserRanges &ranges, bool ismainconn)
Remember client range, can be used for drawing or stats box calculations.
Definition: RFrame.cxx:95
void PopulateMenu(RMenuItems &) override
Provide context menu items.
Definition: RFrame.cxx:80
void GrowToDimensions(size_t nDimensions)
Create nDimensions default axes for the user coordinate system.
Definition: RFrame.cxx:66
List of items for object context menu.
Definition: RMenuItems.hxx:153
void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle)
Definition: RMenuItems.hxx:183
const std::string & GetSpecifier() const
Definition: RMenuItems.hxx:170