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