GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
30class TObject;
31class TMethod;
32class TObjLink;
33class TVirtualPad;
34class TPad;
35class TCanvas;
36class TBrowser;
37class TContextMenu;
38class TList;
39class TVirtualPadEditor;
40class TH1;
41
42class QSignalMapper;
43class QMenu;
44class QAction;
45class QTimer;
46class QRootWindow;
47class QFrame;
48class QStatusBar;
49
56
57class 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
105
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};
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
235};
236
237#endif
#define GO4_WIDGET_EXPORT
Definition QRootCanvas.h:23
This canvas uses Qt eventloop to handle user input.
Definition QRootCanvas.h:57
virtual void ToggleEventStatus()
void SelectedPadChanged(TPad *)
signal which will be emitted when root selected pad is changed via clicking the mid-mouse button (M.
Int_t GetWindowTopX()
Bool_t IsRetained()
Bool_t OpaqueResizing()
void CanvasLeaveEvent()
Int_t GetCanvasID()
virtual TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj)
void FeedbackMode(Bool_t set)
Size_t GetYsizeUser()
void setEditorFrame(QFrame *fr)
Definition QRootCanvas.h:74
void dropEvent(QDropEvent *Event) override
TVirtualPadEditor * fxPeditor
UInt_t GetWh()
double scaledPosition(int p)
returns scaled point coordinate, for high dpi case
TObject * GetSelected()
virtual void SetDoubleBuffer(Int_t mode=1)
void paintEvent(QPaintEvent *e) override
int getRootWid()
Definition QRootCanvas.h:68
TCanvas * getCanvas()
Definition QRootCanvas.h:67
TH1 * fDummyHisto
virtual TObject * DrawClonePad()
Int_t GetEventY()
void UseCurrentStyle()
void processRepaintTimer()
void SetTitle(const char *title="")
void closeEvent(QCloseEvent *e) override
void CanvasDropEvent(QDropEvent *, TPad *)
virtual void Browse(TBrowser *b)
void SetCanvasSize(UInt_t ww, UInt_t wh)
void mouseDoubleClickEvent(QMouseEvent *e) override
bool fxShowEventStatus
UInt_t GetWw()
virtual void Resize(Option_t *option="")
Int_t GetWindowTopY()
TVirtualPad * GetPadSave()
void CanvasUpdated()
Bool_t GetAutoExec()
void SetRetained(Bool_t retained=kTRUE)
const char * GetDISPLAY()
void ForceUpdate()
void SaveSource(const char *filename="", Option_t *option="")
void MoveOpaque(Int_t set=1)
UInt_t GetWindowWidth()
TVirtualPad * GetSelectedPad()
Int_t GetEventX()
Color_t GetHighLightColor()
QRootCanvas(QWidget *parent=nullptr)
virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0)
virtual void ls(Option_t *option="")
void buildEditorWindow()
Int_t fRootWindowId
QPaintEngine * paintEngine() const override
void SetWindowPosition(Int_t x, Int_t y)
Bool_t HasMenuBar()
Bool_t OpaqueMoving()
virtual void SetCursor(ECursor cursor)
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
double fMousePosX
Bool_t IsBatch()
virtual void GetCanvasPar(Int_t &wtopx, Int_t &wtopy, UInt_t &ww, UInt_t &wh)
virtual void Paint(Option_t *option="")
Int_t GetDoubleBuffer()
void Modified(Bool_t=1)
virtual TObject * DrawClone(Option_t *option="")
bool fMaskDoubleClick
void leaveEvent(QEvent *e) override
void mousePressEvent(QMouseEvent *e) override
void wheelEvent(QWheelEvent *e) override
UInt_t GetWindowHeight()
void setMaskDoubleClick(bool on=true)
Definition QRootCanvas.h:69
void SetWindowSize(UInt_t ww, UInt_t wh)
TList * fMenuMethods
void PadDoubleClicked(TPad *, int, int)
signal emitted when user produce left mouse double-click on pad
TObject * fMenuObj
void mouseMoveEvent(QMouseEvent *e) override
Size_t GetYsizeReal()
void MenuCommandExecuted(TObject *, const char *)
QTimer * fRepaintTimer
void Clear(Option_t *option="")
Size_t GetXsizeReal()
void PadClicked(TPad *, int, int)
signal emitted when mouse clicks on pad
void setStatusBar(QStatusBar *bar)
Definition QRootCanvas.h:82
void ResizeOpaque(Int_t set=1)
void SetBatch(Bool_t batch=kTRUE)
TCanvas * fCanvas
void Close(Option_t *option="")
void cd(Int_t subpadnumber=0)
virtual void Draw(Option_t *option="")
Option_t * GetSelectedOpt()
void SetSelected(TObject *obj)
virtual void ToggleAutoExec()
void SetSelectedPad(TPad *pad)
QFrame * fEditorFrame
virtual void Update()
Size_t GetXsizeUser()
void CanvasStatusEvent(const char *)
Bool_t GetShowEventStatus()
Int_t GetEvent()
void resizeEvent(QResizeEvent *e) override
double fQtScalingfactor
TContextMenu * GetContextMenu()
void SetHighLightColor(Color_t col)
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
QStatusBar * fStatusBar
void mouseReleaseEvent(QMouseEvent *e) override
void executeMenu(int id)
QRootWindow * fxRooteditor
double fMousePosY
void dragEnterEvent(QDragEnterEvent *e) override
virtual void EditorBar()
Qt widget wrapper for ROOT TGWindow class.
Definition QRootWindow.h:32