GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
QRootCanvas.h
Go to the documentation of this file.
1 // $Id: QRootCanvas.h 1950 2016-09-12 12:43:45Z adamczew $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef QROOTCANVAS_H
15 #define QROOTCANVAS_H
16 
17 #include <QWidget>
18 
19 
20 #ifdef WIN32
21 
22 #ifdef GO4_EXPORT
23 #define GO4_CLASS_EXPORT __declspec(dllexport)
24 #else
25 #define GO4_CLASS_EXPORT __declspec(dllimport)
26 #endif
27 
28 #else
29 
30 #define GO4_CLASS_EXPORT
31 
32 #endif
33 
34 
35 #ifdef WIN32
36 #define QDESIGNER_WIDGET_EXPORT GO4_CLASS_EXPORT
37 #else
38 #include <QtDesigner/QDesignerExportWidget>
39 #endif
40 
41 #include "Rtypes.h"
42 #include "Gtypes.h"
43 #include "Buttons.h"
44 #include "TVirtualX.h"
45 
46 class TObject;
47 class TMethod;
48 class TObjLink;
49 class TVirtualPad;
50 class TPad;
51 class TCanvas;
52 class TBrowser;
53 class TContextMenu;
54 class TList;
55 
56 class QSignalMapper;
57 class QMenu;
58 class QAction;
59 class QTimer;
60 
68 class QDESIGNER_WIDGET_EXPORT QRootCanvas : public QWidget {
69 
70  Q_OBJECT
71 
72  enum { act_Update = 1, act_Resize = 2 };
73 
74  public:
75  QRootCanvas(QWidget *parent = 0);
76  virtual ~QRootCanvas();
77 
78  TCanvas* getCanvas() { return fCanvas; }
79  int getRootWid() { return fRootWindowId; }
80  void setMaskDoubleClick(bool on=true) { fMaskDoubleClick = on; }
81 
82  bool showEventStatus() const;
83  void setShowEventStatus(bool s);
84 
85  signals:
88  void SelectedPadChanged(TPad*);
89 
91  void PadClicked(TPad*);
92 
94  void PadDoubleClicked(TPad*);
95 
96  void MenuCommandExecuted(TObject*, const char*);
97 
98  void CanvasStatusEvent(const char*);
99 
100  void CanvasDropEvent(QDropEvent*, TPad*);
101 
102  void CanvasLeaveEvent();
103 
104  void CanvasUpdated();
105 
106  public slots:
107 
108  void cd(Int_t subpadnumber=0);
109  virtual void Browse(TBrowser *b);
110  void Clear(Option_t *option="");
111  void Close(Option_t *option="");
112  virtual void Draw(Option_t *option="");
113  virtual TObject *DrawClone(Option_t *option="");
114  virtual TObject *DrawClonePad();
115  virtual void EditorBar();
116  void EnterLeave(TPad *prevSelPad, TObject *prevSelObj);
117  void FeedbackMode(Bool_t set);
118  void Flush();
119  void UseCurrentStyle();
120  void ForceUpdate();
121  const char *GetDISPLAY();
122  TContextMenu *GetContextMenu();
123  Int_t GetDoubleBuffer();
124  Int_t GetEvent();
125  Int_t GetEventX();
126  Int_t GetEventY();
127  Color_t GetHighLightColor();
128  TVirtualPad *GetPadSave();
129  TObject *GetSelected() ;
130  Option_t *GetSelectedOpt();
131  TVirtualPad *GetSelectedPad();
132  Bool_t GetShowEventStatus();
133  Bool_t GetAutoExec();
134  Size_t GetXsizeUser();
135  Size_t GetYsizeUser();
136  Size_t GetXsizeReal();
137  Size_t GetYsizeReal();
138  Int_t GetCanvasID();
139  Int_t GetWindowTopX();
140  Int_t GetWindowTopY();
141  UInt_t GetWindowWidth();
142  UInt_t GetWindowHeight();
143  UInt_t GetWw();
144  UInt_t GetWh();
145  virtual void GetCanvasPar(Int_t &wtopx, Int_t &wtopy, UInt_t &ww, UInt_t &wh);
146  virtual void HandleInput(EEventType button, Int_t x, Int_t y);
147  Bool_t HasMenuBar();
148  void Iconify();
149  Bool_t IsBatch();
150  Bool_t IsRetained();
151  virtual void ls(Option_t *option="");
152  void Modified(Bool_t=1);
153  void MoveOpaque(Int_t set=1);
154  Bool_t OpaqueMoving() ;
155  Bool_t OpaqueResizing() ;
156  virtual void Paint(Option_t *option="");
157  virtual TPad *Pick(Int_t px, Int_t py, TObjLink *&pickobj);
158  virtual TPad *Pick(Int_t px, Int_t py, TObject *prevSelObj);
159  virtual void Resize(Option_t *option="");
160  void ResizeOpaque(Int_t set=1);
161  void SaveSource(const char *filename="", Option_t *option="");
162  virtual void SetCursor(ECursor cursor);
163  virtual void SetDoubleBuffer(Int_t mode=1);
164  void SetWindowPosition(Int_t x, Int_t y);
165  void SetWindowSize(UInt_t ww, UInt_t wh);
166  void SetCanvasSize(UInt_t ww, UInt_t wh);
167  void SetHighLightColor(Color_t col);
168  void SetSelected(TObject *obj);
169  void SetSelectedPad(TPad *pad);
170  void Show();
171  virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0);
172  void SetBatch(Bool_t batch=kTRUE);
173  void SetRetained(Bool_t retained=kTRUE);
174  void SetTitle(const char *title="");
175  virtual void ToggleEventStatus();
176  virtual void ToggleAutoExec();
177  virtual void Update();
178 
179  void executeMenu(int id);
180  void processRepaintTimer();
181 
182  protected:
183 
184  virtual void dropEvent( QDropEvent *Event );
185  virtual void dragEnterEvent( QDragEnterEvent *e );
186  virtual void mousePressEvent( QMouseEvent *e );
187  virtual void mouseReleaseEvent( QMouseEvent *e );
188  virtual void resizeEvent( QResizeEvent *e );
189  virtual void paintEvent( QPaintEvent *e );
190  virtual void mouseDoubleClickEvent(QMouseEvent* e );
191  virtual void mouseMoveEvent(QMouseEvent *e);
192  virtual void wheelEvent( QWheelEvent* e);
193  virtual void leaveEvent(QEvent *e);
194  virtual void closeEvent( QCloseEvent * e);
195 
196 
198  double scaledPosition(int p)
199  {
200  return (double) p * fQtScalingfactor;
201  }
202 
203  virtual QPaintEngine * paintEngine () const {return 0;}
204 
205  void methodDialog(TObject* object, TMethod* method);
206  QAction* addMenuAction(QMenu* menu, QSignalMapper* map, const QString& text, int id);
207 
208  void activateRepaint(int act);
209 
210  TCanvas* fCanvas;
212  WId fQtWindowId; // current id of embedded canvas (may change in Qt 4.4)
213  QTimer* fRepaintTimer; // do not draw canvas immediately, postpone this on few miliseconds
214  int fRepaintMode; // 0 - inactive, 1 - paint, 2 - resize, -1 - skip first repaint event
215 
216  private:
218  double fMousePosX; // mouse position in user coordinate when activate menu
219  double fMousePosY; // mouse position in user coordinate when activate menu
220 
221  TObject* fMenuObj; // object use to fill menu
222  TList* fMenuMethods; // list of menu methods
224 
226 };
227 
228 #endif
229 
230 
231 
232 
233 
234 
double scaledPosition(int p)
Definition: QRootCanvas.h:198
TObject * fMenuObj
Definition: QRootCanvas.h:221
TList * fMenuMethods
Definition: QRootCanvas.h:222
Graphic Qt Widget based Canvas.
Definition: QRootCanvas.h:68
int fRepaintMode
Definition: QRootCanvas.h:214
int getRootWid()
Definition: QRootCanvas.h:79
bool fMaskDoubleClick
Definition: QRootCanvas.h:217
double fMousePosX
Definition: QRootCanvas.h:218
double fMousePosY
Definition: QRootCanvas.h:219
TCanvas * getCanvas()
Definition: QRootCanvas.h:78
bool fxShowEventStatus
Definition: QRootCanvas.h:223
QTimer * fRepaintTimer
Definition: QRootCanvas.h:213
void setMaskDoubleClick(bool on=true)
Definition: QRootCanvas.h:80
TCanvas * fCanvas
Definition: QRootCanvas.h:210
virtual QPaintEngine * paintEngine() const
Definition: QRootCanvas.h:203
double fQtScalingfactor
Definition: QRootCanvas.h:225
Int_t fRootWindowId
Definition: QRootCanvas.h:211