GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCanvas.h
Go to the documentation of this file.
1 #ifndef GRUTCANVAS_H
2 #define GRUTCANVAS_H
3 
4 #include "TROOT.h"
5 #include "TCanvas.h"
6 #include "TRootCanvas.h"
7 //#include "TPeak.h"
8 
9 #include "TH1.h"
10 #include "TLine.h"
11 
12 class GMarker : public TObject{
13  public:
14  GMarker():x(-1),y(-1),linex(0),liney(0),localx(0.0),localy(0.0) { }
15  GMarker(const GMarker &m) { ((GMarker&)m).Copy(*this); }
16  virtual ~GMarker() { if(linex) linex->Delete(); if(liney) liney->Delete(); }
17  int x;
18  int y;
19  double localx;
20  double localy;
21  TLine *linex;
22  TLine *liney;
23  void Copy(TObject &object) const;
24  bool operator<(const GMarker &rhs) const { return x < rhs.x; }
25  ClassDef(GMarker,0)
26 };
27 
28 
29 
30 class GCanvas : public TCanvas {
31  public:
32  GCanvas(Bool_t build = kTRUE);
33  GCanvas(const char* name, const char* title = "", Int_t form = 1);
34  GCanvas(const char* name, const char* title, Int_t ww, Int_t wh);
35  GCanvas(const char* name, Int_t ww, Int_t wh, Int_t winid);
36  GCanvas(const char* name, const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
37  virtual ~GCanvas();
38 
39  //void ProcessEvent(Int_t event,Int_t x,Int_t y,TObject *obj);
40  //void CatchEvent(Int_t event,Int_t x,Int_t y,TObject *obj);
41  void HandleInput(Int_t event,Int_t x,Int_t y);
42  void Draw(Option_t *opt="");
43 
44  static GCanvas *MakeDefCanvas();
45 
46  Int_t GetNMarkers() { return fMarkers.size(); }
47  //Int_t GetNBG_Markers() { return fBG_Markers.size(); }
48  void SetMarkerMode(bool flag=true) { fMarkerMode = flag; }
49 
50  //static void SetBackGroundSubtractionType();
51 
52  TF1 *GetLastFit();
53  private:
54  void GCanvasInit();
55 
56  void UpdateStatsInfo(int,int);
57 
58  static int lastx;
59  static int lasty;
60 
61  //bool fStatsDisplayed;
63  std::vector<GMarker*> fMarkers;
64  void AddMarker(int,int,int dim=1);
65  void RemoveMarker(Option_t *opt="");
66  void OrderMarkers();
67 
68  //std::vector<GMarker*> fBG_Markers;
69  //void AddBGMarker(GMarker *mark);
70  //void RemoveBGMarker();
71  //void ClearBGMarkers();
72  //void OrderBGMarkers();
73 
74  std::vector<TH1*> FindHists(int dim=1);
75  std::vector<TH1*> FindAllHists();
76 
77  public:
78  //void HandleKeyPress(int event,int x,int y,TObject *obj);
79  bool HandleArrowKeyPress(Event_t *event,UInt_t *keysym);
80  bool HandleKeyboardPress(Event_t *event,UInt_t *keysym);
81  bool HandleMousePress(Int_t event,Int_t x,Int_t y);
82 
83  //private:
84 
85  bool Process1DArrowKeyPress(Event_t *event,UInt_t *keysym);
86  bool Process1DKeyboardPress(Event_t *event,UInt_t *keysym);
87  bool Process1DMousePress(Int_t event,Int_t x,Int_t y);
88 
89  bool Process2DArrowKeyPress(Event_t *event,UInt_t *keysym);
90  bool Process2DKeyboardPress(Event_t *event,UInt_t *keysym);
91  bool Process2DMousePress(Int_t event,Int_t x,Int_t y);
92 
93  //bool SetBackGround(GMarker *m1=0,GMarker *m2=0,GMarker *m3=0,GMarker *m4=0);
94  //bool SetLinearBG(GMarker *m1=0,GMarker *m2=0);
95  //bool SetConstantBG(); //GMarker *m1=0,GMarker *m2=0);
96  //bool SetBGGate(GMarker *m1,GMarker *m2,GMarker *m3=0,GMarker *m4=0);
97 
98  //TH1 *GetBackGroundHist(GMarker *addlow,GMarker *addhigh);
99 
100  //bool GausFit(GMarker *m1=0,GMarker *m2=0);
101  //bool GausBGFit(GMarker *m1=0,GMarker *m2=0);
102  //bool PeakFit(GMarker *m1=0,GMarker *m2=0);
103  //bool PeakFitQ(GMarker *m1=0,GMarker *m2=0);
104 
105  //static int fBGSubtraction_type;
106  private:
107  Window_t fCanvasWindowID;
108  TRootCanvas *fRootCanvas;
109 
111 
113 
114  ClassDef(GCanvas,2);
115 };
116 
117 #endif