ROOT logo
// @(#)root/treeviewer:$Id$
// Author: Bastien Dalla Piazza  20/07/07

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TSpider
#define ROOT_TSpider

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TSpider                                                              //
//                                                                      //
// TSpider is a manager used to paint a spider view                     //
// of the events of a TNtuple.                                          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_Object
#include "TObject.h"
#endif

#ifndef ROOT_TAttFill
#include "TAttFill.h"
#endif

#ifndef ROOT_TAttLine
#include "TAttLine.h"
#endif

#ifndef ROOT_TAttText
#include "TAttText.h"
#endif

class TTree;
class TGraphPolargram;
class TPolyLine;
class TTreeFormula;
class TTreeFormulaManager;
class TList;
class TSelectorDraw;
class TString;
class TLatex;
class TCanvas;
class TArc;

class TSpider : public TObject, public TAttFill, public TAttLine {
private:
   UInt_t                  fNx; // Number of horizontal spider plots.
   UInt_t                  fNy; // Number of vertical spider plots.
   UInt_t                  fNcols; // Number of variables.
   Int_t                   fArraySize; // Actual size of the arrays.
   Long64_t                fEntry; // Present entry number in fTree.
   Long64_t                fNentries; // Number of entries.
   Long64_t                fFirstEntry; // First entry.
   Long64_t*               fCurrentEntries; //![fNx*fNy] current selected entries;
   Double_t*               fAve; //[fNcols] Average value of each variable.
   Double_t*               fMax; //[fNcols]  Maximum value of the variables.
   Double_t*               fMin; //[fNcols]  Minimum value of the variables.
   TList*                  fSuperposed; // Superposed spider plots.
   TTree*                  fTree; // Pointer to the TTree to represent.
   TPolyLine*              fAveragePoly; // Polygon representing the average variables value.
   TArc**                  fAverageSlices; //! Average slices.
   TCanvas*                fCanvas; //! Pointer to the mother pad.
   TList*                  fFormulas; // List of all formulas to represent.
   TList*                  fInput; // Used for fSelector.
   TTreeFormulaManager*    fManager; // Coordinator for the formulas.
   TGraphPolargram*        fPolargram; // Polar graph.
   TList*                  fPolyList; // Polygons representing the variables.
   TTreeFormula*           fSelect; // Selection condition
   TSelectorDraw*          fSelector; //! Selector.
   Bool_t                  fAngularLabels; // True if the labels are oriented according to their axis.
   Bool_t                  fDisplayAverage; // Display or not the average.
   Bool_t                  fForceDim; // Force dimension.
   Bool_t                  fSegmentDisplay; // True if displaying a segment plot.
   Bool_t                  fShowRange; // Show range of variables or not.

   Int_t          FindTextAlign(Double_t theta);
   Double_t       FindTextAngle(Double_t theta);
   void           InitVariables(Long64_t firstentry, Long64_t nentries);
   void           DrawPoly(Option_t* options);
   void           DrawPolyAverage(Option_t* options);
   void           DrawSlices(Option_t* options);
   void           DrawSlicesAverage(Option_t* options);
   void           SyncFormulas();
   void           InitArrays(Int_t newsize);
   void           SetCurrentEntries();
   void           UpdateView();

public:
   TSpider();
   TSpider(TTree* tree, const char *varexp, const char *selection, Option_t *option="",
                  Long64_t nentries=0, Long64_t firstentry=0);
   ~TSpider();
   void           AddSuperposed(TSpider* sp);
   void           AddVariable(const char* varexp); // *MENU*
   void           DeleteVariable(const char* varexp); // *MENU*
   virtual void   Draw(Option_t *options="");
   virtual Int_t  DistancetoPrimitive(Int_t px, Int_t py);
   virtual void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
   Style_t        GetAverageLineStyle() const;
   Color_t        GetAverageLineColor() const;
   Width_t        GetAverageLineWidth() const;
   Color_t        GetAverageFillColor() const;
   Style_t        GetAverageFillStyle() const;
   Bool_t         GetDisplayAverage() const {return fDisplayAverage;}
   Long64_t       GetCurrentEntry() const {return fEntry;}
   Long64_t       GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const;
   Int_t          GetNx() const {return fNx;}
   Int_t          GetNy() const {return fNy;}
   Bool_t         GetSegmentDisplay() const {return fSegmentDisplay;}
   void           GotoEntry(Long64_t e); // *MENU*
   void           GotoNext(); // *MENU*
   void           GotoPrevious(); // *MENU*
   void           GotoFollowing(); // *MENU*
   void           GotoPreceding(); // *MENU*
   virtual void   Paint(Option_t *options);
   void           SetAverageLineStyle(Style_t sty);
   void           SetAverageLineColor(Color_t col);
   void           SetAverageLineWidth(Width_t wid);
   void           SetAverageFillColor(Color_t col);
   void           SetAverageFillStyle(Style_t sty);
   virtual void   SetLineStyle(Style_t sty);
   virtual void   SetLineColor(Color_t col);
   virtual void   SetLineWidth(Width_t wid);
   virtual void   SetFillColor(Color_t col);
   virtual void   SetFillStyle(Style_t sty);
   void           SetDisplayAverage(Bool_t disp); // *TOGGLE*
   void           SetVariablesExpression(const char* varexp);
   void           SetNdivRadial(Int_t div); // *MENU*
   void           SetNx(UInt_t nx); // *MENU*
   void           SetNy(UInt_t ny); // *MENU*
   void           SetSelectionExpression(const char* selexp);
   void           SetSegmentDisplay(Bool_t seg); // *TOGGLE*
   void           SetShowRange(Bool_t showrange) {fShowRange = showrange;}
   void           SuperposeTo(TSpider* sp) {sp->AddSuperposed(this);}

