Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TParallelCoordEditor.cxx
Go to the documentation of this file.
1 // @(#)root/treeviewer:$Id$
2 // Author: Bastien Dalla Piazza 02/08/2007
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 "TParallelCoordEditor.h"
13 #include "TParallelCoord.h"
14 #include "TParallelCoordRange.h"
15 #include "TParallelCoordVar.h"
16 
17 #include "TGFrame.h"
18 #include "TGButton.h"
19 #include "TGButtonGroup.h"
20 #include "TGNumberEntry.h"
21 #include "TGLabel.h"
22 #include "TGTextEntry.h"
23 #include "TGComboBox.h"
24 #include "TGColorSelect.h"
25 #include "TColor.h"
26 #include "TG3DLine.h"
27 #include "TGSlider.h"
28 #include "TGComboBox.h"
29 #include "TGDoubleSlider.h"
30 #include "TTree.h"
31 #include "TGListBox.h"
32 #include "TGedPatternSelect.h"
33 #include "TPad.h"
34 #include "TCanvas.h"
35 
36 #include "Riostream.h"
37 
38 #include "TROOT.h"
39 
40 ClassImp(TParallelCoordEditor);
41 
42 
43 /** \class TParallelCoordEditor
44 
45 This is the TParallelCoord editor. It brings tools to explore datas
46 Using parallel coordinates. The main tools are:
47 
48  - Dots spacing : Set the dots spacing with whichone the lines
49  must be drawn. This tool is useful to reduce the image
50  cluttering.
51  - The Selections section : Set the current edited selection and
52  allows to apply it to the tree through a generated entry list.
53  - The Entries section : Set how many events must be drawn.
54  A weight cut can be defioned here (see TParallelCoord for a
55  a description of the weight cut).
56  - The Variables tab : To define the global settings to display
57  the axes. It is also possible to add a variable from its
58  expression or delete a selected one (also possible using right
59  click on the pad.
60 */
61 
62 enum EParallelWid {
63  kGlobalLineColor,
64  kLineTypeBgroup,
65  kLineTypePoly,
66  kLineTypeCurves,
67  kGlobalLineWidth,
68  kDotsSpacing,
69  kDotsSpacingField,
70  kAlpha,
71  kAlphaField,
72  kSelectionSelect,
73  kSelectLineColor,
74  kSelectLineWidth,
75  kActivateSelection,
76  kDeleteSelection,
77  kAddSelection,
78  kAddSelectionEntry,
79  kShowRanges,
80  kPaintEntries,
81  kEntriesToDraw,
82  kFirstEntry,
83  kNentries,
84  kApplySelect,
85  kUnApply,
86  kDelayDrawing,
87  kHideAllRanges,
88  kVariables,
89  kDeleteVar,
90  kHistHeight,
91  kHistWidth,
92  kHistBinning,
93  kRenameVar,
94  kWeightCut,
95  kHistColorSelect,
96  kHistPatternSelect
97 };
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Normal constructor.
101 
102 TParallelCoordEditor::TParallelCoordEditor(const TGWindow* /*p*/,
103  Int_t/*width*/, Int_t /*height*/,
104  UInt_t /*options*/, Pixel_t /*back*/)
105 {
106  fPriority = 1;
107  fDelay = kTRUE;
108 
109  // Line
110  MakeTitle("Line");
111 
112  TGHorizontalFrame *f1 = new TGHorizontalFrame(this);
113  fGlobalLineColor = new TGColorSelect(f1,0,kGlobalLineColor);
114  f1->AddFrame(fGlobalLineColor,new TGLayoutHints(kLHintsLeft | kLHintsTop));
115  fGlobalLineWidth = new TGLineWidthComboBox(f1, kGlobalLineWidth);
116  fGlobalLineWidth->Resize(91, 20);
117  f1->AddFrame(fGlobalLineWidth, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
118  AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsTop));
119 
120  if (!TCanvas::SupportAlpha()) {
121 
122  AddFrame(new TGLabel(this,"Dots spacing"),
123  new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
124 
125  TGHorizontalFrame *f2 = new TGHorizontalFrame(this);
126  fDotsSpacing = new TGHSlider(f2,100,kSlider2|kScaleNo,kDotsSpacing);
127  fDotsSpacing->SetRange(0,60);
128  f2->AddFrame(fDotsSpacing,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
129  fDotsSpacingField = new TGNumberEntryField(f2, kDotsSpacingField, 0,
130  TGNumberFormat::kNESInteger,
131  TGNumberFormat::kNEANonNegative);
132  fDotsSpacingField->Resize(40,20);
133  f2->AddFrame(fDotsSpacingField,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
134  AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
135  }
136  else {
137  TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
138  AddFrame(AlphaLabel,
139  new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
140  TGHorizontalFrame *f2a = new TGHorizontalFrame(this);
141  fAlpha = new TGHSlider(f2a,100,kSlider2|kScaleNo,kAlpha);
142  fAlpha->SetRange(0,1000);
143  f2a->AddFrame(fAlpha,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
144  fAlphaField = new TGNumberEntryField(f2a, kAlphaField, 0,
145  TGNumberFormat::kNESReal,
146  TGNumberFormat::kNEANonNegative);
147  fAlphaField->Resize(40,20);
148  f2a->AddFrame(fAlphaField,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
149  AddFrame(f2a, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
150  }
151 
152  fLineTypeBgroup = new TGButtonGroup(this,2,1,0,0, "Line type");
153  fLineTypeBgroup->SetRadioButtonExclusive(kTRUE);
154  fLineTypePoly = new TGRadioButton(fLineTypeBgroup,"Polyline", kLineTypePoly);
155  fLineTypePoly->SetToolTipText("Draw the entries with a polyline");
156  fLineTypeCurves = new TGRadioButton(fLineTypeBgroup,"Curves",
157  kLineTypeCurves);
158  fLineTypeCurves->SetToolTipText("Draw the entries with a curve");
159  fLineTypeBgroup->ChangeOptions(kChildFrame|kVerticalFrame);
160  AddFrame(fLineTypeBgroup, new TGLayoutHints(kLHintsCenterY | kLHintsLeft));
161 
162  // Selections
163  MakeTitle("Selections");
164 
165  fHideAllRanges = new TGCheckButton(this,"Hide all ranges",kHideAllRanges);
166  AddFrame(fHideAllRanges);
167 
168  fSelectionSelect = new TGComboBox(this,kSelectionSelect);
169  fSelectionSelect->Resize(140,20);
170  AddFrame(fSelectionSelect, new TGLayoutHints(kLHintsCenterY | kLHintsLeft,0,0,3,0));
171 
172  TGHorizontalFrame *f3 = new TGHorizontalFrame(this);
173  fSelectLineColor = new TGColorSelect(f3,0,kSelectLineColor);
174  f3->AddFrame(fSelectLineColor,new TGLayoutHints(kLHintsLeft | kLHintsTop));
175  fSelectLineWidth = new TGLineWidthComboBox(f3, kSelectLineWidth);
176  fSelectLineWidth->Resize(94, 20);
177  f3->AddFrame(fSelectLineWidth, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
178  AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsTop,0,0,3,0));
179 
180  fActivateSelection = new TGCheckButton(this,"Activate",kActivateSelection);
181  fActivateSelection->SetToolTipText("Activate the current selection");
182  AddFrame(fActivateSelection);
183  fShowRanges = new TGCheckButton(this,"Show ranges",kShowRanges);
184  AddFrame(fShowRanges);
185 
186  TGHorizontalFrame *f5 = new TGHorizontalFrame(this);
187  fAddSelectionField = new TGTextEntry(f5);
188  fAddSelectionField->Resize(57,20);
189  f5->AddFrame(fAddSelectionField, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
190  fAddSelection = new TGTextButton(f5,"Add");
191  fAddSelection->SetToolTipText("Add a new selection (Right click on the axes to add a range).");
192  f5->AddFrame(fAddSelection, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,3,0,0,0));
193  fDeleteSelection = new TGTextButton(f5,"Delete",kDeleteSelection);
194  fDeleteSelection->SetToolTipText("Delete the current selection");
195  f5->AddFrame(fDeleteSelection, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,3,0,0,0));
196  AddFrame(f5, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,3,0,0,0));
197 
198  TGHorizontalFrame *f7 = new TGHorizontalFrame(this);
199  fApplySelect = new TGTextButton(f7,"Apply to tree",kApplySelect);
200  fApplySelect->SetToolTipText("Generate an entry list for the current selection and apply it to the tree.");
201  f7->AddFrame(fApplySelect);
202  fUnApply = new TGTextButton(f7,"Reset tree",kUnApply);
203  fUnApply->SetToolTipText("Reset the tree entry list");
204  f7->AddFrame(fUnApply, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,10,0,0,0));
205  AddFrame(f7, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,0,0,3,0));
206 
207  // Entries
208  MakeTitle("Entries");
209 
210  fPaintEntries = new TGCheckButton(this,"Draw entries",kPaintEntries);
211  AddFrame(fPaintEntries);
212  fDelayDrawing = new TGCheckButton(this,"Delay Drawing", kDelayDrawing);
213  AddFrame(fDelayDrawing);
214 
215  fEntriesToDraw = new TGDoubleHSlider(this,140,kDoubleScaleNo,kEntriesToDraw);
216  AddFrame(fEntriesToDraw);
217 
218  TGHorizontalFrame *f6 = new TGHorizontalFrame(this);
219  TGVerticalFrame *v1 = new TGVerticalFrame(f6);
220  TGVerticalFrame *v2 = new TGVerticalFrame(f6);
221  v1->AddFrame(new TGLabel(v1,"First entry:"));
222  fFirstEntry = new TGNumberEntryField(v1, kFirstEntry, 0,
223  TGNumberFormat::kNESInteger,
224  TGNumberFormat::kNEANonNegative);
225  fFirstEntry->Resize(68,20);
226  v1->AddFrame(fFirstEntry);
227  v2->AddFrame(new TGLabel(v2,"# of entries:"));
228  fNentries = new TGNumberEntryField(v2, kFirstEntry, 0,
229  TGNumberFormat::kNESInteger,
230  TGNumberFormat::kNEANonNegative);
231  fNentries->Resize(68,20);
232  v2->AddFrame(fNentries);
233  f6->AddFrame(v1);
234  f6->AddFrame(v2, new TGLayoutHints(kLHintsLeft,4,0,0,0));
235  AddFrame(f6);
236 
237  AddFrame(new TGLabel(this,"Weight cut:"));
238 
239  TGHorizontalFrame *f8 = new TGHorizontalFrame(this);
240  fWeightCut = new TGHSlider(f8,100,kSlider2|kScaleNo,kDotsSpacing);
241  fWeightCutField = new TGNumberEntryField(f8,kDotsSpacingField, 0,
242  TGNumberFormat::kNESInteger,
243  TGNumberFormat::kNEANonNegative);
244  fWeightCutField->Resize(40,20);
245  f8->AddFrame(fWeightCut);
246  f8->AddFrame(fWeightCutField);
247  AddFrame(f8);
248 
249  MakeVariablesTab();
250 }
251 
252 ////////////////////////////////////////////////////////////////////////////////
253 /// Make the "variable" tab.
254 
255 void TParallelCoordEditor::MakeVariablesTab()
256 {
257  fVarTab = CreateEditorTabSubFrame("Variables");
258  // Variable
259 
260  TGHorizontalFrame *f9 = new TGHorizontalFrame(fVarTab);
261  fAddVariable = new TGTextEntry(f9);
262  fAddVariable->Resize(71,20);
263  f9->AddFrame(fAddVariable, new TGLayoutHints(kLHintsCenterY));
264  fButtonAddVar = new TGTextButton(f9,"Add");
265  fButtonAddVar->SetToolTipText("Add a new variable from the tree (must be a valid expression).");
266  f9->AddFrame(fButtonAddVar, new TGLayoutHints(kLHintsCenterY,4,0,0,0));
267  fVarTab->AddFrame(f9);
268 
269  TGHorizontalFrame *f10 = new TGHorizontalFrame(fVarTab);
270  fVariables = new TGComboBox(f10,kVariables);
271  fVariables->Resize(105,20);
272  f10->AddFrame(fVariables, new TGLayoutHints(kLHintsCenterY));
273  fVarTab->AddFrame(f10,new TGLayoutHints(kLHintsLeft,0,0,2,0));
274 
275  TGHorizontalFrame *f12 = new TGHorizontalFrame(fVarTab);
276  fDeleteVar = new TGTextButton(f12,"Delete",kDeleteVar);
277  fDeleteVar->SetToolTipText("Delete the current selected variable");
278  f12->AddFrame(fDeleteVar, new TGLayoutHints(kLHintsCenterY,1,0,0,0));
279  fRenameVar = new TGTextButton(f12,"Rename",kRenameVar);
280  fRenameVar->SetToolTipText("Rename the current selected variable");
281  f12->AddFrame(fRenameVar, new TGLayoutHints(kLHintsCenterY,4,0,0,0));
282  fVarTab->AddFrame(f12,new TGLayoutHints(kLHintsLeft,0,0,2,0));
283 
284  fVarTab->AddFrame(new TGLabel(fVarTab,"Axis histograms:"));
285 
286  TGHorizontalFrame *f11 = new TGHorizontalFrame(fVarTab);
287  TGVerticalFrame *v3 = new TGVerticalFrame(f11);
288  TGVerticalFrame *v4 = new TGVerticalFrame(f11);
289  v3->AddFrame(new TGLabel(v3,"Binning:"));
290  fHistBinning = new TGNumberEntryField(v3, kHistWidth, 0,
291  TGNumberFormat::kNESInteger,
292  TGNumberFormat::kNEANonNegative);
293  fHistBinning->Resize(68,20);
294  v3->AddFrame(fHistBinning);
295  v4->AddFrame(new TGLabel(v4,"Width:"));
296  fHistWidth = new TGNumberEntryField(v4, kHistWidth, 0,
297  TGNumberFormat::kNESInteger,
298  TGNumberFormat::kNEANonNegative);
299  fHistWidth->Resize(68,20);
300  v4->AddFrame(fHistWidth, new TGLayoutHints(kLHintsLeft,4,0,0,0));
301  f11->AddFrame(v3);
302  f11->AddFrame(v4);
303  fVarTab->AddFrame(f11);
304 
305  fHistShowBoxes = new TGCheckButton(fVarTab,"Show box histograms");
306  fVarTab->AddFrame(fHistShowBoxes);
307 
308  fVarTab->AddFrame(new TGLabel(fVarTab,"Bar histograms style:"));
309 
310  TGCompositeFrame *f13 = new TGCompositeFrame(fVarTab, 80, 20, kHorizontalFrame);
311  fHistColorSelect = new TGColorSelect(f13, 0, kHistColorSelect);
312  f13->AddFrame(fHistColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
313  fHistColorSelect->Associate(this);
314  fHistPatternSelect = new TGedPatternSelect(f13, 1, kHistPatternSelect);
315  f13->AddFrame(fHistPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
316  fHistPatternSelect->Associate(this);
317  fVarTab->AddFrame(f13, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
318 }
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// Destructor.
322 
323 TParallelCoordEditor::~TParallelCoordEditor()
324 {
325  delete fLineTypePoly;
326  delete fLineTypeCurves;
327 }
328 
329 ////////////////////////////////////////////////////////////////////////////////
330 /// Clean up the selection combo box.
331 
332 void TParallelCoordEditor::CleanUpSelections()
333 {
334  TList *list = fParallel->GetSelectList();
335  fSelectionSelect->RemoveAll();
336  Bool_t enable = list->GetSize() > 0;
337  fSelectionSelect->SetEnabled(enable);
338  fSelectLineColor->SetEnabled(enable);
339  fSelectLineWidth->SetEnabled(enable);
340  fActivateSelection->SetEnabled(enable);
341  fShowRanges->SetEnabled(enable);
342  fDeleteSelection->SetEnabled(enable);
343  if (list->GetSize() > 0) {
344  Int_t i = 0;
345  TIter next(list);
346  TParallelCoordSelect* sel;
347  while ((sel = (TParallelCoordSelect*)next())) {
348  fSelectionSelect->AddEntry(sel->GetTitle(),i);
349  TGLBEntry *entry = fSelectionSelect->GetListBox()->GetEntry(i);
350  if (entry)
351  entry->SetBackgroundColor(TColor::Number2Pixel(sel->GetLineColor()));
352  ++i;
353  }
354  sel = fParallel->GetCurrentSelection();
355  if (sel) {
356  fSelectionSelect->Select(list->IndexOf(sel),kFALSE);
357  Color_t c;
358  Pixel_t p;
359  c = sel->GetLineColor();
360  p = TColor::Number2Pixel(c);
361  fSelectLineColor->SetColor(p);
362  fSelectLineWidth->Select(sel->GetLineWidth());
363  fActivateSelection->SetOn(sel->TestBit(TParallelCoordSelect::kActivated));
364  fShowRanges->SetOn(sel->TestBit(TParallelCoordSelect::kShowRanges));
365  }
366  }
367 }
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Clean up the variables combo box.
371 
372 void TParallelCoordEditor::CleanUpVariables()
373 {
374  TList *list = fParallel->GetVarList();
375  fVariables->RemoveAll();
376  Bool_t enable = list->GetSize() > 0;
377  fVariables->SetEnabled(enable);
378  fDeleteVar->SetEnabled(enable);
379  fHistShowBoxes->SetEnabled(enable);
380  fHistWidth->SetEnabled(enable);
381  fHistBinning->SetEnabled(enable);
382  if (list->GetSize() > 0) {
383  Int_t i = 0;
384  TIter next(list);
385  TParallelCoordVar* var;
386  while ((var = (TParallelCoordVar*)next())) {
387  fVariables->AddEntry(var->GetTitle(),i);
388  ++i;
389  }
390  var = (TParallelCoordVar*)list->First();
391  fVariables->Select(0,kFALSE);
392  fHistShowBoxes->SetOn(var->TestBit(TParallelCoordVar::kShowBarHisto));
393  fHistWidth->SetNumber(var->GetHistLineWidth());
394  fHistBinning->SetNumber(var->GetHistBinning());
395  }
396 }
397 
398 ////////////////////////////////////////////////////////////////////////////////
399 /// Connect signals to slots.
400 
401 void TParallelCoordEditor::ConnectSignals2Slots()
402 {
403  fGlobalLineColor->Connect("ColorSelected(Pixel_t)","TParallelCoordEditor",
404  this, "DoGlobalLineColor(Pixel_t)");
405  fGlobalLineWidth->Connect("Selected(Int_t)","TParallelCoordEditor",
406  this, "DoGlobalLineWidth(Int_t)");
407  if (!TCanvas::SupportAlpha()) {
408  fDotsSpacing->Connect("Released()","TParallelCoordEditor",
409  this, "DoDotsSpacing()");
410  fDotsSpacing->Connect("PositionChanged(Int_t)","TParallelCoordEditor",
411  this, "DoLiveDotsSpacing(Int_t)");
412  fDotsSpacingField->Connect("ReturnPressed()","TParallelCoordEditor",
413  this, "DoDotsSpacingField()");
414  }
415  else {
416  fAlpha->Connect("Released()","TParallelCoordEditor",
417  this, "DoAlpha()");
418  fAlpha->Connect("PositionChanged(Int_t)","TParallelCoordEditor",
419  this, "DoLiveAlpha(Int_t)");
420  fAlphaField->Connect("ReturnPressed()","TParallelCoordEditor",
421  this, "DoAlphaField()");
422  }
423  fLineTypeBgroup->Connect("Clicked(Int_t)", "TParallelCoordEditor",
424  this, "DoLineType()");
425  fSelectionSelect->Connect("Selected(const char*)","TParallelCoordEditor",
426  this, "DoSelectionSelect(const char*)");
427  fSelectLineColor->Connect("ColorSelected(Pixel_t)","TParallelCoordEditor",
428  this, "DoSelectLineColor(Pixel_t)");
429  fSelectLineWidth->Connect("Selected(Int_t)","TParallelCoordEditor",
430  this, "DoSelectLineWidth(Int_t)");
431  fActivateSelection->Connect("Toggled(Bool_t)","TParallelCoordEditor",
432  this, "DoActivateSelection(Bool_t)");
433  fShowRanges->Connect("Toggled(Bool_t)","TParallelCoordEditor",
434  this, "DoShowRanges(Bool_t)");
435  fDeleteSelection->Connect("Clicked()","TParallelCoordEditor",
436  this, "DoDeleteSelection()");
437  fAddSelection->Connect("Clicked()","TParallelCoordEditor",
438  this, "DoAddSelection()");
439  fPaintEntries->Connect("Toggled(Bool_t)","TParallelCoordEditor",
440  this, "DoPaintEntries(Bool_t)");
441  fEntriesToDraw->Connect("Released()","TParallelCoordEditor",
442  this, "DoEntriesToDraw()");
443  fEntriesToDraw->Connect("PositionChanged()","TParallelCoordEditor",
444  this, "DoLiveEntriesToDraw()");
445  fFirstEntry->Connect("ReturnPressed()","TParallelCoordEditor",
446  this, "DoFirstEntry()");
447  fNentries->Connect("ReturnPressed()","TParallelCoordEditor",
448  this, "DoNentries()");
449  fApplySelect->Connect("Clicked()","TParallelCoordEditor",
450  this, "DoApplySelect()");
451  fUnApply->Connect("Clicked()","TParallelCoordEditor",
452  this, "DoUnApply()");
453  fDelayDrawing->Connect("Toggled(Bool_t)","TParallelCoordEditor",
454  this, "DoDelayDrawing(Bool_t)");
455  fAddVariable->Connect("ReturnPressed()","TParallelCoordEditor",
456  this, "DoAddVariable()");
457  fButtonAddVar->Connect("Clicked()","TParallelCoordEditor",
458  this, "DoAddVariable()");
459  fHideAllRanges->Connect("Toggled(Bool_t)","TParallelCoordEditor",
460  this, "DoHideAllRanges(Bool_t)");
461  fVariables->Connect("Selected(const char*)","TParallelCoordEditor",
462  this, "DoVariableSelect(const char*)");
463  fDeleteVar->Connect("Clicked()","TParallelCoordEditor",
464  this, "DoDeleteVar()");
465  fHistWidth->Connect("ReturnPressed()","TParallelCoordEditor",
466  this, "DoHistWidth()");
467  fHistBinning->Connect("ReturnPressed()","TParallelCoordEditor",
468  this, "DoHistBinning()");
469  fWeightCut->Connect("Released()","TParallelCoordEditor",
470  this, "DoWeightCut()");
471  fWeightCut->Connect("PositionChanged(Int_t)","TParallelCoordEditor",
472  this, "DoLiveWeightCut(Int_t)");
473  fWeightCutField->Connect("ReturnPressed()","TParallelCoordEditor",
474  this, "DoWeightCut()");
475  fHistColorSelect->Connect("ColorSelected(Pixel_t)", "TParallelCoordEditor",
476  this, "DoHistColorSelect(Pixel_t)");
477  fHistPatternSelect->Connect("PatternSelected(Style_t)", "TParallelCoordEditor",
478  this, "DoHistPatternSelect(Style_t)");
479  fHistShowBoxes->Connect("Toggled(Bool_t)","TParallelCoordEditor",
480  this, "DoHistShowBoxes(Bool_t)");
481 
482  fInit = kFALSE;
483 }
484 
485 ////////////////////////////////////////////////////////////////////////////////
486 /// Slot to activate or not a selection.
487 
488 void TParallelCoordEditor::DoActivateSelection(Bool_t on)
489 {
490  if (fAvoidSignal) return;
491 
492  TParallelCoordSelect* sel = fParallel->GetCurrentSelection();
493  if (sel) {
494  sel->SetActivated(on);
495  Update();
496  }
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// Slot to add a selection.
501 
502 void TParallelCoordEditor::DoAddSelection()
503 {
504  TString title = fAddSelectionField->GetText();
505  if (title == "") title = "Selection";
506  TString titlebis = title;
507  Bool_t found = kTRUE;
508  Int_t i=1;
509  while (found){
510  if (fSelectionSelect->FindEntry(titlebis)) {
511  titlebis = title;
512  titlebis.Append(Form("(%d)",i));
513  }
514  else found = kFALSE;
515  ++i;
516  }
517 
518  fParallel->AddSelection(titlebis.Data());
519 
520  CleanUpSelections();
521 }
522 
523 ////////////////////////////////////////////////////////////////////////////////
524 /// Slot to add a variable.
525 
526 void TParallelCoordEditor::DoAddVariable()
527 {
528  if (fAvoidSignal) return;
529 
530  fParallel->AddVariable(fAddVariable->GetText());
531  CleanUpVariables();
532  Update();
533 }
534 
535 ////////////////////////////////////////////////////////////////////////////////
536 /// Slot to apply a selection to the tree.
537 
538 void TParallelCoordEditor::DoApplySelect()
539 {
540  //FIXME I forgot to update the slider over the entries
541  // (nentries and firstentry might have changed after applying the selection)
542 
543  if (fAvoidSignal) return;
544 
545  fParallel->ApplySelectionToTree();
546  Update();
547  SetModel(fParallel);
548 }
549 
550 ////////////////////////////////////////////////////////////////////////////////
551 /// Slot to delay the drawing.
552 
553 void TParallelCoordEditor::DoDelayDrawing(Bool_t on)
554 {
555  if (fAvoidSignal) return;
556 
557  fDelay = on;
558  fParallel->SetLiveRangesUpdate(!on);
559 }
560 
561 ////////////////////////////////////////////////////////////////////////////////
562 /// Slot to delete a selection.
563 
564 void TParallelCoordEditor::DoDeleteSelection()
565 {
566  if (fAvoidSignal) return;
567 
568  fParallel->DeleteSelection(fParallel->GetCurrentSelection());
569 
570  CleanUpSelections();
571  Update();
572 }
573 
574 ////////////////////////////////////////////////////////////////////////////////
575 /// Slot to delete a variable().
576 
577 void TParallelCoordEditor::DoDeleteVar()
578 {
579  if (fAvoidSignal) return;
580 
581  Bool_t hasDeleted = fParallel->RemoveVariable(((TGTextLBEntry*)fVariables->GetSelectedEntry())->GetTitle());
582  CleanUpVariables();
583  if (hasDeleted) Update();
584 }
585 
586 ////////////////////////////////////////////////////////////////////////////////
587 /// Slot to set the line dotspacing.
588 
589 void TParallelCoordEditor::DoDotsSpacing()
590 {
591  if (fAvoidSignal) return;
592 
593  fParallel->SetDotsSpacing(fDotsSpacing->GetPosition());
594  fDotsSpacingField->SetNumber((Int_t)fDotsSpacing->GetPosition());
595  Update();
596 }
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 /// Slot to set the line dotspacing from the entry field.
600 
601 void TParallelCoordEditor::DoDotsSpacingField()
602 {
603  if (fAvoidSignal) return;
604 
605  fParallel->SetDotsSpacing((Int_t)fDotsSpacingField->GetNumber());
606  fDotsSpacing->SetPosition((Int_t)fDotsSpacingField->GetNumber());
607  Update();
608 }
609 
610 ////////////////////////////////////////////////////////////////////////////////
611 /// Slot to set the alpha value from the entry field.
612 
613 void TParallelCoordEditor::DoAlphaField()
614 {
615  if (fAvoidSignal) return;
616 
617  if (TColor *color = gROOT->GetColor(fParallel->GetLineColor())) {
618  color->SetAlpha((Float_t)fAlphaField->GetNumber());
619  fAlpha->SetPosition((Int_t)fAlphaField->GetNumber()*1000);
620  }
621  Update();
622 }
623 
624 ////////////////////////////////////////////////////////////////////////////////
625 /// Slot to set the alpha value
626 
627 void TParallelCoordEditor::DoAlpha()
628 {
629  if (fAvoidSignal) return;
630 
631  if (TColor *color = gROOT->GetColor(fParallel->GetLineColor())) {
632  color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
633  fAlphaField->SetNumber((Float_t)fAlpha->GetPosition()/1000);
634  }
635  Update();
636 }
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// Slot to select the entries to be drawn.
640 
641 void TParallelCoordEditor::DoEntriesToDraw()
642 {
643  if (fAvoidSignal) return;
644 
645  Long64_t nentries,firstentry;
646  firstentry = (Long64_t)fEntriesToDraw->GetMinPosition();
647  nentries = (Long64_t)(fEntriesToDraw->GetMaxPosition() - fEntriesToDraw->GetMinPosition() + 1);
648 
649  fParallel->SetCurrentFirst(firstentry);
650  fParallel->SetCurrentN(nentries);
651  Update();
652 }
653 
654 ////////////////////////////////////////////////////////////////////////////////
655 /// Slot to set the first entry.
656 
657 void TParallelCoordEditor::DoFirstEntry()
658 {
659  if (fAvoidSignal) return;
660 
661  fParallel->SetCurrentFirst((Long64_t)fFirstEntry->GetNumber());
662  fEntriesToDraw->SetPosition((Long64_t)fFirstEntry->GetNumber(),(Long64_t)fFirstEntry->GetNumber()+fParallel->GetCurrentN());
663  Update();
664 }
665 
666 ////////////////////////////////////////////////////////////////////////////////
667 /// Slot to set the global line color.
668 
669 void TParallelCoordEditor::DoGlobalLineColor(Pixel_t a)
670 {
671  if (fAvoidSignal) return;
672 
673  if (TColor *color = gROOT->GetColor(fParallel->GetLineColor())) {
674  color->SetAlpha(1);
675  color = gROOT->GetColor(TColor::GetColor(a));
676  if (color) {
677  color->SetAlpha((Float_t)fAlphaField->GetNumber());
678  fParallel->SetLineColor(color->GetNumber());
679  }
680  }
681  Update();
682 }
683 
684 ////////////////////////////////////////////////////////////////////////////////
685 /// Slot to set the global line width.
686 
687 void TParallelCoordEditor::DoGlobalLineWidth(Int_t wid)
688 {
689  if (fAvoidSignal) return;
690 
691  fParallel->SetLineWidth(wid);
692  Update();
693 }
694 
695 ////////////////////////////////////////////////////////////////////////////////
696 /// Slot to hide all the ranges.
697 
698 void TParallelCoordEditor::DoHideAllRanges(Bool_t on)
699 {
700  if (fAvoidSignal) return;
701 
702  TIter next(fParallel->GetSelectList());
703  TParallelCoordSelect* sel;
704  while((sel = (TParallelCoordSelect*)next())) sel->SetShowRanges(!on);
705  fShowRanges->SetOn(!on);
706  fShowRanges->SetEnabled(!on);
707  fShowRanges->SetOn(!on);
708  Update();
709 }
710 
711 ////////////////////////////////////////////////////////////////////////////////
712 /// Slot to set the axes histogram binning.
713 
714 void TParallelCoordEditor::DoHistBinning()
715 {
716  if (fAvoidSignal) return;
717 
718  fParallel->SetAxisHistogramBinning((Int_t)fHistBinning->GetNumber());
719  Update();
720 }
721 
722 ////////////////////////////////////////////////////////////////////////////////
723 /// Slot to set the histograms color.
724 
725 void TParallelCoordEditor::DoHistColorSelect(Pixel_t p)
726 {
727  if (fAvoidSignal) return;
728 
729  Color_t col = TColor::GetColor(p);
730  TIter next(fParallel->GetVarList());
731  TParallelCoordVar *var = NULL;
732  while ((var = (TParallelCoordVar*)next())) var->SetFillColor(col);
733  Update();
734 }
735 
736 ////////////////////////////////////////////////////////////////////////////////
737 /// Slot to set histogram height.
738 
739 void TParallelCoordEditor::DoHistShowBoxes(Bool_t s)
740 {
741  if (fAvoidSignal) return;
742 
743  TIter next(fParallel->GetVarList());
744  TParallelCoordVar* var;
745  while ((var = (TParallelCoordVar*)next())) var->SetBit(TParallelCoordVar::kShowBarHisto,s);
746  Update();
747 }
748 
749 ////////////////////////////////////////////////////////////////////////////////
750 /// Slot to set the histograms fill style.
751 
752 void TParallelCoordEditor::DoHistPatternSelect(Style_t sty)
753 {
754  if (fAvoidSignal) return;
755 
756  TIter next(fParallel->GetVarList());
757  TParallelCoordVar *var = NULL;
758  while ((var = (TParallelCoordVar*)next())) var->SetFillStyle(sty);
759  Update();
760 }
761 
762 ////////////////////////////////////////////////////////////////////////////////
763 /// Slot to set histogram width.
764 
765 void TParallelCoordEditor::DoHistWidth()
766 {
767  if (fAvoidSignal) return;
768 
769  fParallel->SetAxisHistogramLineWidth((Int_t)fHistWidth->GetNumber());
770  Update();
771 }
772 
773 ////////////////////////////////////////////////////////////////////////////////
774 /// Slot to set the line type.
775 
776 void TParallelCoordEditor::DoLineType()
777 {
778  if (fAvoidSignal) return;
779 
780  if (fLineTypePoly->GetState() == kButtonDown) fParallel->SetCurveDisplay(kFALSE);
781  else fParallel->SetCurveDisplay(kTRUE);
782  Update();
783 }
784 
785 ////////////////////////////////////////////////////////////////////////////////
786 /// Slot to set the dots spacing online.
787 
788 void TParallelCoordEditor::DoLiveDotsSpacing(Int_t a)
789 {
790  if (fAvoidSignal) return;
791  fDotsSpacingField->SetNumber(a);
792  fParallel->SetDotsSpacing(a);
793  if (!fDelay) Update();
794 }
795 
796 ////////////////////////////////////////////////////////////////////////////////
797 /// Slot to set alpha value online.
798 
799 void TParallelCoordEditor::DoLiveAlpha(Int_t a)
800 {
801  if (fAvoidSignal) return;
802  fAlphaField->SetNumber((Float_t)a/1000);
803 
804  if (TColor *color = gROOT->GetColor(fParallel->GetLineColor())) color->SetAlpha((Float_t)a/1000);
805  if (!fDelay) Update();
806 }
807 
808 ////////////////////////////////////////////////////////////////////////////////
809 /// Slot to update the entries fields from the slider position.
810 
811 void TParallelCoordEditor::DoLiveEntriesToDraw()
812 {
813  if (fAvoidSignal) return;
814 
815  Long64_t nentries,firstentry;
816  firstentry = (Long64_t)fEntriesToDraw->GetMinPosition();
817  nentries = (Long64_t)(fEntriesToDraw->GetMaxPosition() - fEntriesToDraw->GetMinPosition() + 1);
818 
819  fFirstEntry->SetNumber(firstentry);
820  fNentries->SetNumber(nentries);
821 
822  if (!fDelay) {
823  fParallel->SetCurrentFirst(firstentry);
824  fParallel->SetCurrentN(nentries);
825  Update();
826  }
827 }
828 
829 ////////////////////////////////////////////////////////////////////////////////
830 /// Slot to update the wieght cut entry field from the slider position.
831 
832 void TParallelCoordEditor::DoLiveWeightCut(Int_t n)
833 {
834  if (fAvoidSignal) return;
835 
836  fWeightCutField->SetNumber(n);
837  if (!fDelay) {
838  fParallel->SetWeightCut(n);
839  Update();
840  }
841 }
842 
843 ////////////////////////////////////////////////////////////////////////////////
844 /// Slot to set the number of entries to display.
845 
846 void TParallelCoordEditor::DoNentries()
847 {
848  if (fAvoidSignal) return;
849 
850  fParallel->SetCurrentN((Long64_t)fNentries->GetNumber());
851  fEntriesToDraw->SetPosition(fParallel->GetCurrentFirst(),fParallel->GetCurrentFirst()+fParallel->GetCurrentN());
852  Update();
853 }
854 
855 ////////////////////////////////////////////////////////////////////////////////
856 /// Slot to postpone the entries drawing.
857 
858 void TParallelCoordEditor::DoPaintEntries(Bool_t on)
859 {
860  if (fAvoidSignal) return;
861 
862  fParallel->SetBit(TParallelCoord::kPaintEntries,on);
863  Update();
864 }
865 
866 ////////////////////////////////////////////////////////////////////////////////
867 /// Slot to set the line color of selection.
868 
869 void TParallelCoordEditor::DoSelectLineColor(Pixel_t a)
870 {
871  if (fAvoidSignal) return;
872 
873  TParallelCoordSelect* sel = fParallel->GetCurrentSelection();
874  if (sel) sel->SetLineColor(TColor::GetColor(a));
875  fSelectionSelect->GetSelectedEntry()->SetBackgroundColor(a);
876  Update();
877 }
878 
879 ////////////////////////////////////////////////////////////////////////////////
880 /// Slot to set the line width of selection.
881 
882 void TParallelCoordEditor::DoSelectLineWidth(Int_t wid)
883 {
884  if (fAvoidSignal) return;
885 
886  TParallelCoordSelect* sel = fParallel->GetCurrentSelection();
887  if (sel) {
888  sel->SetLineWidth(wid);
889  Update();
890  }
891 }
892 
893 ////////////////////////////////////////////////////////////////////////////////
894 /// Slot to set the selection beeing edited.
895 
896 void TParallelCoordEditor::DoSelectionSelect(const char* title)
897 {
898  if (fAvoidSignal) return;
899 
900  if (!fParallel->SetCurrentSelection(title)) return;
901 
902  Color_t c = fParallel->GetCurrentSelection()->GetLineColor();
903  Pixel_t p = TColor::Number2Pixel(c);
904  fSelectLineColor->SetColor(p,kFALSE);
905 
906  fSelectLineWidth->Select(fParallel->GetCurrentSelection()->GetLineWidth(),kFALSE);
907 
908  fActivateSelection->SetOn(fParallel->GetCurrentSelection()->TestBit(TParallelCoordSelect::kActivated));
909  fShowRanges->SetOn(fParallel->GetCurrentSelection()->TestBit(TParallelCoordSelect::kShowRanges));
910 }
911 
912 ////////////////////////////////////////////////////////////////////////////////
913 /// Slot to show or not the ranges on the pad.
914 
915 void TParallelCoordEditor::DoShowRanges(Bool_t s)
916 {
917  if (fAvoidSignal) return;
918 
919  TParallelCoordSelect *select = fParallel->GetCurrentSelection();
920  if (select) {
921  select->SetShowRanges(s);
922  Update();
923  }
924 }
925 
926 ////////////////////////////////////////////////////////////////////////////////
927 /// Slot to reset the tree entry list to the original one.
928 
929 void TParallelCoordEditor::DoUnApply()
930 {
931  if (fAvoidSignal) return;
932 
933  fParallel->ResetTree();
934  Update();
935  SetModel(fParallel);
936 }
937 
938 ////////////////////////////////////////////////////////////////////////////////
939 /// Slot to select a variable.
940 
941 void TParallelCoordEditor::DoVariableSelect(const char* /*var*/)
942 {
943 }
944 
945 ////////////////////////////////////////////////////////////////////////////////
946 /// Slot to update the weight cut.
947 
948 void TParallelCoordEditor::DoWeightCut()
949 {
950  if (fAvoidSignal) return;
951 
952  Int_t n = (Int_t)fWeightCutField->GetNumber();
953  fParallel->SetWeightCut(n);
954  Update();
955 }
956 
957 ////////////////////////////////////////////////////////////////////////////////
958 /// Pick up the used parallel coordinates plot attributes.
959 
960 void TParallelCoordEditor::SetModel(TObject* obj)
961 {
962  if (!obj) return;
963  fParallel = dynamic_cast<TParallelCoord*>(obj);
964  if (!fParallel) return;
965  fAvoidSignal = kTRUE;
966 
967  Color_t c = fParallel->GetLineColor();
968  Pixel_t p = TColor::Number2Pixel(c);
969  fGlobalLineColor->SetColor(p);
970 
971  fGlobalLineWidth->Select(fParallel->GetLineWidth());
972 
973  fPaintEntries->SetOn(fParallel->TestBit(TParallelCoord::kPaintEntries));
974 
975  if (!TCanvas::SupportAlpha()) {
976  fDotsSpacing->SetPosition(fParallel->GetDotsSpacing());
977  fDotsSpacingField->SetNumber(fParallel->GetDotsSpacing());
978  }
979  else {
980  if (TColor *color = gROOT->GetColor(fParallel->GetLineColor())) {
981  fAlpha->SetPosition((Int_t)color->GetAlpha()*1000);
982  fAlphaField->SetNumber(color->GetAlpha());
983  }
984  }
985 
986  Bool_t cur = fParallel->GetCurveDisplay();
987  if (cur) fLineTypeBgroup->SetButton(kLineTypeCurves,kTRUE);
988  else fLineTypeBgroup->SetButton(kLineTypePoly,kTRUE);
989 
990  if (fInit) fHideAllRanges->SetOn(kFALSE);
991 
992  CleanUpSelections();
993  CleanUpVariables();
994 
995  if (fInit) fEntriesToDraw->SetRange(0,fParallel->GetNentries());
996  fEntriesToDraw->SetPosition(fParallel->GetCurrentFirst(), fParallel->GetCurrentFirst()+fParallel->GetCurrentN());
997 
998  fFirstEntry->SetNumber(fParallel->GetCurrentFirst());
999  fNentries->SetNumber(fParallel->GetCurrentN());
1000 
1001  fDelayDrawing->SetOn(fDelay);
1002 
1003  fWeightCut->SetRange(0,(Int_t)(fParallel->GetNentries()/10)); // Maybe search here for better boundaries.
1004  fWeightCut->SetPosition(fParallel->GetWeightCut());
1005  fWeightCutField->SetNumber(fParallel->GetWeightCut());
1006 
1007  fHistColorSelect->SetColor(TColor::Number2Pixel(((TParallelCoordVar*)fParallel->GetVarList()->Last())->GetFillColor()), kFALSE);
1008  fHistPatternSelect->SetPattern(((TParallelCoordVar*)fParallel->GetVarList()->Last())->GetFillStyle(),kFALSE);
1009 
1010  if (fInit) ConnectSignals2Slots();
1011 
1012  fAvoidSignal = kFALSE;
1013 }