Logo ROOT   6.10/09
Reference Guide
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 "TGFrame.h"
15 #include "TGButton.h"
16 #include "TGNumberEntry.h"
17 #include "TGButtonGroup.h"
18 #include <Riostream.h>
19 #include "TGLabel.h"
20 #include "TGPicture.h"
21 #include "TGTextEntry.h"
22 #include "TG3DLine.h"
23 #include "TGComboBox.h"
24 #include "TGColorSelect.h"
25 #include "TGedPatternSelect.h"
26 #include "TColor.h"
27 
29 
30 /** \class TSpiderEditor
31 The TSpider editor class.
32 Provides the graphical user interface to the spider plots.
33 */
34 
35 enum ESpiderWid {
37  kNx,
38  kNy,
53 };
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Normal constructor.
57 
58 TSpiderEditor::TSpiderEditor(const TGWindow* /*p*/, Int_t /*width*/, Int_t /*height*/, UInt_t /*options*/, Pixel_t /*back*/)
59 {
60  fPriority = 1;
61  MakeTitle("Spider");
62 
63  fBgroup = new TGButtonGroup(this,2,1,0,0, "Plot type");
65  fPolyLines = new TGRadioButton(fBgroup, "PolyLine", kPolyLines);
66  fPolyLines->SetToolTipText("Set a polyline plot type");
67  fSegment = new TGRadioButton(fBgroup, "Segment", kSegment);
68  fSegment->SetToolTipText("Set a segment plot type");
71 
73 
74  TGLabel *nxLabel = new TGLabel(f1,"Nx:");
75  f1->AddFrame(nxLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 1, 1));
76  fSetNx = new TGNumberEntryField(f1, kNx, 2,
80  fSetNx->SetToolTipText("Set the X number of plots");
81  fSetNx->Resize(30,20);
82  f1->AddFrame(fSetNx, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
83 
84  TGLabel *nyLabel = new TGLabel(f1,"Ny:");
85  f1->AddFrame(nyLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 1, 1));
86  fSetNy = new TGNumberEntryField(f1, kNy, 2,
90  fSetNy->SetToolTipText("Set the Y number of plots");
91  fSetNy->Resize(30,20);
92  f1->AddFrame(fSetNy, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
93  AddFrame(f1, new TGLayoutHints(kLHintsLeft,1,1,1,1));
94 
95  MakeTitle("Average");
96 
97  fDisplayAverage = new TGCheckButton(this, "Average",kAverage);
98  fDisplayAverage->SetToolTipText("Display average");
100 
102 
104  f2->AddFrame(fAvLineColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
105 
107  fAvLineWidthCombo->Resize(91, 20);
108  f2->AddFrame(fAvLineWidthCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
109 
110  AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
111 
113  fAvLineStyleCombo->Resize(137, 20);
115 
116  TGHorizontalFrame *f2b = new TGHorizontalFrame(this);
117 
119  f2b->AddFrame(fAvFillColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
120 
122  f2b->AddFrame(fAvFillPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
123 
124  AddFrame(f2b, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
125 
126  MakeBrowse();
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 /// Destructor of the TSpiderEditor.
131 
133 {
134  delete fPolyLines;
135  delete fSegment;
136 }
137 
138 ////////////////////////////////////////////////////////////////////////////////
139 /// Connect signals to slots.
140 
142 {
143  fDisplayAverage->Connect("Toggled(Bool_t)", "TSpiderEditor", this, "DoDisplayAverage(Bool_t)");
144  fSetNx->Connect("ReturnPressed()", "TSpiderEditor", this, "DoSetNx()");
145  fSetNy->Connect("ReturnPressed()", "TSpiderEditor", this, "DoSetNy()");
146  fBgroup->Connect("Clicked(Int_t)","TSpiderEditor",this,"DoSetPlotType()");
147  fGotoEntry->Connect("ReturnPressed()", "TSpiderEditor", this, "DoGotoEntry()");
148  fGotoNext->Connect("Clicked()","TSpiderEditor",this,"DoGotoNext()");
149  fGotoPrevious->Connect("Clicked()","TSpiderEditor",this,"DoGotoPrevious()");
150  fGotoFollowing->Connect("Clicked()","TSpiderEditor",this,"DoGotoFollowing()");
151  fGotoPreceding->Connect("Clicked()","TSpiderEditor",this,"DoGotoPreceding()");
152  fAddVar->Connect("ReturnPressed()","TSpiderEditor",this,"DoAddVar()");
153  fDeleteVar->Connect("ReturnPressed()","TSpiderEditor",this,"DoDeleteVar()");
154  fAvLineStyleCombo->Connect("Selected(Int_t)", "TSpiderEditor", this, "DoAvLineStyle(Int_t)");
155  fAvLineWidthCombo->Connect("Selected(Int_t)", "TSpiderEditor", this, "DoAvLineWidth(Int_t)");
156  fAvLineColorSelect->Connect("ColorSelected(Pixel_t)", "TSpiderEditor", this, "DoAvLineColor(Pixel_t)");
157  fAvFillColorSelect->Connect("ColorSelected(Pixel_t)", "TSpiderEditor", this, "DoAvFillColor(Pixel_t)");
158  fAvFillPatternSelect->Connect("PatternSelected(Style_t)", "TSpiderEditor", this, "DoAvFillPattern(Style_t)");
159 
160  fInit = kFALSE;
161 }
162 
163 ////////////////////////////////////////////////////////////////////////////////
164 /// Make the Browse tab.
165 
167 {
168  fBrowse = CreateEditorTabSubFrame("Browse");
169 
171  title1->AddFrame(new TGLabel(title1, "Entries"),
172  new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
173  title1->AddFrame(new TGHorizontal3DLine(title1),
174  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
175  fBrowse->AddFrame(title1, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
176 
178 
179  TGLabel *gotoEntryLabel = new TGLabel(f3,"Go to:");
180  f3->AddFrame(gotoEntryLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 18, 1, 5));
184  fGotoEntry->SetToolTipText("Jump to a specified entry");
185  fGotoEntry->Resize(60,20);
186  f3->AddFrame(fGotoEntry, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
187 
189 
191 
192  fPicPrevious = gClient->GetPicture("first_t.xpm");
194  fGotoPrevious->SetToolTipText("Jump to the last entries");
196 
197  fPicPreceding = gClient->GetPicture("previous_t.xpm");
199  fGotoPreceding->SetToolTipText("Jump to the last entries");
201 
202  fPicFollowing = gClient->GetPicture("next_t.xpm");
204  fGotoFollowing->SetToolTipText("Jump to the last entries");
206 
207  fPicNext = gClient->GetPicture("last_t.xpm");
209  fGotoNext->SetToolTipText("Jump to the next entries");
211 
213 
215 
216  title2->AddFrame(new TGLabel(title2, "Variables"),
217  new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
218  title2->AddFrame(new TGHorizontal3DLine(title2),
219  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
220  fBrowse->AddFrame(title2, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
221 
223 
224  TGVerticalFrame *v1 = new TGVerticalFrame(f4);
225 
226  TGLabel *addVar = new TGLabel(v1,"Add:");
228 
229  TGLabel *deleteVar = new TGLabel(v1,"Delete:");
230  v1->AddFrame(deleteVar,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
231 
232  f4->AddFrame(v1, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,0,0));
233 
234  TGVerticalFrame *v2 = new TGVerticalFrame(f4);
235 
236  fAddVar = new TGTextEntry(v2, new TGTextBuffer(50), kAddVar);
237  fAddVar->Resize(60,20);
238  fAddVar->SetToolTipText("Add a variable");
240 
241  fDeleteVar = new TGTextEntry(v2, new TGTextBuffer(50), kAddVar);
242  fDeleteVar->Resize(60,20);
243  fDeleteVar->SetToolTipText("Delete a variable");
245 
246  f4->AddFrame(v2, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,0,0));
247 
249 }
250 
251 ////////////////////////////////////////////////////////////////////////////////
252 /// Pick up the used spider attributes.
253 
255 {
256  if (!obj) return;
257  fSpider = dynamic_cast<TSpider*>(obj);
258  if (!fSpider) return;
260 
264 
267 
269 
270  if(seg) fBgroup->SetButton(kSegment,kTRUE);
272 
274 
275  fAddVar->SetText("");
276  fDeleteVar->SetText("");
277 
284  p = TColor::Number2Pixel(c);
287 
289 
291 }
292 
293 ////////////////////////////////////////////////////////////////////////////////
294 /// Slot to add a variable.
295 
297 {
298  if (fAvoidSignal) return;
299 
300  const char * var = fAddVar->GetText();
301  fSpider->AddVariable(var);
302  Update();
303 }
304 
305 ////////////////////////////////////////////////////////////////////////////////
306 /// Slot to set the average LineStyle.
307 
309 {
310  if (fAvoidSignal) return;
311 
313  Update();
314 }
315 
316 ////////////////////////////////////////////////////////////////////////////////
317 /// Slot to set the average LineWidth.
318 
320 {
321  if (fAvoidSignal) return;
322 
324  Update();
325 }
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 /// Slot to set the average LineColor.
329 
331 {
332  if (fAvoidSignal) return;
333 
335  Update();
336 }
337 
338 ////////////////////////////////////////////////////////////////////////////////
339 /// Slot to set the average Fill Color.
340 
342 {
343  if (fAvoidSignal) return;
344 
346  Update();
347 }
348 
349 ////////////////////////////////////////////////////////////////////////////////
350 /// Slot to set the average FillStyle.
351 
353 {
354  if (fAvoidSignal) return;
355 
357  Update();
358 }
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 /// Slot to delete a variable.
362 
364 {
365  if (fAvoidSignal) return;
366 
367  const char * var = fDeleteVar->GetText();
368  fSpider->DeleteVariable(var);
369  Update();
370 }
371 
372 ////////////////////////////////////////////////////////////////////////////////
373 /// Slot Connected to the average display.
374 
376 {
377  if (fAvoidSignal) return;
378 
380  Update();
381 }
382 
383 ////////////////////////////////////////////////////////////////////////////////
384 /// Slot to select an entry by number.
385 
387 {
388  if (fAvoidSignal) return;
390  fSpider->GotoEntry(ev);
391  Update();
392 }
393 
394 ////////////////////////////////////////////////////////////////////////////////
395 /// Slot to Go to next entries.
396 
398 {
399  if (fAvoidSignal) return;
400  fSpider->GotoNext();
401  Update();
402 }
403 
404 ////////////////////////////////////////////////////////////////////////////////
405 /// Slot to go to previous entries.
406 
408 {
409  if (fAvoidSignal) return;
411  Update();
412 }
413 
414 ////////////////////////////////////////////////////////////////////////////////
415 /// Slot to go to next entry.
416 
418 {
419  if (fAvoidSignal) return;
421  Update();
422 }
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 /// Slot to go to last entry.
426 
428 {
429  if (fAvoidSignal) return;
431  Update();
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Slot connected to the nx setting.
436 
438 {
439  if (fAvoidSignal) return;
441  fSpider->SetNx(nx);
442  Update();
443 }
444 
445 ////////////////////////////////////////////////////////////////////////////////
446 /// Slot connected to the nx setting.
447 
449 {
450  if (fAvoidSignal) return;
452  fSpider->SetNy(ny);
453  Update();
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// Slot to set the plot type.
458 
460 {
463  Update();
464 }
const int nx
Definition: kalman.C:16
virtual void SetModel(TObject *obj)
Pick up the used spider attributes.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGButtonGroup * fBgroup
Definition: TSpiderEditor.h:50
TGNumberEntryField * fSetNy
Definition: TSpiderEditor.h:49
void SetAverageLineStyle(Style_t sty)
Set the LineStyle of the average.
Definition: TSpider.cxx:964
long long Long64_t
Definition: RtypesCore.h:69
virtual void DoAvFillPattern(Style_t)
Slot to set the average FillStyle.
void GotoPrevious()
Go to the previous entries.
Definition: TSpider.cxx:763
short Style_t
Definition: RtypesCore.h:76
virtual void DoAvLineStyle(Int_t)
Slot to set the average LineStyle.
Style_t GetAverageFillStyle() const
Get the FillStyle of the average.
Definition: TSpider.cxx:656
void MakeBrowse()
Make the Browse tab.
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void DoAvFillColor(Pixel_t)
Slot to set the average Fill Color.
void SetSegmentDisplay(Bool_t seg)
Set the segment display or not.
Definition: TSpider.cxx:1379
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
virtual void DoGotoNext()
Slot to Go to next entries.
TGTextEntry * fAddVar
Definition: TSpiderEditor.h:63
TGPictureButton * fGotoFollowing
Definition: TSpiderEditor.h:59
TGLineStyleComboBox * fAvLineStyleCombo
Definition: TSpiderEditor.h:43
TGCheckButton * fDisplayAverage
Definition: TSpiderEditor.h:42
TGColorSelect * fAvFillColorSelect
Definition: TSpiderEditor.h:46
virtual void DoDeleteVar()
Slot to delete a variable.
#define gClient
Definition: TGClient.h:166
Bool_t GetDisplayAverage() const
Definition: TSpider.h:103
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
TGPictureButton * fGotoPreceding
Definition: TSpiderEditor.h:61
Color_t GetAverageFillColor() const
Get the Fill Color of the average.
Definition: TSpider.cxx:646
TSpider * fSpider
Definition: TSpiderEditor.h:41
void GotoNext()
Go to the next entries.
Definition: TSpider.cxx:753
TGRadioButton * fPolyLines
Definition: TSpiderEditor.h:51
void DeleteVariable(const char *varexp)
Delete a variable from its expression.
Definition: TSpider.cxx:352
TGColorSelect * fAvLineColorSelect
Definition: TSpiderEditor.h:45
const TGPicture * fPicPrevious
Definition: TSpiderEditor.h:58
ESpiderWid
Style_t GetAverageLineStyle() const
Get the LineStyle of the average.
Definition: TSpider.cxx:616
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
ULong_t Pixel_t
Definition: GuiTypes.h:39
virtual void DoGotoEntry()
Slot to select an entry by number.
const int ny
Definition: kalman.C:17
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:443
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by &#39;owner&#39; in extra tab &#39;name&#39;.
Definition: TGedFrame.cxx:123
TGCompositeFrame * fBrowse
Definition: TSpiderEditor.h:53
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive, and other buttons according to IsExclusive().
void SetNx(UInt_t nx)
Set the X number of sub pads.
Definition: TSpider.cxx:1225
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
virtual EButtonState GetState() const
Definition: TGButton.h:112
short Color_t
Definition: RtypesCore.h:79
void SetAverageLineWidth(Width_t wid)
Set the LineWidth of the average.
Definition: TSpider.cxx:988
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:867
virtual void DoAvLineColor(Pixel_t)
Slot to set the average LineColor.
const TGPicture * fPicNext
Definition: TSpiderEditor.h:56
virtual void ConnectSignals2Slots()
Connect signals to slots.
unsigned int UInt_t
Definition: RtypesCore.h:42
void SetNy(UInt_t ny)
Set the Y number of sub pads.
Definition: TSpider.cxx:1302
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
Definition: TColor.cxx:1707
void SetPattern(Style_t pattern, Bool_t emit=kTRUE)
Set pattern.
virtual void DoSetNx()
Slot connected to the nx setting.
void SetAverageFillColor(Color_t col)
Set the Fill Color of the average.
Definition: TSpider.cxx:1000
virtual void DoAvLineWidth(Int_t)
Slot to set the average LineWidth.
Width_t GetAverageLineWidth() const
Get the LineWidth of the average.
Definition: TSpider.cxx:636
const Bool_t kFALSE
Definition: RtypesCore.h:92
const TGPicture * fPicPreceding
Definition: TSpiderEditor.h:62
void SetAverageFillStyle(Style_t sty)
Set the FillStyle of the average.
Definition: TSpider.cxx:1012
const char * GetText() const
Definition: TGTextEntry.h:134
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:1917
Long64_t GetCurrentEntry() const
Definition: TSpider.h:104
#define ClassImp(name)
Definition: Rtypes.h:336
TGNumberEntryField * fSetNx
Definition: TSpiderEditor.h:48
~TSpiderEditor()
Destructor of the TSpiderEditor.
virtual void DoSetPlotType()
Slot to set the plot type.
void GotoFollowing()
Go to the next entry.
Definition: TSpider.cxx:773
TGLineWidthComboBox * fAvLineWidthCombo
Definition: TSpiderEditor.h:44
virtual void DoGotoPreceding()
Slot to go to last entry.
Bool_t GetSegmentDisplay() const
Definition: TSpider.h:108
TGedPatternSelect * fAvFillPatternSelect
Definition: TSpiderEditor.h:47
void SetDisplayAverage(Bool_t disp)
Display or not the average.
Definition: TSpider.cxx:1024
void GotoPreceding()
Go to the last entry.
Definition: TSpider.cxx:783
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
TGTextEntry * fDeleteVar
Definition: TSpiderEditor.h:64
Mother of all ROOT objects.
Definition: TObject.h:37
const TGPicture * fPicFollowing
Definition: TSpiderEditor.h:60
Bool_t fInit
Definition: TGedFrame.h:53
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
double f2(const double *x)
Color_t GetAverageLineColor() const
Get the LineColor of the average.
Definition: TSpider.cxx:626
void AddVariable(const char *varexp)
Add a variable to the plot from its expression.
Definition: TSpider.cxx:214
virtual void DoDisplayAverage(Bool_t av)
Slot Connected to the average display.
Int_t GetNx() const
Definition: TSpider.h:106
TF1 * f1
Definition: legend1.C:11
Spider class.
Definition: TSpider.h:44
Int_t GetNy() const
Definition: TSpider.h:107
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
TSpiderEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Normal constructor.
TGNumberEntryField * fGotoEntry
Definition: TSpiderEditor.h:54
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...
virtual void DoGotoPrevious()
Slot to go to previous entries.
The TSpider editor class.
Definition: TSpiderEditor.h:39
TGRadioButton * fSegment
Definition: TSpiderEditor.h:52
virtual void DoGotoFollowing()
Slot to go to next entry.
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
void GotoEntry(Long64_t e)
Go to a specified entry.
Definition: TSpider.cxx:743
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
TGPictureButton * fGotoNext
Definition: TSpiderEditor.h:55
virtual void DoAddVar()
Slot to add a variable.
void SetAverageLineColor(Color_t col)
Set the LineColor of the average.
Definition: TSpider.cxx:976
TGPictureButton * fGotoPrevious
Definition: TSpiderEditor.h:57
virtual void DoSetNy()
Slot connected to the nx setting.
Int_t fPriority
Definition: TGedFrame.h:59