TSpiderEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/treeviewer:$Id: TSpiderEditor.cxx 36014 2010-10-01 13:47:13Z couet $
00002 // Author: Bastien Dalla Piazza  20/07/07
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TSpiderEditor.h"
00013 #include "TSpider.h"
00014 #include "TGFrame.h"
00015 #include "TGButton.h"
00016 #include "TGNumberEntry.h"
00017 #include "TGButtonGroup.h"
00018 #include <Riostream.h>
00019 #include "TGLabel.h"
00020 #include "TGPicture.h"
00021 #include "TGTextEntry.h"
00022 #include "TG3DLine.h"
00023 #include "TGComboBox.h"
00024 #include "TGColorSelect.h"
00025 #include "TGedPatternSelect.h"
00026 #include "TColor.h"
00027 
00028 //______________________________________________________________________________
00029 /* Begin_Html
00030 <center><h2>The TSpider editor class</h2></center>
00031 Provides the graphical user interface to the spider plots.
00032 End_Html */
00033 
00034 
00035 ClassImp(TSpiderEditor)
00036 
00037 enum ESpiderWid {
00038    kAverage,
00039    kNx,
00040    kNy,
00041    kPolyLines,
00042    kSegment,
00043    kGotoEntry,
00044    kNext,
00045    kPrevious,
00046    kFollowing,
00047    kPreceding,
00048    kAddVar,
00049    kDeleteVar,
00050    kAvLineStyle,
00051    kAvLineColor,
00052    kAvLineWidth,
00053    kAvFillColor,
00054    kAvFillStyle
00055 };
00056 
00057 //______________________________________________________________________________
00058 TSpiderEditor::TSpiderEditor(const TGWindow* /*p*/, Int_t /*width*/, Int_t /*height*/, UInt_t /*options*/, Pixel_t /*back*/)
00059 {
00060    // Normal constructor.
00061 
00062    fPriority = 1;
00063    MakeTitle("Spider");
00064 
00065    fBgroup = new TGButtonGroup(this,2,1,0,0, "Plot type");
00066    fBgroup->SetRadioButtonExclusive(kTRUE);
00067    fPolyLines = new TGRadioButton(fBgroup, "PolyLine", kPolyLines);
00068    fPolyLines->SetToolTipText("Set a polyline plot type");
00069    fSegment = new TGRadioButton(fBgroup, "Segment", kSegment);
00070    fSegment->SetToolTipText("Set a segment plot type");
00071    fBgroup->ChangeOptions(kFitWidth|kChildFrame);
00072    AddFrame(fBgroup, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 1, 0, 0));
00073 
00074    TGHorizontalFrame *f1 = new TGHorizontalFrame(this);
00075 
00076    TGLabel *nxLabel = new TGLabel(f1,"Nx:");
00077    f1->AddFrame(nxLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 1, 1));
00078    fSetNx = new TGNumberEntryField(f1, kNx, 2,
00079                                       TGNumberFormat::kNESInteger,
00080                                       TGNumberFormat::kNEAPositive,
00081                                       TGNumberFormat::kNELLimitMinMax, 0, 99);
00082    fSetNx->SetToolTipText("Set the X number of plots");
00083    fSetNx->Resize(30,20);
00084    f1->AddFrame(fSetNx, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00085 
00086    TGLabel *nyLabel = new TGLabel(f1,"Ny:");
00087    f1->AddFrame(nyLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 1, 1));
00088    fSetNy = new TGNumberEntryField(f1, kNy, 2,
00089                                       TGNumberFormat::kNESInteger,
00090                                       TGNumberFormat::kNEAPositive,
00091                                       TGNumberFormat::kNELLimitMinMax, 0, 99);
00092    fSetNy->SetToolTipText("Set the Y number of plots");
00093    fSetNy->Resize(30,20);
00094    f1->AddFrame(fSetNy, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00095    AddFrame(f1, new TGLayoutHints(kLHintsLeft,1,1,1,1));
00096 
00097    MakeTitle("Average");
00098 
00099    fDisplayAverage = new TGCheckButton(this, "Average",kAverage);
00100    fDisplayAverage->SetToolTipText("Display average");
00101    AddFrame(fDisplayAverage, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
00102 
00103    TGHorizontalFrame *f2 = new TGHorizontalFrame(this);
00104 
00105    fAvLineColorSelect = new TGColorSelect(f2, 0, kAvLineColor);
00106    f2->AddFrame(fAvLineColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00107 
00108    fAvLineWidthCombo = new TGLineWidthComboBox(f2, kAvLineWidth);
00109    fAvLineWidthCombo->Resize(91, 20);
00110    f2->AddFrame(fAvLineWidthCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
00111 
00112    AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00113 
00114    fAvLineStyleCombo = new TGLineStyleComboBox(this, kAvLineStyle);
00115    fAvLineStyleCombo->Resize(137, 20);
00116    AddFrame(fAvLineStyleCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
00117 
00118    TGHorizontalFrame *f2b = new TGHorizontalFrame(this);
00119 
00120    fAvFillColorSelect = new TGColorSelect(f2b, 0, kAvFillColor);
00121    f2b->AddFrame(fAvFillColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00122 
00123    fAvFillPatternSelect = new TGedPatternSelect(f2b, 1, kAvFillStyle);
00124    f2b->AddFrame(fAvFillPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00125 
00126    AddFrame(f2b, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00127 
00128    MakeBrowse();
00129 }
00130 
00131 
00132 //______________________________________________________________________________
00133 TSpiderEditor::~TSpiderEditor()
00134 {
00135    // Destructor of the TSpidereditor.
00136 
00137    delete fPolyLines;
00138    delete fSegment;
00139 }
00140 
00141 //______________________________________________________________________________
00142 void TSpiderEditor::ConnectSignals2Slots()
00143 {
00144    // Connect signals to slots.
00145 
00146    fDisplayAverage->Connect("Toggled(Bool_t)", "TSpiderEditor", this, "DoDisplayAverage(Bool_t)");
00147    fSetNx->Connect("ReturnPressed()", "TSpiderEditor", this, "DoSetNx()");
00148    fSetNy->Connect("ReturnPressed()", "TSpiderEditor", this, "DoSetNy()");
00149    fBgroup->Connect("Clicked(Int_t)","TSpiderEditor",this,"DoSetPlotType()");
00150    fGotoEntry->Connect("ReturnPressed()", "TSpiderEditor", this, "DoGotoEntry()");
00151    fGotoNext->Connect("Clicked()","TSpiderEditor",this,"DoGotoNext()");
00152    fGotoPrevious->Connect("Clicked()","TSpiderEditor",this,"DoGotoPrevious()");
00153    fGotoFollowing->Connect("Clicked()","TSpiderEditor",this,"DoGotoFollowing()");
00154    fGotoPreceding->Connect("Clicked()","TSpiderEditor",this,"DoGotoPreceding()");
00155    fAddVar->Connect("ReturnPressed()","TSpiderEditor",this,"DoAddVar()");
00156    fDeleteVar->Connect("ReturnPressed()","TSpiderEditor",this,"DoDeleteVar()");
00157    fAvLineStyleCombo->Connect("Selected(Int_t)", "TSpiderEditor", this, "DoAvLineStyle(Int_t)");
00158    fAvLineWidthCombo->Connect("Selected(Int_t)", "TSpiderEditor", this, "DoAvLineWidth(Int_t)");
00159    fAvLineColorSelect->Connect("ColorSelected(Pixel_t)", "TSpiderEditor", this, "DoAvLineColor(Pixel_t)");
00160    fAvFillColorSelect->Connect("ColorSelected(Pixel_t)", "TSpiderEditor", this, "DoAvFillColor(Pixel_t)");
00161    fAvFillPatternSelect->Connect("PatternSelected(Style_t)", "TSpiderEditor", this, "DoAvFillPattern(Style_t)");
00162 
00163    fInit = kFALSE;
00164 }
00165 
00166 
00167 //______________________________________________________________________________
00168 void TSpiderEditor::MakeBrowse()
00169 {
00170    // Make the Browse tab.
00171 
00172    fBrowse = CreateEditorTabSubFrame("Browse");
00173 
00174    TGHorizontalFrame *title1 = new TGHorizontalFrame(fBrowse);
00175    title1->AddFrame(new TGLabel(title1, "Entries"),
00176                     new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
00177    title1->AddFrame(new TGHorizontal3DLine(title1),
00178                     new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00179    fBrowse->AddFrame(title1, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
00180 
00181    TGHorizontalFrame *f3 = new TGHorizontalFrame(fBrowse);
00182 
00183    TGLabel *gotoEntryLabel = new TGLabel(f3,"Go to:");
00184    f3->AddFrame(gotoEntryLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 18, 1, 5));
00185    fGotoEntry = new TGNumberEntryField(f3, kGotoEntry, 0,
00186                                       TGNumberFormat::kNESInteger,
00187                                       TGNumberFormat::kNEANonNegative);
00188    fGotoEntry->SetToolTipText("Jump to a specified entry");
00189    fGotoEntry->Resize(60,20);
00190    f3->AddFrame(fGotoEntry, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
00191 
00192    fBrowse->AddFrame(f3,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
00193 
00194    TGHorizontalFrame *f2 = new TGHorizontalFrame(fBrowse);
00195 
00196    fPicPrevious = gClient->GetPicture("first_t.xpm");
00197    fGotoPrevious = new TGPictureButton(f2,fPicPrevious,kPrevious);
00198    fGotoPrevious->SetToolTipText("Jump to the last entries");
00199    f2->AddFrame(fGotoPrevious,new TGLayoutHints(kLHintsCenterX | kLHintsBottom, 1, 1, 1, 1));
00200 
00201    fPicPreceding = gClient->GetPicture("previous_t.xpm");
00202    fGotoPreceding = new TGPictureButton(f2,fPicPreceding,kPreceding);
00203    fGotoPreceding->SetToolTipText("Jump to the last entries");
00204    f2->AddFrame(fGotoPreceding,new TGLayoutHints(kLHintsCenterX | kLHintsBottom, 1, 1, 1, 1));
00205 
00206    fPicFollowing = gClient->GetPicture("next_t.xpm");
00207    fGotoFollowing = new TGPictureButton(f2,fPicFollowing,kFollowing);
00208    fGotoFollowing->SetToolTipText("Jump to the last entries");
00209    f2->AddFrame(fGotoFollowing,new TGLayoutHints(kLHintsCenterX | kLHintsBottom, 1, 1, 1, 1));
00210 
00211    fPicNext = gClient->GetPicture("last_t.xpm");
00212    fGotoNext = new TGPictureButton(f2,fPicNext,kNext);
00213    fGotoNext->SetToolTipText("Jump to the next entries");
00214    f2->AddFrame(fGotoNext,new TGLayoutHints(kLHintsCenterX | kLHintsBottom, 1, 1, 1, 1));
00215 
00216    fBrowse->AddFrame(f2,new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));
00217 
00218    TGHorizontalFrame *title2 = new TGHorizontalFrame(fBrowse);
00219 
00220    title2->AddFrame(new TGLabel(title2, "Variables"),
00221                     new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
00222    title2->AddFrame(new TGHorizontal3DLine(title2),
00223                     new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00224    fBrowse->AddFrame(title2, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
00225 
00226    TGHorizontalFrame *f4 = new TGHorizontalFrame(fBrowse);
00227 
00228    TGVerticalFrame *v1 = new TGVerticalFrame(f4);
00229 
00230    TGLabel *addVar = new TGLabel(v1,"Add:");
00231    v1->AddFrame(addVar,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
00232 
00233    TGLabel *deleteVar = new TGLabel(v1,"Delete:");
00234    v1->AddFrame(deleteVar,new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
00235 
00236    f4->AddFrame(v1, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,0,0));
00237 
00238    TGVerticalFrame *v2 = new TGVerticalFrame(f4);
00239 
00240    fAddVar = new TGTextEntry(v2, new TGTextBuffer(50), kAddVar);
00241    fAddVar->Resize(60,20);
00242    fAddVar->SetToolTipText("Add a variable");
00243    v2->AddFrame(fAddVar, new TGLayoutHints(kLHintsRight | kLHintsTop));
00244 
00245    fDeleteVar = new TGTextEntry(v2, new TGTextBuffer(50), kAddVar);
00246    fDeleteVar->Resize(60,20);
00247    fDeleteVar->SetToolTipText("Delete a variable");
00248    v2->AddFrame(fDeleteVar, new TGLayoutHints(kLHintsRight | kLHintsTop));
00249 
00250    f4->AddFrame(v2, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,0,0));
00251 
00252    fBrowse->AddFrame(f4, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
00253 }
00254 
00255 
00256 //______________________________________________________________________________
00257 void TSpiderEditor::SetModel(TObject* obj)
00258 {
00259    // Pick up the used spider attributes.
00260 
00261    if (!obj) return;
00262    fSpider = dynamic_cast<TSpider*>(obj);
00263    if (!fSpider) return;
00264    fAvoidSignal = kTRUE;
00265 
00266    Bool_t av = fSpider->GetDisplayAverage();
00267    if(av) fDisplayAverage->SetState(kButtonDown);
00268    else fDisplayAverage->SetState(kButtonUp);
00269 
00270    fSetNx->SetNumber(fSpider->GetNx());
00271    fSetNy->SetNumber(fSpider->GetNy());
00272 
00273    Bool_t seg = fSpider->GetSegmentDisplay();
00274 
00275    if(seg) fBgroup->SetButton(kSegment,kTRUE);
00276    else fBgroup->SetButton(kPolyLines,kTRUE);
00277 
00278    fGotoEntry->SetNumber(fSpider->GetCurrentEntry());
00279 
00280    fAddVar->SetText("");
00281    fDeleteVar->SetText("");
00282 
00283    fAvLineStyleCombo->Select(fSpider->GetAverageLineStyle());
00284    fAvLineWidthCombo->Select(fSpider->GetAverageLineWidth());
00285    Color_t c = fSpider->GetAverageLineColor();
00286    Pixel_t p = TColor::Number2Pixel(c);
00287    fAvLineColorSelect->SetColor(p);
00288    c = fSpider->GetAverageFillColor();
00289    p = TColor::Number2Pixel(c);
00290    fAvFillColorSelect->SetColor(p,kFALSE);
00291    fAvFillPatternSelect->SetPattern(fSpider->GetAverageFillStyle(),kFALSE);
00292 
00293    if (fInit) ConnectSignals2Slots();
00294 
00295    fAvoidSignal = kFALSE;
00296 }
00297 
00298 
00299 //______________________________________________________________________________
00300 void TSpiderEditor::DoAddVar()
00301 {
00302    // Slot to add a variable.
00303 
00304    if (fAvoidSignal) return;
00305 
00306    const char * var = fAddVar->GetText();
00307    fSpider->AddVariable(var);
00308    Update();
00309 }
00310 
00311 
00312 //______________________________________________________________________________
00313 void TSpiderEditor::DoAvLineStyle(Int_t a)
00314 {
00315    // Slot to set the average LineStyle.
00316 
00317    if (fAvoidSignal) return;
00318 
00319    fSpider->SetAverageLineStyle(a);
00320    Update();
00321 }
00322 
00323 
00324 //______________________________________________________________________________
00325 void TSpiderEditor::DoAvLineWidth(Int_t a)
00326 {
00327    // Slot to set the average LineWidth.
00328 
00329    if (fAvoidSignal) return;
00330 
00331    fSpider->SetAverageLineWidth(a);
00332    Update();
00333 }
00334 
00335 
00336 //______________________________________________________________________________
00337 void TSpiderEditor::DoAvLineColor(Pixel_t a)
00338 {
00339    // Slot to set the average LineColor.
00340 
00341    if (fAvoidSignal) return;
00342 
00343    fSpider->SetAverageLineColor(TColor::GetColor(a));
00344    Update();
00345 }
00346 
00347 
00348 //______________________________________________________________________________
00349 void TSpiderEditor::DoAvFillColor(Pixel_t a)
00350 {
00351    // Slot to set the average FillColor.
00352 
00353    if (fAvoidSignal) return;
00354 
00355    fSpider->SetAverageFillColor(TColor::GetColor(a));
00356    Update();
00357 }
00358 
00359 
00360 //______________________________________________________________________________
00361 void TSpiderEditor::DoAvFillPattern(Style_t a)
00362 {
00363    // Slot to set the average FillStyle.
00364 
00365    if (fAvoidSignal) return;
00366 
00367    fSpider->SetAverageFillStyle(a);
00368    Update();
00369 }
00370 
00371 
00372 //______________________________________________________________________________
00373 void TSpiderEditor::DoDeleteVar()
00374 {
00375    // Slot to delete a variable.
00376 
00377    if (fAvoidSignal) return;
00378 
00379    const char * var = fDeleteVar->GetText();
00380    fSpider->DeleteVariable(var);
00381    Update();
00382 }
00383 
00384 
00385 //______________________________________________________________________________
00386 void TSpiderEditor::DoDisplayAverage(Bool_t av)
00387 {
00388    // Slot Connected to the average display.
00389 
00390    if (fAvoidSignal) return;
00391 
00392    fSpider->SetDisplayAverage(av);
00393    Update();
00394 }
00395 
00396 
00397 //______________________________________________________________________________
00398 void  TSpiderEditor::DoGotoEntry()
00399 {
00400    // Slot to select an entry by number.
00401 
00402    if (fAvoidSignal) return;
00403    Long64_t ev = (Long64_t)fGotoEntry->GetNumber();
00404    fSpider->GotoEntry(ev);
00405    Update();
00406 }
00407 
00408 
00409 //______________________________________________________________________________
00410 void  TSpiderEditor::DoGotoNext()
00411 {
00412    // Slot to Go to next entries.
00413 
00414    if (fAvoidSignal) return;
00415    fSpider->GotoNext();
00416    Update();
00417 }
00418 
00419 
00420 //______________________________________________________________________________
00421 void  TSpiderEditor::DoGotoPrevious()
00422 {
00423    // Slot to go to previous entries.
00424 
00425    if (fAvoidSignal) return;
00426    fSpider->GotoPrevious();
00427    Update();
00428 }
00429 
00430 
00431 //______________________________________________________________________________
00432 void  TSpiderEditor::DoGotoFollowing()
00433 {
00434    // Slot to go to next entry.
00435 
00436    if (fAvoidSignal) return;
00437    fSpider->GotoFollowing();
00438    Update();
00439 }
00440 
00441 
00442 //______________________________________________________________________________
00443 void  TSpiderEditor::DoGotoPreceding()
00444 {
00445    // Slot to go to last entry.
00446 
00447    if (fAvoidSignal) return;
00448    fSpider->GotoPreceding();
00449    Update();
00450 }
00451 
00452 
00453 //______________________________________________________________________________
00454 void  TSpiderEditor::DoSetNx()
00455 {
00456    // Slot connected to the nx setting.
00457 
00458    if (fAvoidSignal) return;
00459    UInt_t nx = (UInt_t)fSetNx->GetNumber();
00460    fSpider->SetNx(nx);
00461    Update();
00462 }
00463 
00464 //______________________________________________________________________________
00465 void  TSpiderEditor::DoSetNy()
00466 {
00467    // Slot connected to the nx setting.
00468 
00469    if (fAvoidSignal) return;
00470    UInt_t ny = (UInt_t)fSetNy->GetNumber();
00471    fSpider->SetNy(ny);
00472    Update();
00473 }
00474 
00475 //______________________________________________________________________________
00476 void  TSpiderEditor::DoSetPlotType()
00477 {
00478    // Slot to set the plot type.
00479 
00480    if(fSegment->GetState() == kButtonDown) fSpider->SetSegmentDisplay(kTRUE);
00481    else fSpider->SetSegmentDisplay(kFALSE);
00482    Update();
00483 }

Generated on Tue Jul 5 15:43:46 2011 for ROOT_528-00b_version by  doxygen 1.5.1