ROOT logo
// @(#)root/treeviewer:$Id: TParallelCoord.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Bastien Dalla Piazza  02/08/2007

/*************************************************************************
 * 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_TParallelCoord
#define ROOT_TParallelCoord

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

class TTree;
class TPaveText;
class TEntryList;
class TParallelCoordSelect;
class TParallelCoordVar;
class TParallelCoordRange;
class TList;
class TGaxis;
class TSelectorDraw;

class TParallelCoord : public TNamed {
public:
   enum {
      kVertDisplay      =BIT(14),      // If the axes are drawn vertically, false if horizontally.
      kCurveDisplay     =BIT(15),      // If the polylines are replaced by interpolated curves.
      kPaintEntries     =BIT(16),      // To prentry the TParallelCoord to paint all the entries.
      kLiveUpdate       =BIT(17),      // To paint the entries when being modified.
      kGlobalScale      =BIT(19),      // Every variable is on the same scale.
      kCandleChart      =BIT(20),      // To produce a candle chart.
      kGlobalLogScale   =BIT(21)       // Every variable in log scale.
   };

private:
   UInt_t          fNvar;              // Number of variables.
   Long64_t        fCurrentFirst;      // First entry to display.
   Long64_t        fCurrentN;          // Number of entries to display.
   Long64_t        fNentries;          // Number of entries;
   Int_t           fDotsSpacing;       // Spacing between dots to draw the entries.
   Color_t         fLineColor;         // entries line color.
   Width_t         fLineWidth;         // entries line width.
   Int_t           fWeightCut;         // Specify a cut on the entries from their weight (see TParallelCoordVar::GetEvtWeight(Long64_t))
   TEntryList     *fCurrentEntries;    //-> Current selected entries in the tree.
   TEntryList     *fInitEntries;       //-> Selected entries when TParallelCoord first initialized.
   TTree          *fTree;              //! Pointer to the TTree.
   TString         fTreeName;          // Name of the tree.
   TString         fTreeFileName;      // Name of the file containing the tree.
   TList          *fVarList;           // List of the variables.
   TList          *fSelectList;        // List of selections over the variables.
   TParallelCoordSelect* fCurrentSelection; //! Current Selection being edited.
   TGaxis         *fCandleAxis;        //! An axis used when displaying a candle chart.

   void            Init();
   void            PaintEntries(TParallelCoordSelect* sel=NULL);
   void            SetAxesPosition();

public:
   TParallelCoord();
   TParallelCoord(Long64_t nentries);
   TParallelCoord(TTree* tree, Long64_t nentries);
   ~TParallelCoord();

   void           AddVariable(Double_t* val, const char* title="");
   void           AddVariable(const char* varexp);
   void           AddSelection(const char* title);
   void           ApplySelectionToTree(); // *MENU*
   static void    BuildParallelCoord(TSelectorDraw* selector, Bool_t candle);
   void           CleanUpSelections(TParallelCoordRange* range);
   void           RemoveVariable(TParallelCoordVar* var);
   TParallelCoordVar* RemoveVariable(const char* var);
   void           DeleteSelection(TParallelCoordSelect* sel);
   virtual Int_t  DistancetoPrimitive(Int_t px, Int_t py);
   virtual void   Draw(Option_t* options="");
   virtual void   ExecuteEvent(Int_t entry, Int_t px, Int_t py);
   Bool_t         GetCandleChart() {return TestBit(kCandleChart);}
   Long64_t       GetCurrentFirst() {return fCurrentFirst;}
   Long64_t       GetCurrentN() {return fCurrentN;}
   TParallelCoordSelect* GetCurrentSelection();
   Bool_t         GetCurveDisplay() const {return TestBit(kCurveDisplay);}
   Int_t          GetDotsSpacing() const {return fDotsSpacing;}
   TEntryList    *GetEntryList(Bool_t sel=kTRUE);
   Double_t       GetGlobalMin();
   Double_t       GetGlobalMax();
   Bool_t         GetGlobalScale() {return TestBit(kGlobalScale);}
   Bool_t         GetGlobalLogScale() {return TestBit(kGlobalLogScale);}
   Color_t        GetLineColor() {return fLineColor;}
   Width_t        GetLineWidth() {return fLineWidth;}
   Int_t          GetNbins();
   UInt_t         GetNvar() {return fNvar;}
   Long64_t       GetNentries() {return fNentries;}
   TList         *GetSelectList() {return fSelectList;}
   TParallelCoordSelect* GetSelection(const char* title);
   TTree         *GetTree();
   Double_t      *GetVariable(const char* var);
   Double_t      *GetVariable(Int_t i);
   TList         *GetVarList() {return fVarList;}
   Bool_t         GetVertDisplay() const {return TestBit(kVertDisplay);}
   Int_t          GetWeightCut() const {return fWeightCut;};
   virtual void   Paint(Option_t* options="");
   void           ResetTree();
   void           SaveEntryLists(const char* filename="", Bool_t overwrite=kFALSE); // *MENU*
   void           SavePrimitive(ostream & out,Option_t *options);
   void           SaveTree(const char* filename="", Bool_t overwrite=kFALSE); // *MENU*
   void           SetAxisHistogramBinning(Int_t n=100); // *MENU*
   void           SetAxisHistogramHeight(Double_t h=0.5); // *MENU*
   void           SetAxisHistogramLineWidth(Int_t lw=2); // *MENU*
   void           SetCandleChart(Bool_t can); // *TOGGLE* *GETTER=GetCandleChart
   virtual void   SetCurveDisplay(Bool_t curve=1) {SetBit(kCurveDisplay,curve);} // *TOGGLE* *GETTER=GetCurveDisplay
   void           SetCurrentEntries(TEntryList* entries) {fCurrentEntries = entries;}
   void           SetCurrentFirst(Long64_t);
   void           SetCurrentN(Long64_t);
   TParallelCoordSelect* SetCurrentSelection(const char* title);
   void           SetCurrentSelection(TParallelCoordSelect* sel);
   void           SetDotsSpacing(Int_t s=0); // *MENU*
   static void    SetEntryList(TParallelCoord* para, TEntryList* enlist);
   void           SetGlobalScale(Bool_t gl); // *TOGGLE* *GETTER=GetGlobalScale
   void           SetGlobalLogScale(Bool_t); // *TOGGLE* *GETTER=GetGlobalLogScale
   void           SetGlobalMin(Double_t min);
   void           SetGlobalMax(Double_t max);
   void           SetInitEntries(TEntryList* entries) {fInitEntries = entries;}
   void           SetLineColor(Color_t col) {fLineColor = col;}
   void           SetLineWidth(Width_t wid) {fLineWidth = wid;}
   void           SetLiveRangesUpdate(Bool_t);
   void           SetNentries(Long64_t n) {fNentries = n;}
   void           SetTree(TTree* tree) {fTree = tree;}
   void           SetVertDisplay(Bool_t vert=kTRUE); // *TOGGLE* *GETTER=GetVertDisplay
   void           SetWeightCut(Int_t w=0) {fWeightCut = w;} // *MENU*
   void           UnzoomAll(); // *MENU*

   ClassDef(TParallelCoord,1); // To display parallel coordinates plots.
};

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