GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
QRootCanvas.h
Go to the documentation of this file.
1 // $Id: QRootCanvas.h 3145 2021-03-30 14:33:08Z linev $
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 "Rtypes.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 = 0);
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*);
94 
96  void PadDoubleClicked(TPad*);
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  virtual void dropEvent( QDropEvent *Event );
188  virtual void dragEnterEvent( QDragEnterEvent *e );
189  virtual void mousePressEvent( QMouseEvent *e );
190  virtual void mouseReleaseEvent( QMouseEvent *e );
191  virtual void resizeEvent( QResizeEvent *e );
192  virtual void paintEvent( QPaintEvent *e );
193  virtual void mouseDoubleClickEvent(QMouseEvent* e );
194  virtual void mouseMoveEvent(QMouseEvent *e);
195  virtual void wheelEvent( QWheelEvent* e);
196  virtual void leaveEvent(QEvent *e);
197  virtual void closeEvent( QCloseEvent * e);
198 
199 
201  double scaledPosition(int p)
202  {
203  return (double) p * fQtScalingfactor;
204  }
205 
206  QPoint scaledMousePoint(QMouseEvent *ev);
207 
208  virtual QPaintEngine * paintEngine () const {return 0;}
209 
210  void methodDialog(TObject* object, TMethod* method);
211  QAction* addMenuAction(QMenu* menu, QSignalMapper* map, const QString& text, int id);
212 
213  void activateRepaint(int act);
214 
215  TCanvas* fCanvas;
217  WId fQtWindowId; // current id of embedded canvas (may change in Qt 4.4)
218  QTimer* fRepaintTimer; // do not draw canvas immediately, postpone this on few miliseconds
219  int fRepaintMode; // 0 - inactive, 1 - paint, 2 - resize, -1 - skip first repaint event
220 
221  QFrame* fEditorFrame; // frame to show editor
222  TVirtualPadEditor* fxPeditor; // ROOT editor
223  QRootWindow* fxRooteditor; // QtRoot window to embed ROOT editor
224  TH1* fDummyHisto; // dummy histogram used for editor cleanup
225 
226  QStatusBar *fStatusBar;
227 
228  private:
230  double fMousePosX; // mouse position in user coordinate when activate menu
231  double fMousePosY; // mouse position in user coordinate when activate menu
232 
233  TObject* fMenuObj; // object use to fill menu
234  TList* fMenuMethods; // list of menu methods
236 
238 };
239 
240 #endif
241 
242 
243 
244 
245 
246 
double scaledPosition(int p)
Definition: QRootCanvas.h:201
QRootWindow * fxRooteditor
Definition: QRootCanvas.h:223
#define GO4_WIDGET_EXPORT
Definition: QRootCanvas.h:23
TObject * fMenuObj
Definition: QRootCanvas.h:233
TList * fMenuMethods
Definition: QRootCanvas.h:234
Graphic Qt Widget based Canvas.
Definition: QRootCanvas.h:57
int fRepaintMode
Definition: QRootCanvas.h:219
int getRootWid()
Definition: QRootCanvas.h:68
bool fMaskDoubleClick
Definition: QRootCanvas.h:229
double fMousePosX
Definition: QRootCanvas.h:230
double fMousePosY
Definition: QRootCanvas.h:231
QFrame * fEditorFrame
Definition: QRootCanvas.h:221
TCanvas * getCanvas()
Definition: QRootCanvas.h:67
TH1 * fDummyHisto
Definition: QRootCanvas.h:224
GO4 MsgListPainter prototype Draw
Definition: go4.js:213
bool fxShowEventStatus
Definition: QRootCanvas.h:235
QTimer * fRepaintTimer
Definition: QRootCanvas.h:218
void setMaskDoubleClick(bool on=true)
Definition: QRootCanvas.h:69
QStatusBar * fStatusBar
Definition: QRootCanvas.h:226
TCanvas * fCanvas
Definition: QRootCanvas.h:215
virtual QPaintEngine * paintEngine() const
Definition: QRootCanvas.h:208
double fQtScalingfactor
Definition: QRootCanvas.h:237
void setStatusBar(QStatusBar *bar)
Definition: QRootCanvas.h:82
TVirtualPadEditor * fxPeditor
Definition: QRootCanvas.h:222
void setEditorFrame(QFrame *fr)
Definition: QRootCanvas.h:74
Int_t fRootWindowId
Definition: QRootCanvas.h:216
string msg
Definition: go4init.py:11