CXCanvas.h 3.79 KB
Newer Older
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//Author: jdudouet

#ifndef __CXCanvas_H
#define __CXCanvas_H

#include "TCanvas.h"
#include "TH2.h"
#include "TH1.h"
#include "TGFrame.h"
#include "TList.h"
#include "TGFileDialog.h"
#include "TSystem.h"
#include "TGClient.h"

class TGraph;
class CXMainWindow;
class CXCanvas : public TCanvas {

protected:

   CXMainWindow *fMainWindow = nullptr;

   Double_t xmin, xmax, ymin, ymax;
   Double_t oldx, oldy;
   Double_t xinit, yinit;
   //! variables for pan & scan
   Int_t X0, Y0;           //! coordinates of initial click in pad pixels
   Int_t NdisXbins, NdisYbins;      //! number of displayed bins on X & Y
   Int_t NXbins, Xfirst0, Xlast0;   //! number of bins on x-axis, initial displayed bins
   Int_t NYbins, Yfirst0, Ylast0;   //! number of bins on y-axis, initial displayed bins
   TAxis* theXaxis, *theYaxis;   //! the axes of the histogram
   Double_t XbinPixel, YbinPixel;   //! size of bins in pixels
   Int_t Xf1, Xl1, Yf1, Yl1;  //! last modification to axis limits

   Bool_t   moved1D = false;
   Bool_t   moved2D = false;
   Bool_t   fPPressed;
   Bool_t   fJPressed;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
39
   Bool_t   fAgeOfEmpireMode;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
40 41 42 43 44 45 46 47 48 49 50 51 52
   Bool_t   fVenerMode;
   Bool_t   fHasDisabledClasses;
   TString  fDisabledClasses;
   Bool_t   fHasDisabledObject;

   TList    fDisabledObjects;
   TList    fShortCuts;
   Int_t    fEnabledShortcuts;
   TString  fSavedAs;

   TGFrame* fKeyHandler;         //! handler for keys
   Bool_t   fFreezed;

53
   TBox *fZoomBox;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
54 55 56 57 58 59 60 61 62

   Int_t fLastX;
   Int_t fLastY;
   Int_t fLastEvent;
   TObject *fLastSelected;

   TH1 *fSelectedHisto;
   Float_t ScaleFact;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
63 64
   Int_t fNPads;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
public:
   CXCanvas();
//   using TCanvas::TCanvas;
   CXCanvas(const char* name, const char* title, Int_t ww, Int_t wh, Bool_t keyHandler = kTRUE);
   CXCanvas(const char* name, Int_t ww, Int_t wh, Int_t winid);
   virtual ~CXCanvas();

   void HandleInput(EEventType event, Int_t px, Int_t py);
   void EventProcessed(Event_t *ev, Window_t);

   Bool_t IsLogz();
   Bool_t IsLogy();
   Bool_t IsLogx();

   void DisableClass(const char* className);
   void DisableObject(TObject* obj);
   void ResetDisabledClass();
   void ResetDisabledObject();

   void SaveCanvasAs();
   TCanvas *GetTCanvas();

   void SetMainWindow(CXMainWindow *w);

   TH1 *GetSelectedHisto(){return fSelectedHisto;}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
91 92 93
   Int_t GetNPads(){return fNPads;}
   void SetNPads(Int_t npads) {fNPads = npads;}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
94 95
   void FreezCavans(Bool_t freez) { fFreezed = freez;}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
96 97
   void ShowShortcutsInfos(); // *MENU*

Jérémie Dudouet's avatar
Jérémie Dudouet committed
98
   void SetAgeOfEmpireMode(Int_t value = 1); // *TOGGLE*
Jérémie Dudouet's avatar
Jérémie Dudouet committed
99
   void SetVenerMode(Int_t value = 1); // *TOGGLE*
Jérémie Dudouet's avatar
Jérémie Dudouet committed
100 101 102 103

   Int_t GetVenerMode() { return fVenerMode; }

   Int_t GetAgeOfEmpireMode() {return fAgeOfEmpireMode;}
Jérémie Dudouet's avatar
Jérémie Dudouet committed
104 105

   void SetEnabledShortcuts(Int_t value = 1); // *TOGGLE*
Jérémie Dudouet's avatar
Jérémie Dudouet committed
106
   Int_t GetEnabledShortcuts() { return fEnabledShortcuts; }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
107 108 109 110 111 112

   TH1* FindHisto(TVirtualPad *pad = nullptr);
   TGraph* FindGraph();

   void SaveHistToAsciiFile();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
113 114 115 116 117
   void CopyObject(TObject *obj);
   void CutObject(TObject *obj);
   void UndrawObject(TObject *obj);
   void Paste(); // *MENU*

Jérémie Dudouet's avatar
Jérémie Dudouet committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
protected:

//   virtual Bool_t HandleKey(Event_t* /*event*/){return kTRUE;}
   virtual Bool_t HandleKey(Int_t px, Int_t py);

   void DynamicZoom(Int_t Sign, Int_t px, Int_t py);
   void DynamicZoomTH1(Int_t Sign, Int_t px, Int_t py);
   void RunAutoExec();
   void DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject* selected);
   void ZoomSelected(TH2* TheHisto);

   void MoveAxis(TAxis* ax, Int_t sign);
   void ProfileX(TH2* hh);
   void ProfileY(TH2* hh);
   void ProjectionX(TH2* hh);
   void ProjectionY(TH2* hh);

   Bool_t ExpandFunctionRange();

   void InitInfos();
   void AddShortcutsInfo(const char* cut, const char* desc);

   ClassDef(CXCanvas, 1) //TCanvas with mouse-controlled dynamic zoom and pan & scan
};

//................  global variable
R__EXTERN TObject* gCopyObject;
R__EXTERN TString gDrawOptions;

#endif