Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TSpiderEditor.cxx
Go to the documentation of this file.
1// @(#)root/treeviewer:$Id$
2// Author: Bastien Dalla Piazza 20/07/07
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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#include "TSpiderEditor.h"
13#include "TSpider.h"
14#include "TGButton.h"
15#include "TGNumberEntry.h"
16#include "TGButtonGroup.h"
17#include "TGLabel.h"
18#include "TGPicture.h"
19#include "TGTextEntry.h"
20#include "TG3DLine.h"
21#include "TGComboBox.h"
22#include "TGColorSelect.h"
23#include "TGedPatternSelect.h"
24#include "TColor.h"
25
26
27/** \class TSpiderEditor
28The TSpider editor class.
29Provides the graphical user interface to the spider plots.
30*/
31
51
52////////////////////////////////////////////////////////////////////////////////
53/// Normal constructor.
54
55TSpiderEditor::TSpiderEditor(const TGWindow* /*p*/, Int_t /*width*/, Int_t /*height*/, UInt_t /*options*/, Pixel_t /*back*/)
56{
57 fPriority = 1;
58 MakeTitle("Spider");
59
60 fBgroup = new TGButtonGroup(this,2,1,0,0, "Plot type");
61 fBgroup->SetRadioButtonExclusive(true);
62 fPolyLines = new TGRadioButton(fBgroup, "PolyLine", kPolyLines);
63 fPolyLines->SetToolTipText("Set a polyline plot type");
64 fSegment = new TGRadioButton(fBgroup, "Segment", kSegment);
65 fSegment->SetToolTipText("Set a segment plot type");
66 fBgroup->ChangeOptions(kFitWidth|kChildFrame);
68
70
71 TGLabel *nxLabel = new TGLabel(f1,"Nx:");
72 f1->AddFrame(nxLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 1, 1));
77 fSetNx->SetToolTipText("Set the X number of plots");
78 fSetNx->Resize(30,20);
79 f1->AddFrame(fSetNx, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
80
81 TGLabel *nyLabel = new TGLabel(f1,"Ny:");
82 f1->AddFrame(nyLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 1, 1));
87 fSetNy->SetToolTipText("Set the Y number of plots");
88 fSetNy->Resize(30,20);
89 f1->AddFrame(fSetNy, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
90 AddFrame(f1, new TGLayoutHints(kLHintsLeft,1,1,1,1));
91
92 MakeTitle("Average");
93
94 fDisplayAverage = new TGCheckButton(this, "Average",kAverage);
95 fDisplayAverage->SetToolTipText("Display average");
97
99
102
104 fAvLineWidthCombo->Resize(91, 20);
106
107 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
108
110 fAvLineStyleCombo->Resize(137, 20);
112
113 TGHorizontalFrame *f2b = new TGHorizontalFrame(this);
114
117
120
121 AddFrame(f2b, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
122
123 MakeBrowse();
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Destructor of the TSpiderEditor.
128
130{
131 delete fPolyLines;
132 delete fSegment;
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Connect signals to slots.
137
139{
140 fDisplayAverage->Connect("Toggled(bool)", "TSpiderEditor", this, "DoDisplayAverage(bool)");
141 fSetNx->Connect("ReturnPressed()", "TSpiderEditor", this, "DoSetNx()");
142 fSetNy->Connect("ReturnPressed()", "TSpiderEditor", this, "DoSetNy()");
143 fBgroup->Connect("Clicked(Int_t)","TSpiderEditor",this,"DoSetPlotType()");
144 fGotoEntry->Connect("ReturnPressed()", "TSpiderEditor", this, "DoGotoEntry()");
145 fGotoNext->Connect("Clicked()","TSpiderEditor",this,"DoGotoNext()");
146 fGotoPrevious->Connect("Clicked()","TSpiderEditor",this,"DoGotoPrevious()");
147 fGotoFollowing->Connect("Clicked()","TSpiderEditor",this,"DoGotoFollowing()");
148 fGotoPreceding->Connect("Clicked()","TSpiderEditor",this,"DoGotoPreceding()");
149 fAddVar->Connect("ReturnPressed()","TSpiderEditor",this,"DoAddVar()");
150 fDeleteVar->Connect("ReturnPressed()","TSpiderEditor",this,"DoDeleteVar()");
151 fAvLineStyleCombo->Connect("Selected(Int_t)", "TSpiderEditor", this, "DoAvLineStyle(Int_t)");
152 fAvLineWidthCombo->Connect("Selected(Int_t)", "TSpiderEditor", this, "DoAvLineWidth(Int_t)");
153 fAvLineColorSelect->Connect("ColorSelected(Pixel_t)", "TSpiderEditor", this, "DoAvLineColor(Pixel_t)");
154 fAvFillColorSelect->Connect("ColorSelected(Pixel_t)", "TSpiderEditor", this, "DoAvFillColor(Pixel_t)");
155 fAvFillPatternSelect->Connect("PatternSelected(Style_t)", "TSpiderEditor", this, "DoAvFillPattern(Style_t)");
156
157 fInit = false;
158}
159
160////////////////////////////////////////////////////////////////////////////////
161/// Make the Browse tab.
162
164{
166
168 title1->AddFrame(new TGLabel(title1, "Entries"),
169 new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
170 title1->AddFrame(new TGHorizontal3DLine(title1),
171 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
172 fBrowse->AddFrame(title1, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
173
175
176 TGLabel *gotoEntryLabel = new TGLabel(f3,"Go to:");
177 f3->AddFrame(gotoEntryLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 18, 1, 5));
181 fGotoEntry->SetToolTipText("Jump to a specified entry");
182 fGotoEntry->Resize(60,20);
183 f3->AddFrame(fGotoEntry, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
184
185 fBrowse->AddFrame(f3,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
186
188
189 fPicPrevious = gClient->GetPicture("first_t.xpm");
191 fGotoPrevious->SetToolTipText("Jump to the last entries");
193
194 fPicPreceding = gClient->GetPicture("previous_t.xpm");
196 fGotoPreceding->SetToolTipText("Jump to the last entries");
198
199 fPicFollowing = gClient->GetPicture("next_t.xpm");
201 fGotoFollowing->SetToolTipText("Jump to the last entries");
203
204 fPicNext = gClient->GetPicture("last_t.xpm");
206 fGotoNext->SetToolTipText("Jump to the next entries");
208
210
212
213 title2->AddFrame(new TGLabel(title2, "Variables"),
214 new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
215 title2->AddFrame(new TGHorizontal3DLine(title2),
216 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
217 fBrowse->AddFrame(title2, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
218
220
222
223 TGLabel *addVar = new TGLabel(v1,"Add:");
224 v1->AddFrame(addVar,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
225
226 TGLabel *deleteVar = new TGLabel(v1,"Delete:");
227 v1->AddFrame(deleteVar,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
228
229 f4->AddFrame(v1, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,0,0));
230
232
233 fAddVar = new TGTextEntry(v2, new TGTextBuffer(50), kAddVar);
234 fAddVar->Resize(60,20);
235 fAddVar->SetToolTipText("Add a variable");
237
239 fDeleteVar->Resize(60,20);
240 fDeleteVar->SetToolTipText("Delete a variable");
242
243 f4->AddFrame(v2, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,0,0));
244
245 fBrowse->AddFrame(f4, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Pick up the used spider attributes.
250
252{
253 if (!obj) return;
254 fSpider = dynamic_cast<TSpider*>(obj);
255 if (!fSpider) return;
256 fAvoidSignal = true;
257
258 bool av = fSpider->GetDisplayAverage();
259 if(av) fDisplayAverage->SetState(kButtonDown);
260 else fDisplayAverage->SetState(kButtonUp);
261
262 fSetNx->SetNumber(fSpider->GetNx());
263 fSetNy->SetNumber(fSpider->GetNy());
264
265 bool seg = fSpider->GetSegmentDisplay();
266
267 if(seg) fBgroup->SetButton(kSegment,true);
268 else fBgroup->SetButton(kPolyLines,true);
269
270 fGotoEntry->SetNumber(fSpider->GetCurrentEntry());
271
272 fAddVar->SetText("");
273 fDeleteVar->SetText("");
274
275 fAvLineStyleCombo->Select(fSpider->GetAverageLineStyle());
276 fAvLineWidthCombo->Select(fSpider->GetAverageLineWidth());
277 Color_t c = fSpider->GetAverageLineColor();
279 fAvLineColorSelect->SetColor(p);
280 c = fSpider->GetAverageFillColor();
282 fAvFillColorSelect->SetColor(p,false);
283 fAvFillPatternSelect->SetPattern(fSpider->GetAverageFillStyle(),false);
284
286
287 fAvoidSignal = false;
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Slot to add a variable.
292
294{
295 if (fAvoidSignal) return;
296
297 const char * var = fAddVar->GetText();
298 fSpider->AddVariable(var);
299 Update();
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Slot to set the average LineStyle.
304
306{
307 if (fAvoidSignal) return;
308
309 fSpider->SetAverageLineStyle(a);
310 Update();
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Slot to set the average LineWidth.
315
317{
318 if (fAvoidSignal) return;
319
320 fSpider->SetAverageLineWidth(a);
321 Update();
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Slot to set the average LineColor.
326
328{
329 if (fAvoidSignal) return;
330
331 fSpider->SetAverageLineColor(TColor::GetColor(a));
332 Update();
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Slot to set the average Fill Color.
337
339{
340 if (fAvoidSignal) return;
341
342 fSpider->SetAverageFillColor(TColor::GetColor(a));
343 Update();
344}
345
346////////////////////////////////////////////////////////////////////////////////
347/// Slot to set the average FillStyle.
348
350{
351 if (fAvoidSignal) return;
352
353 fSpider->SetAverageFillStyle(a);
354 Update();
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Slot to delete a variable.
359
361{
362 if (fAvoidSignal) return;
363
364 const char * var = fDeleteVar->GetText();
365 fSpider->DeleteVariable(var);
366 Update();
367}
368
369////////////////////////////////////////////////////////////////////////////////
370/// Slot Connected to the average display.
371
373{
374 if (fAvoidSignal) return;
375
376 fSpider->SetDisplayAverage(av);
377 Update();
378}
379
380////////////////////////////////////////////////////////////////////////////////
381/// Slot to select an entry by number.
382
384{
385 if (fAvoidSignal) return;
386 Long64_t ev = (Long64_t)fGotoEntry->GetNumber();
387 fSpider->GotoEntry(ev);
388 Update();
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Slot to Go to next entries.
393
395{
396 if (fAvoidSignal) return;
397 fSpider->GotoNext();
398 Update();
399}
400
401////////////////////////////////////////////////////////////////////////////////
402/// Slot to go to previous entries.
403
405{
406 if (fAvoidSignal) return;
407 fSpider->GotoPrevious();
408 Update();
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// Slot to go to next entry.
413
415{
416 if (fAvoidSignal) return;
417 fSpider->GotoFollowing();
418 Update();
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// Slot to go to last entry.
423
425{
426 if (fAvoidSignal) return;
427 fSpider->GotoPreceding();
428 Update();
429}
430
431////////////////////////////////////////////////////////////////////////////////
432/// Slot connected to the nx setting.
433
435{
436 if (fAvoidSignal) return;
437 UInt_t nx = (UInt_t)fSetNx->GetNumber();
438 fSpider->SetNx(nx);
439 Update();
440}
441
442////////////////////////////////////////////////////////////////////////////////
443/// Slot connected to the nx setting.
444
446{
447 if (fAvoidSignal) return;
448 UInt_t ny = (UInt_t)fSetNy->GetNumber();
449 fSpider->SetNy(ny);
450 Update();
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Slot to set the plot type.
455
457{
458 if(fSegment->GetState() == kButtonDown) fSpider->SetSegmentDisplay(true);
459 else fSpider->SetSegmentDisplay(false);
460 Update();
461}
@ kChildFrame
Definition GuiTypes.h:380
@ kFitWidth
Definition GuiTypes.h:387
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
short Color_t
Color number (short).
Definition RtypesCore.h:99
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
short Style_t
Style number (short).
Definition RtypesCore.h:96
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
ESpiderWid
@ kAvFillColor
@ kAvLineStyle
@ kAvLineWidth
@ kPicPreceding
@ kSegment
@ kNx
@ kAddVar
@ kPicNext
@ kAvFillStyle
@ kPolyLines
@ kNy
@ kAvLineColor
@ kPicFollowing
@ kAverage
@ kGotoEntry
@ kPicPrevious
static Int_t GetColor(const char *hexcolor)
static ULong_t Number2Pixel(Int_t ci)
Organizes TGButton widgets in a group.
Selects different options.
Definition TGButton.h:264
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
The TGLineStyleComboBox user callable and it creates a combobox for selecting the line style.
Definition TGComboBox.h:140
The TGLineWidthComboBox user callable and it creates a combobox for selecting the line width.
Definition TGComboBox.h:158
@ kNEAPositive
Positive number.
@ kNEANonNegative
Non-negative number.
@ kNESInteger
Style of number entry field.
@ kNELLimitMinMax
Both lower and upper limits.
Yield an action as soon as it is clicked.
Definition TGButton.h:228
Selects different options.
Definition TGButton.h:321
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
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:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Int_t fPriority
location in GedEditor
Definition TGedFrame.h:53
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
is a button with pattern area with a little down arrow.
Mother of all ROOT objects.
Definition TObject.h:42
virtual void DoSetNy()
Slot connected to the nx setting.
TGNumberEntryField * fGotoEntry
Jump to an entry field.
TSpiderEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Normal constructor.
TGPictureButton * fGotoNext
Go to next entries button.
void MakeBrowse()
Make the Browse tab.
TGColorSelect * fAvFillColorSelect
fill color widget for the average.
void SetModel(TObject *obj) override
Pick up the used spider attributes.
virtual void DoAvLineStyle(Int_t)
Slot to set the average LineStyle.
virtual void DoGotoFollowing()
Slot to go to next entry.
TGLineWidthComboBox * fAvLineWidthCombo
line width combo box for the average.
TSpider * fSpider
Pointer to the TSpider.
virtual void DoAvFillPattern(Style_t)
Slot to set the average FillStyle.
const TGPicture * fPicNext
Go to next entries picture.
TGCheckButton * fDisplayAverage
Button for the display of the average.
const TGPicture * fPicPreceding
Go to last entry picture.
virtual void DoGotoEntry()
Slot to select an entry by number.
TGNumberEntryField * fSetNy
To set the ny number of subpads.
virtual void DoGotoPreceding()
Slot to go to last entry.
virtual void DoSetNx()
Slot connected to the nx setting.
TGRadioButton * fPolyLines
Polyline option.
virtual void DoAvLineWidth(Int_t)
Slot to set the average LineWidth.
TGCompositeFrame * fBrowse
Browse tab.
virtual void DoAvLineColor(Pixel_t)
Slot to set the average LineColor.
virtual void DoGotoNext()
Slot to Go to next entries.
virtual void DoGotoPrevious()
Slot to go to previous entries.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGButtonGroup * fBgroup
Group of the plot type selection.
TGRadioButton * fSegment
Segment option.
TGLineStyleComboBox * fAvLineStyleCombo
line style combo box for the average.
const TGPicture * fPicFollowing
Go to next entry picture.
virtual void DoDisplayAverage(bool av)
Slot Connected to the average display.
TGPictureButton * fGotoFollowing
Go to next entry button.
const TGPicture * fPicPrevious
Go to previous entries picture.
TGPictureButton * fGotoPreceding
Go to last entry button.
virtual void DoDeleteVar()
Slot to delete a variable.
TGedPatternSelect * fAvFillPatternSelect
fill pattern widget for the average.
TGColorSelect * fAvLineColorSelect
line color widget for the average.
virtual void DoAvFillColor(Pixel_t)
Slot to set the average Fill Color.
TGPictureButton * fGotoPrevious
Go to previous entries button.
TGTextEntry * fDeleteVar
Delete variable field.
virtual void DoSetPlotType()
Slot to set the plot type.
~TSpiderEditor() override
Destructor of the TSpiderEditor.
TGNumberEntryField * fSetNx
To set the nx number of subpads.
TGTextEntry * fAddVar
Add variable field.
virtual void DoAddVar()
Slot to add a variable.
Spider class.
Definition TSpider.h:40
TF1 * f1
Definition legend1.C:11