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