GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4SetScaleValues.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 "TGo4SetScaleValues.h"
15#include "TGo4MdiArea.h"
16#include "TGo4ViewPanel.h"
17#include "TPad.h"
18
19
20TGo4SetScaleValues::TGo4SetScaleValues( QWidget *parent, const char *name, Qt::WindowFlags fl ) :
21 QWidget( parent, fl )
22{
23 setObjectName( name ? name : "Go4SetScaleValues");
24 setupUi(this);
25
26 QObject::connect(AutoScaleButton, &QCheckBox::toggled, this, &TGo4SetScaleValues::AutoscaleChanged);
27 QObject::connect(SetButton, &QPushButton::clicked, this, &TGo4SetScaleValues::ApplyValues);
28 QObject::connect(XminV, &QLineEdit::returnPressed, this, &TGo4SetScaleValues::ApplyValues);
29 QObject::connect(XmaxV, &QLineEdit::returnPressed, this, &TGo4SetScaleValues::ApplyValues);
30 QObject::connect(YminV, &QLineEdit::returnPressed, this, &TGo4SetScaleValues::ApplyValues);
31 QObject::connect(YmaxV, &QLineEdit::returnPressed, this, &TGo4SetScaleValues::ApplyValues);
32 QObject::connect(ZminV, &QLineEdit::returnPressed, this, &TGo4SetScaleValues::ApplyValues);
33 QObject::connect(ZmaxV, &QLineEdit::returnPressed, this, &TGo4SetScaleValues::ApplyValues);
34
36
37 fbDoingRefresh = false;
38
39 refreshView(true);
40}
41
43{
44 if (fbDoingRefresh) return;
45
46 fbDoingRefresh = true;
47
48 if (force) {
49 XminV->setModified(false);
50 XmaxV->setModified(false);
51 YminV->setModified(false);
52 YmaxV->setModified(false);
53 ZminV->setModified(false);
54 ZmaxV->setModified(false);
55 }
56
58
59 setEnabled(panel != nullptr);
60
61 if (panel) {
62
63 setWindowTitle(QString("Scale values: ") + panel->objectName());
64
65 int ndim = 0;
66 double Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0;
67 bool autoscale;
68
69 panel->GetSelectedRange(ndim, autoscale, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
70
71 AutoScaleButton->setChecked(autoscale);
72
73 if (!XminV->isModified())
74 XminV->setText(QString::number(Xmin));
75 if (!XmaxV->isModified())
76 XmaxV->setText(QString::number(Xmax));
77 if (!YminV->isModified())
78 YminV->setText(QString::number(Ymin));
79 if (!YmaxV->isModified())
80 YmaxV->setText(QString::number(Ymax));
81 if (!ZminV->isModified())
82 ZminV->setText(QString::number(Zmin));
83 if (!ZmaxV->isModified())
84 ZmaxV->setText(QString::number(Zmax));
85
86 // enables/disables text edit for y
87 switch(ndim) {
88 case 1:
89 YminV->setDisabled(autoscale);
90 YmaxV->setDisabled(autoscale);
91 ZminV->setDisabled(true);
92 ZmaxV->setDisabled(true);
93 break;
94 case 2:
95 YminV->setDisabled(false);
96 YmaxV->setDisabled(false);
97 ZminV->setDisabled(autoscale);
98 ZmaxV->setDisabled(autoscale);
99 break;
100 default:
101 YminV->setDisabled(false);
102 YmaxV->setDisabled(false);
103 ZminV->setDisabled(false);
104 ZmaxV->setDisabled(false);
105 break;
106 }
107
108 } else {
109 setWindowTitle(QString("Scale values: none"));
110
111 XminV->setText("");
112 XmaxV->setText("");
113 YminV->setText("");
114 YmaxV->setText("");
115 ZminV->setText("");
116 ZmaxV->setText("");
117 }
118
119 fbDoingRefresh = false;
120}
121
122
123void TGo4SetScaleValues::panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
124{
125 switch (signalid) {
128 refreshView(true);
129 break;
131 refreshView(false);
132 break;
133 }
134}
135
137{
138 if (fbDoingRefresh) return;
139
141 if (!panel) return;
142
143 double Xmin = XminV->text().toDouble();
144 double Xmax = XmaxV->text().toDouble();
145 double Ymin = YminV->text().toDouble();
146 double Ymax = YmaxV->text().toDouble();
147 double Zmin = ZminV->text().toDouble();
148 double Zmax = ZmaxV->text().toDouble();
149
150 if ((Xmin == 0.) && (Xmax == 0.)) { Xmin=-1.; Xmax=-1.; }
151 if ((Ymin == 0.) && (Ymax == 0.)) { Ymin=-1.; Ymax=-1.; }
152 if ((Zmin == 0.) && (Zmax == 0.)) { Zmin=-1.; Zmax=-1.; }
153
154 fbDoingRefresh = true;
155 panel->SetSelectedRange(Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
156 fbDoingRefresh = false;
157
158 refreshView(true);
159}
160
162{
163 if (fbDoingRefresh) return;
165 if (!panel) return;
166
167 fbDoingRefresh = true;
168 panel->SetAutoScale(on, nullptr);
169 fbDoingRefresh = false;
170
171 refreshView(true);
172}
@ panel_Activated
Definition QGo4Widget.h:90
@ panel_ActiveUpdated
Definition QGo4Widget.h:93
void panelSignal(TGo4ViewPanel *, TPad *, int)
static TGo4MdiArea * Instance()
TGo4ViewPanel * GetActivePanel()
virtual void panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
virtual void AutoscaleChanged(bool on)
void refreshView(bool force)
TGo4SetScaleValues(QWidget *parent=nullptr, const char *name=nullptr, Qt::WindowFlags fl=Qt::Widget)
virtual void SetSelectedRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
virtual void GetSelectedRange(int &ndim, bool &autoscale, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax)
virtual void SetAutoScale(bool on, TPad *selpad)