   ClassDef(TSpider,0)  //Helper class to draw spider
};

#endif
 TSpider.h:1
 TSpider.h:2
 TSpider.h:3
 TSpider.h:4
 TSpider.h:5
 TSpider.h:6
 TSpider.h:7
 TSpider.h:8
 TSpider.h:9
 TSpider.h:10
 TSpider.h:11
 TSpider.h:12
 TSpider.h:13
 TSpider.h:14
 TSpider.h:15
 TSpider.h:16
 TSpider.h:17
 TSpider.h:18
 TSpider.h:19
 TSpider.h:20
 TSpider.h:21
 TSpider.h:22
 TSpider.h:23
 TSpider.h:24
 TSpider.h:25
 TSpider.h:26
 TSpider.h:27
 TSpider.h:28
 TSpider.h:29
 TSpider.h:30
 TSpider.h:31
 TSpider.h:32
 TSpider.h:33
 TSpider.h:34
 TSpider.h:35
 TSpider.h:36
 TSpider.h:37
 TSpider.h:38
 TSpider.h:39
 TSpider.h:40
 TSpider.h:41
 TSpider.h:42
 TSpider.h:43
 TSpider.h:44
 TSpider.h:45
 TSpider.h:46
 TSpider.h:47
 TSpider.h:48
 TSpider.h:49
 TSpider.h:50
 TSpider.h:51
 TSpider.h:52
 TSpider.h:53
 TSpider.h:54
 TSpider.h:55
 TSpider.h:56
 TSpider.h:57
 TSpider.h:58
 TSpider.h:59
 TSpider.h:60
 TSpider.h:61
 TSpider.h:62
 TSpider.h:63
 TSpider.h:64
 TSpider.h:65
 TSpider.h:66
 TSpider.h:67
 TSpider.h:68
 TSpider.h:69
 TSpider.h:70
 TSpider.h:71
 TSpider.h:72
 TSpider.h:73
 TSpider.h:74
 TSpider.h:75
 TSpider.h:76
 TSpider.h:77
 TSpider.h:78
 TSpider.h:79
 TSpider.h:80
 TSpider.h:81
 TSpider.h:82
 TSpider.h:83
 TSpider.h:84
 TSpider.h:85
 TSpider.h:86
 TSpider.h:87
 TSpider.h:88
 TSpider.h:89
 TSpider.h:90
 TSpider.h:91
 TSpider.h:92
 TSpider.h:93
 TSpider.h:94
 TSpider.h:95
 TSpider.h:96
 TSpider.h:97
 TSpider.h:98
 TSpider.h:99
 TSpider.h:100
 TSpider.h:101
 TSpider.h:102
 TSpider.h:103
 TSpider.h:104
 TSpider.h:105
 TSpider.h:106
 TSpider.h:107
 TSpider.h:108
 TSpider.h:109
 TSpider.h:110
 TSpider.h:111
 TSpider.h:112
 TSpider.h:113
 TSpider.h:114
 TSpider.h:115
 TSpider.h:116
 TSpider.h:117
 TSpider.h:118
 TSpider.h:119
 TSpider.h:120
 TSpider.h:121
 TSpider.h:122
 TSpider.h:123
 TSpider.h:124
 TSpider.h:125
 TSpider.h:126
 TSpider.h:127
 TSpider.h:128
 TSpider.h:129
 TSpider.h:130
 TSpider.h:131
 TSpider.h:132
 TSpider.h:133
 TSpider.h:134
 TSpider.h:135
 TSpider.h:136
 TSpider.h:137
 TSpider.h:138
 TSpider.h:139
 TSpider.h:140
 TSpider.h:141
 TSpider.h:142
 TSpider.h:143
 TSpider.h:144
 TSpider.h:145
 TSpider.h:146