GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
QRootCanvas.h
Go to the documentation of this file.
1 // $Id$
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 fuer 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 #ifdef __GO4DESIGNER__
20 #include <QtDesigner/QDesignerExportWidget>
21 #define GO4_WIDGET_EXPORT QDESIGNER_WIDGET_EXPORT
22 #else
23 #define GO4_WIDGET_EXPORT
24 #endif
25 
26 #include "RtypesCore.h"
27 #include "Buttons.h"
28 #include "TVirtualX.h"
29 
30 class TObject;
31 class TMethod;
32 class TObjLink;
33 class TVirtualPad;
34 class TPad;
35 class TCanvas;
36 class TBrowser;
37 class TContextMenu;
38 class TList;
39 class TVirtualPadEditor;
40 class TH1;
41 
42 class QSignalMapper;
43 class QMenu;
44 class QAction;
45 class QTimer;
46 class QRootWindow;
47 class QFrame;
48 class QStatusBar;
49 
57 class GO4_WIDGET_EXPORT QRootCanvas : public QWidget {
58 
59  Q_OBJECT
60 
61  enum { act_Update = 1, act_Resize = 2 };
62 
63  public:
64  QRootCanvas(QWidget *parent = nullptr);
65  virtual ~QRootCanvas();
66 
67  TCanvas *getCanvas() { return fCanvas; }
68  int getRootWid() { return fRootWindowId; }
69  void setMaskDoubleClick(bool on=true) { fMaskDoubleClick = on; }
70 
71  bool showEventStatus() const;
72  void setShowEventStatus(bool s);
73 
74  void setEditorFrame(QFrame *fr) { fEditorFrame = fr; }
75  bool isEditorAllowed();
76  bool isEditorVisible();
77  void toggleEditor();
78  void resizeEditor();
79  void activateEditor(TPad *pad, TObject *obj);
80  void cleanupEditor();
81 
82  void setStatusBar(QStatusBar *bar) { fStatusBar = bar; }
83  void showStatusMessage(const char *msg);
84  void setStatusBarVisible(bool flag);
85  bool isStatusBarVisible();
86 
87  signals:
90  void SelectedPadChanged(TPad *);
91 
93  void PadClicked(TPad *, int, int);
94 
96  void PadDoubleClicked(TPad *, int, int);
97 
98  void MenuCommandExecuted(TObject *, const char *);
99 
100  void CanvasStatusEvent(const char *);
101 
102  void CanvasDropEvent(QDropEvent *, TPad *);
103 
104  void CanvasLeaveEvent();
105 
106  void CanvasUpdated();
107 
108  public slots:
109 
110  void cd(Int_t subpadnumber = 0);
111  virtual void Browse(TBrowser *b);
112  void Clear(Option_t *option = "");
113  void Close(Option_t *option = "");
114  virtual void Draw(Option_t *option = "");
115  virtual TObject *DrawClone(Option_t *option = "");
116  virtual TObject *DrawClonePad();
117  virtual void EditorBar();
118  void EnterLeave(TPad *prevSelPad, TObject *prevSelObj);
119  void FeedbackMode(Bool_t set);
120  void Flush();
121  void UseCurrentStyle();
122  void ForceUpdate();
123  const char *GetDISPLAY();
124  TContextMenu *GetContextMenu();
125  Int_t GetDoubleBuffer();
126  Int_t GetEvent();
127  Int_t GetEventX();
128  Int_t GetEventY();
129  Color_t GetHighLightColor();
130  TVirtualPad *GetPadSave();
131  TObject *GetSelected();
132  Option_t *GetSelectedOpt();
133  TVirtualPad *GetSelectedPad();
134  Bool_t GetShowEventStatus();
135  Bool_t GetAutoExec();
136  Size_t GetXsizeUser();
137  Size_t GetYsizeUser();
138  Size_t GetXsizeReal();
139  Size_t GetYsizeReal();
140  Int_t GetCanvasID();
141  Int_t GetWindowTopX();
142  Int_t GetWindowTopY();
143  UInt_t GetWindowWidth();
144  UInt_t GetWindowHeight();
145  UInt_t GetWw();
146  UInt_t GetWh();
147  virtual void GetCanvasPar(Int_t &wtopx, Int_t &wtopy, UInt_t &ww, UInt_t &wh);
148  virtual void HandleInput(EEventType button, Int_t x, Int_t y);
149  Bool_t HasMenuBar();
150  void Iconify();
151  Bool_t IsBatch();
152  Bool_t IsRetained();
153  virtual void ls(Option_t *option = "");
154  void Modified(Bool_t=1);
155  void MoveOpaque(Int_t set=1);
156  Bool_t OpaqueMoving();
157  Bool_t OpaqueResizing();
158  virtual void Paint(Option_t *option = "");
159  virtual TPad *Pick(Int_t px, Int_t py, TObjLink *&pickobj);
160  virtual TPad *Pick(Int_t px, Int_t py, TObject *prevSelObj);
161  virtual void Resize(Option_t *option = "");
162  void ResizeOpaque(Int_t set=1);
163  void SaveSource(const char *filename = "", Option_t *option = "");
164  virtual void SetCursor(ECursor cursor);
165  virtual void SetDoubleBuffer(Int_t mode=1);
166  void SetWindowPosition(Int_t x, Int_t y);
167  void SetWindowSize(UInt_t ww, UInt_t wh);
168  void SetCanvasSize(UInt_t ww, UInt_t wh);
169  void SetHighLightColor(Color_t col);
170  void SetSelected(TObject *obj);
171  void SetSelectedPad(TPad *pad);
172  void Show();
173  virtual void Size(Float_t xsizeuser = 0, Float_t ysizeuser = 0);
174  void SetBatch(Bool_t batch=kTRUE);
175  void SetRetained(Bool_t retained=kTRUE);
176  void SetTitle(const char *title = "");
177  virtual void ToggleEventStatus();
178  virtual void ToggleAutoExec();
179  virtual void Update();
180 
181  void buildEditorWindow();
182  void executeMenu(int id);
183  void processRepaintTimer();
184 
185  protected:
186 
187  void dropEvent( QDropEvent *Event ) override;
188  void dragEnterEvent( QDragEnterEvent *e ) override;
189  void mousePressEvent( QMouseEvent *e ) override;
190  void mouseReleaseEvent( QMouseEvent *e ) override;
191  void resizeEvent( QResizeEvent *e ) override;
192  void paintEvent( QPaintEvent *e ) override;
193  void mouseDoubleClickEvent(QMouseEvent* e ) override;
194  void mouseMoveEvent(QMouseEvent *e) override;
195  void wheelEvent( QWheelEvent* e) override;
196  void leaveEvent(QEvent *e) override;
197  void closeEvent( QCloseEvent * e) override;
198 
199 
201  double scaledPosition(int p) { return (double) p * fQtScalingfactor; }
202 
203  QPoint scaledMousePoint(QMouseEvent *ev);
204 
205  QPaintEngine * paintEngine() const override { return nullptr; }
206 
207  void methodDialog(TObject *object, TMethod *method);
208  QAction* addMenuAction(QMenu *menu, QSignalMapper *map, const QString &text, int id);
209 
210  void activateRepaint(int act);
211 
212  TCanvas *fCanvas{nullptr};
213  Int_t fRootWindowId{0};
214  WId fQtWindowId; // current id of embedded canvas
215  QTimer *fRepaintTimer{nullptr}; // do not draw canvas immediately, postpone this on few miliseconds
216  int fRepaintMode{0}; // 0 - inactive, 1 - paint, 2 - resize, -1 - skip first repaint event
217 
218  QFrame *fEditorFrame{nullptr}; // frame to show editor
219  TVirtualPadEditor *fxPeditor{nullptr}; // ROOT editor
220  QRootWindow *fxRooteditor{nullptr}; // QtRoot window to embed ROOT editor
221  TH1 *fDummyHisto{nullptr}; // dummy histogram used for editor cleanup
222 
223  QStatusBar *fStatusBar{nullptr};
224 
225  private:
226  bool fMaskDoubleClick{false};
227  double fMousePosX{0}; // mouse position in user coordinate when activate menu
228  double fMousePosY{0}; // mouse position in user coordinate when activate menu
229 
230  TObject *fMenuObj{nullptr}; // object use to fill menu
231  TList *fMenuMethods{nullptr}; // list of menu methods
232  bool fxShowEventStatus{false};
233 
234  double fQtScalingfactor{0};
235 };
236 
237 #endif
double scaledPosition(int p)
Definition: QRootCanvas.h:201
#define GO4_WIDGET_EXPORT
Definition: QRootCanvas.h:23
Graphic Qt Widget based Canvas.
Definition: QRootCanvas.h:57
int getRootWid()
Definition: QRootCanvas.h:68
TCanvas * getCanvas()
Definition: QRootCanvas.h:67
QPaintEngine * paintEngine() const override
Definition: QRootCanvas.h:205
void setMaskDoubleClick(bool on=true)
Definition: QRootCanvas.h:69
void setStatusBar(QStatusBar *bar)
Definition: QRootCanvas.h:82
void setEditorFrame(QFrame *fr)
Definition: QRootCanvas.h:74
string msg
Definition: go4init.py:11