GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4MdiArea.cpp
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#include "TGo4MdiArea.h"
15
16#include "TROOT.h"
17#include "TCanvas.h"
18
19#include <QMdiSubWindow>
20
21#include "TGo4ViewPanel.h"
22#include "TGo4QSettings.h"
23
25
30
31TGo4MdiArea::TGo4MdiArea(QWidget *parent) :
32 QMdiArea(parent)
33{
34 setSizeIncrement( QSize( 100, 100 ) );
35 setBaseSize( QSize( 100, 100 ) );
36
37 QObject::connect(this, &TGo4MdiArea::subWindowActivated, this, &TGo4MdiArea::subWindowActivatedSlot);
38
39 if (!gInstance) gInstance = this;
40}
41
43{
44 if (gInstance == this)
45 gInstance = nullptr;
46}
47
49{
50 return fxSelectedPad;
51}
52
54{
55 fxSelectedPad = pad;
56 gROOT->SetSelectedPad(pad);
57 gPad = pad;
58}
59
64
65QMdiSubWindow *TGo4MdiArea::AddGo4SubWindow(QWidget *widget, Qt::WindowFlags flags)
66{
67 QMdiSubWindow *sub = addSubWindow(widget, flags);
68 // JAM make window behavior configurable in Go4 for all Qt versions.
69 if (go4sett->getMoveSubwindowRubberBand()) {
70 sub->setOption(QMdiSubWindow::RubberBandResize);
71 sub->setOption(QMdiSubWindow::RubberBandMove); // JAM required for qt5 performance
72 }
73 return sub;
74}
75
77{
78 TGo4ViewPanel *panel = sub ? dynamic_cast<TGo4ViewPanel *>(sub->widget()) : nullptr;
79
80 if (panel && (fxActivePanel != panel))
81 panel->SetActivePad(panel->GetActivePad());
82}
83
85{
86 QList<QMdiSubWindow *> windows = subWindowList();
87 for (int i = 0; i < windows.count(); ++i) {
88 TGo4ViewPanel *panel = dynamic_cast<TGo4ViewPanel *>(windows.at(i)->widget());
89 if (panel && (panel != not_this)) return panel;
90 }
91
92 return nullptr;
93}
94
95void TGo4MdiArea::ResponseOnPanelEvent(int funcid, TGo4ViewPanel *panel, TPad *pad)
96{
97 if (!panel)
98 return;
99
100 switch (funcid) {
102 if ((fxActivePanel != panel) && fxActivePanel)
103 fxActivePanel->SetActivePad(nullptr);
104
105 bool changed = (fxActivePanel != panel) || (fxActivePad != pad);
106 fxActivePanel = panel;
107 fxActivePad = pad;
108
109 if (changed)
111
112 break;
113 }
114
116 emit panelSignal(panel, pad, QGo4Widget::panel_Modified);
117 break;
118 }
119
121 emit panelSignal(panel, pad, QGo4Widget::panel_Updated);
122 if ((panel == fxActivePanel) && (pad == fxActivePad))
124 break;
125 }
126
128 if (GetSelectedPad() == pad)
129 SetSelectedPad(nullptr);
130 if (fxActivePad == pad)
131 fxActivePad = nullptr;
133 break;
134 }
135
137 if (GetSelectedPad())
138 if (panel->IsPanelPad(GetSelectedPad()))
139 SetSelectedPad(nullptr);
140
141 if (fxActivePanel == panel) {
142 fxActivePanel = nullptr;
143 fxActivePad = nullptr;
144 }
145
146#ifdef __GO4WEB__
147 // try to keep gPad - nullptr can have problem when running TWebCanvas
148 if (!gPad || panel->IsPanelPad((TPad *)gPad)) {
149 TGo4ViewPanel *other = FindOtherPanel(panel);
150
151 SetSelectedPad(other ? other->GetCanvas() : nullptr);
152 }
153#endif
154
155 emit panelSignal(panel, pad, QGo4Widget::panel_Deleted);
156
157 break;
158 }
159 }
160}
161
TGo4QSettings * go4sett
@ panel_PadDeleted
Definition QGo4Widget.h:94
@ panel_Activated
Definition QGo4Widget.h:90
@ panel_ActiveUpdated
Definition QGo4Widget.h:93
TGo4MdiArea(QWidget *parent=nullptr)
TPad * fxSelectedPad
Definition TGo4MdiArea.h:58
void panelSignal(TGo4ViewPanel *, TPad *, int)
void ResponseOnPanelEvent(int funcid, TGo4ViewPanel *panel, TPad *pad)
QMdiSubWindow * AddGo4SubWindow(QWidget *widget, Qt::WindowFlags flags=Qt::Widget)
this method allows to set general properties for all go4 subwindows JAM
virtual ~TGo4MdiArea()
void SetSelectedPad(TPad *pad)
TPad * fxActivePad
Definition TGo4MdiArea.h:57
static TGo4MdiArea * Instance()
TGo4ViewPanel * fxActivePanel
Definition TGo4MdiArea.h:56
TGo4ViewPanel * FindOtherPanel(TGo4ViewPanel *not_this)
static TGo4MdiArea * gInstance
Definition TGo4MdiArea.h:60
void subWindowActivatedSlot(QMdiSubWindow *window)
TGo4ViewPanel * GetActivePanel()
TPad * GetSelectedPad()
virtual TPad * GetActivePad()
virtual void SetActivePad(TPad *pad)
virtual TCanvas * GetCanvas()
virtual bool IsPanelPad(TPad *pad)