Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TStructNodeEditor.cxx
Go to the documentation of this file.
1// @(#)root/gviz3d:$Id$
2// Author: Tomasz Sosnicki 18/09/09
3
4/************************************************************************
5* Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6* All rights reserved. *
7* *
8* For the licensing terms see $ROOTSYS/LICENSE. *
9* For the list of contributors see $ROOTSYS/README/CREDITS. *
10*************************************************************************/
11
12
13#include "TStructNodeEditor.h"
14#include "TStructNode.h"
15#include "TStructNodeProperty.h"
16
17#include <TGColorSelect.h>
18#include <TGNumberEntry.h>
19#include <TGLabel.h>
20#include <TGTextEntry.h>
21#include <TClass.h>
22
24
25//________________________________________________________________________
26//////////////////////////////////////////////////////////////////////////
27//
28// TStructNodeEditor is an editor for changing node attributes such as
29// maximum numbers of level or maximum number of objects diplayed if this
30// node is our top node. We can also change color associated with a class
31// or chagne color to default.
32//
33//////////////////////////////////////////////////////////////////////////
34
35////////////////////////////////////////////////////////////////////////////////
36/// Constructor of node attributes GUI.
37
39 : TGedFrame(p, width, height, options | kVerticalFrame, back), fColors(colors)
40{
41 MakeTitle("TStructNode");
42 fInit = kFALSE;
43
44 TGLayoutHints* expandX = new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,5,5);
45 fNodeNameLabel = new TGLabel(this, "No node selected");
46 this->AddFrame(fNodeNameLabel, expandX);
47
48 fTypeName = new TGLabel(this);
49
50 this->AddFrame(fTypeName, expandX);
51
52 TGHorizontalFrame* maxObjectsFrame = new TGHorizontalFrame(this);
53 TGLabel* fMaxObjectslabel = new TGLabel(maxObjectsFrame, "Max objects:");
54 maxObjectsFrame->AddFrame(fMaxObjectslabel);
55
56 fMaxObjectsNumberEntry = new TGNumberEntry(maxObjectsFrame, 0);
60 fMaxObjectsNumberEntry->Connect("ValueSet(Long_t)", "TStructNodeEditor", this, "MaxObjectsValueSetSlot(Long_t)");
61 maxObjectsFrame->AddFrame(fMaxObjectsNumberEntry);
62 this->AddFrame(maxObjectsFrame, expandX);
63
64 TGHorizontalFrame* maxLevelFrame = new TGHorizontalFrame(this);
65 TGLabel* fMaxLevelsLabel = new TGLabel(maxLevelFrame, "Max levels:");
66 maxLevelFrame->AddFrame(fMaxLevelsLabel);
67 fMaxLevelsNumberEntry = new TGNumberEntry(maxLevelFrame, 0);
71 fMaxLevelsNumberEntry->Connect("ValueSet(Long_t)", "TStructNodeEditor", this, "MaxLevelsValueSetSlot(Long_t)");
72 maxLevelFrame->AddFrame(fMaxLevelsNumberEntry);
73 this->AddFrame(maxLevelFrame, expandX);
74
75 fNameEntry = new TGTextEntry(this, fName.Data());
76 this->AddFrame(fNameEntry, expandX);
78
79 fColorSelect = new TGColorSelect(this);
80 fColorSelect->Connect("ColorSelected(Pixel_t)", "TStructNodeEditor", this, "ColorSelectedSlot(Pixel_t)");
81 this->AddFrame(fColorSelect, expandX);
83
84 fAutoRefesh = new TGCheckButton(this, "Auto refesh");
86 fAutoRefesh->Connect("Toggled(Bool_t)", "TStructNodeEditor", this, "AutoRefreshButtonSlot(Bool_t)");
88 this->AddFrame(fAutoRefesh, expandX);
89
90 fDefaultButton = new TGTextButton(this, "Default color");
91 fDefaultButton->Connect("Clicked()", "TStructNodeEditor", this, "DefaultButtonSlot()");
92 this->AddFrame(fDefaultButton, expandX);
94
95
96 fApplyButton = new TGTextButton(this, "Apply");
97 fApplyButton->Connect("Clicked()", "TStructNodeEditor", this, "ApplyButtonSlot()");
99 this->AddFrame(fApplyButton, expandX);
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Destructor of node editor.
104
106{
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// ApplyButton Slot. Activated when user press Apply button. Sets properties of a node
111
113{
114 Bool_t needReset = false;
115
118 needReset = true;
119 }
120
123 needReset = true;
124 }
125
126 if (fSelectedPropert) {
129 }
130
131 Update(needReset);
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Activated when user chage condition
136
138{
139 if (on) {
140 Update(kTRUE);
141 }
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Slot connected to the fill area color.
146
148{
149 if (fAvoidSignal) {
150 return;
151 }
152
154 if (prop) {
155 prop->SetColor(color);
156 } else {
157 // add property
158 prop = new TStructNodeProperty(fNode->GetTypeName(), color);
159 fColors->Add(prop);
160 fColors->Sort();
163 }
164 Update();
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Slot for Defaulf button. Sets color of class to default
169
171{
177 Update();
178 }
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Retruns property associated to the class of given node "node". If property isn't found
183/// then returns NULL
184
186{
187 TIter it(fColors);
189 while ((prop = (TStructNodeProperty*) it() )) {
190 TString propName(prop->GetName());
191 if (propName.EndsWith("+")) {
192
193 if (TClass* cl = TClass::GetClass(node->GetTypeName())) {
194 propName.Remove(propName.Length()-1, 1);
195 if (cl->InheritsFrom(propName.Data())) {
196 return prop;
197 }
198 }
199 } else {
200 if (propName == TString(node->GetTypeName())) {
201 return prop;
202 }
203 }
204 }
205
206 return nullptr;
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Returns property with default color
211
213{
214 return (TStructNodeProperty*)fColors->Last();
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Enables button and fields
219
221{
229 fInit = kTRUE;
230}
231
232////////////////////////////////////////////////////////////////////////////////
233/// Emmited when user changes maximum number of levels
234
236{
238
239 if(fAutoRefesh->IsOn()) {
240 Update(kTRUE);
241 }
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Emmited when user changes maximum number of objects
246
248{
250
251 if(fAutoRefesh->IsOn()) {
252 Update(kTRUE);
253 }
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Pick up the used node attributes.
258
260{
261 fNode = dynamic_cast<TStructNode *>(obj);
262 if (!fNode) return;
263
264 // Add max level
266
267 // Add max objects
269
270 // Type label
271 fTypeName->SetText(fNode->GetTypeName());
272
273 // name label
275
276 // Add color property
278 if (!fSelectedPropert)
279 {
281 }
284
285 if (!fInit) {
286 Init();
287 }
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Signal emmited when color or other property like number of level is changed
292/// without camera reset
293
295{
296 Emit("Update(Bool_t)", false);
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Signal emmited when color or other property like number of level is changed.
301/// If "resetCamera" is true, then current camera is reset.
302
304{
305 Emit("Update(Bool_t)", resetCamera);
306}
@ kVerticalFrame
Definition GuiTypes.h:381
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Color * colors
Definition X3DBuffer.c:21
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:3035
virtual void SetOn(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition TGButton.h:120
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:459
Selects different options.
Definition TGButton.h:264
Bool_t IsOn() const override
Definition TGButton.h:310
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
void SetEnabled(Bool_t e=kTRUE) override
Set enabled or disabled state of button.
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
Pixel_t GetColor() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:180
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
virtual void SetIntNumber(Long_t val, Bool_t emit=kTRUE)
virtual Long_t GetIntNumber() const
virtual void SetFormat(EStyle style, EAttribute attr=TGNumberFormat::kNEAAnyNumber)
@ kNESInteger
Style of number entry field.
@ kNELLimitMin
Lower limit only.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
const char * GetText() const
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
ROOT GUI Window base class.
Definition TGWindow.h:23
TString fName
name of the window used in SavePrimitive()
Definition TGWindow.h:30
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:691
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Definition TList.cxx:935
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
Mother of all ROOT objects.
Definition TObject.h:41
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
const char * Data() const
Definition TString.h:376
TString & Remove(Ssiz_t pos)
Definition TString.h:685
TGColorSelect * fColorSelect
void MaxLevelsValueSetSlot(Long_t)
Emmited when user changes maximum number of levels.
TStructNodeProperty * GetDefaultProperty()
Returns property with default color.
void MaxObjectsValueSetSlot(Long_t)
Emmited when user changes maximum number of objects.
void DefaultButtonSlot()
Slot for Defaulf button. Sets color of class to default.
~TStructNodeEditor() override
Destructor of node editor.
TGNumberEntry * fMaxLevelsNumberEntry
void AutoRefreshButtonSlot(Bool_t on)
Activated when user chage condition.
void ColorSelectedSlot(Pixel_t color)
Slot connected to the fill area color.
void SetModel(TObject *obj) override
Pick up the used node attributes.
TGNumberEntry * fMaxObjectsNumberEntry
TStructNodeProperty * fSelectedPropert
TGCheckButton * fAutoRefesh
TGTextEntry * fNameEntry
TStructNodeEditor(TList *colors, const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of node attributes GUI.
TGTextButton * fApplyButton
TGTextButton * fDefaultButton
void Update() override
Signal emmited when color or other property like number of level is changed without camera reset.
TStructNodeProperty * FindNodeProperty(TStructNode *node)
Retruns property associated to the class of given node "node".
void Init()
Enables button and fields.
void ApplyButtonSlot()
ApplyButton Slot. Activated when user press Apply button. Sets properties of a node.
Pixel_t GetPixel() const
Return color in Pixel_t format.
void SetColor(const TColor &color)
Sets the color to "color".
UInt_t GetMaxLevel() const
Returns maximum number of leves displayed when the node is top node on scene.
const char * GetName() const override
Returns name of object.
TString GetTypeName() const
Returns name of class.
void SetMaxLevel(UInt_t level)
Sets maximum number of leves displayed when the node is top node on scene.
void SetMaxObjects(UInt_t max)
Sets maximum number of objects displayed when the node is top node on scene.
UInt_t GetMaxObjects() const
Returns maximum number of objects displayed when the node is top node on scene.
struct void * fTypeName
Definition cppyy.h:9