General Purpose Geodetic Library
SgGuiParameterCfg.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <SgGuiParameterCfg.h>
24 
25 #if QT_VERSION >= 0x050000
26 # include <QtWidgets/QBoxLayout>
27 # include <QtWidgets/QButtonGroup>
28 # include <QtWidgets/QGridLayout>
29 # include <QtWidgets/QGroupBox>
30 # include <QtWidgets/QLabel>
31 # include <QtWidgets/QLineEdit>
32 # include <QtWidgets/QPushButton>
33 # include <QtWidgets/QRadioButton>
34 # include <QtWidgets/QTabWidget>
35 #else
36 # include <QtGui/QBoxLayout>
37 # include <QtGui/QButtonGroup>
38 # include <QtGui/QGridLayout>
39 # include <QtGui/QGroupBox>
40 # include <QtGui/QLabel>
41 # include <QtGui/QLineEdit>
42 # include <QtGui/QPushButton>
43 # include <QtGui/QRadioButton>
44 # include <QtGui/QTabWidget>
45 #endif
46 
47 
48 #include <SgParametersDescriptor.h>
49 #include <SgLogger.h>
50 
51 
52 
53 /*=======================================================================================================
54 *
55 * SgGuiParameterCfg's METHODS:
56 *
57 *======================================================================================================*/
58 //
59 SgGuiParameterCfg::SgGuiParameterCfg(SgParameterCfg *pCfg, int idx, bool isModeAdjustable,
60  QWidget* parent, Qt::WindowFlags f)
61  : QDialog(parent, f),
62  str_()
63 {
64  parameterIdx_ = idx;
65  parConfigOrig_ = pCfg;
67  isModified_ = false;
68  isModeAdjustable_ = isModeAdjustable;
69  setWindowTitle("Parameter Editor: " + parConfig_->getName());
70 
71  QBoxLayout *layout, *subLayout;
72  QSize btnSize;
73  tabs4types_ = new QTabWidget(this);
74  layout = new QVBoxLayout(this);
75  tabs4types_->addTab(tab4RegularType(), "&Regular");
76  tabs4types_->addTab(tab4ArcType(), "&Arc");
77  tabs4types_->addTab(tab4PWLType(), "&PWL");
78  tabs4types_->addTab(tab4StochasticType(), "&Stochastic");
79 
80  switch (parConfig_->getPMode())
81  {
82  default:
84  tabs4types_->setCurrentIndex(0);
85  break;
87  tabs4types_->setCurrentIndex(1);
88  break;
90  tabs4types_->setCurrentIndex(2);
91  break;
93  tabs4types_->setCurrentIndex(3);
94  break;
95  };
96 
97  layout->addWidget(tabs4types_, 10);
98  subLayout = new QHBoxLayout();
99  layout->addLayout(subLayout);
100 
101  QPushButton *btnApply = new QPushButton("Apply", this);
102  QPushButton *btnOk = new QPushButton("OK", this);
103  QPushButton *btnCancel = new QPushButton("Cancel", this);
104  QPushButton *btnDefault = new QPushButton("Default", this);
105  btnOk->setDefault(true);
106  btnDefault->setMinimumSize((btnSize=btnDefault->sizeHint()));
107  btnCancel ->setMinimumSize( btnSize );
108  btnOk ->setMinimumSize( btnSize );
109  btnApply ->setMinimumSize( btnSize );
110 
111  subLayout->addWidget(btnApply);
112  subLayout->addWidget(btnDefault);
113  subLayout->addStretch(1);
114  subLayout->addWidget(btnOk);
115  subLayout->addWidget(btnCancel);
116  setSizeGripEnabled(true);
117 
118  connect(btnApply, SIGNAL(clicked()), SLOT(apply()));
119  connect(btnDefault,SIGNAL(clicked()), SLOT(setDefault()));
120  connect(btnOk, SIGNAL(clicked()), SLOT(accept()));
121  connect(btnCancel, SIGNAL(clicked()), SLOT(reject()));
122 };
123 
124 
125 
126 //
128 {
129  acquireData();
130  if (isModified_)
133 };
134 
135 
136 
137 //
139 {
140  acquireData();
141  if (isModified_)
144  QDialog::accept();
145  deleteLater();
146 };
147 
148 
149 
150 //
152 {
155  parConfig_->setPMode(pm);
156  isModified_ = true;
157  browseData();
158 };
159 
160 
161 
162 //
164 {
165  leConvApriori_->setText(str_.sprintf("%.4f", parConfig_->getConvAPriori()));
166  leArcLength_->setText(str_.sprintf("%.4f", 24.0*parConfig_->getArcStep()));
167  lePwlApriori_->setText(str_.sprintf("%.4f", parConfig_->getPwlAPriori()/24.0));
168  lePwlLength_->setText(str_.sprintf("%.4f", 24.0*parConfig_->getPwlStep()));
169  leStcApriori_->setText(str_.sprintf("%.4f", parConfig_->getStocAPriori()));
170  leRWNPower_->setText(str_.sprintf("%.4f", parConfig_->getWhiteNoise()));
171  leTau_->setText(str_.sprintf("%.4f", parConfig_->getTau()));
172  rbSType_[(int)parConfig_->getSType()]->setChecked(true);
173 };
174 
175 
176 
177 //
179 {
180  bool isOK;
181  double d;
183  // conventional parameter:
184  str_ = leConvApriori_->text();
185  d = str_.toDouble(&isOK);
186  if (isOK && d!=parConfig_->getConvAPriori())
187  {
188  isModified_ = true;
190  };
191  // arc parameter:
192  str_ = leArcLength_->text();
193  d = str_.toDouble(&isOK);
194  if (isOK && d!=parConfig_->getArcStep()*24.0)
195  {
196  isModified_ = true;
197  parConfig_->setArcStep(d/24.0);
198  };
199  // PWL parameter:
200  str_ = lePwlApriori_->text();
201  d = str_.toDouble(&isOK);
202  if (isOK && d!=parConfig_->getPwlAPriori()/24.0)
203  {
204  isModified_ = true;
205  parConfig_->setPwlAPriori(d*24.0);
206  };
207  str_ = lePwlLength_->text();
208  d = str_.toDouble(&isOK);
209  if (isOK && d!=parConfig_->getPwlStep()*24.0)
210  {
211  isModified_ = true;
212  parConfig_->setPwlStep(d/24.0);
213  };
214  // stochastic parameter:
215  str_ = leStcApriori_->text();
216  d = str_.toDouble(&isOK);
217  if (isOK && d!=parConfig_->getStocAPriori())
218  {
219  isModified_ = true;
221  };
222  str_ = leRWNPower_->text();
223  d = str_.toDouble(&isOK);
224  if (isOK && d!=parConfig_->getWhiteNoise())
225  {
226  isModified_ = true;
228  };
229  str_ = leTau_->text();
230  d = str_.toDouble(&isOK);
231  if (isOK && d!=parConfig_->getTau())
232  {
233  isModified_ = true;
234  parConfig_->setTau(d);
235  };
236  if (rbSType_[0]->isChecked())
238  else if (rbSType_[1]->isChecked())
240  else if (rbSType_[2]->isChecked())
242  if (type != parConfig_->getSType())
243  {
244  isModified_ = true;
245  parConfig_->setSType(type);
246  };
247  //
249  if (isModeAdjustable_)
250  switch (tabs4types_->currentIndex())
251  {
252  default:
253  case 0:
255  break;
256  case 1:
258  break;
259  case 2:
261  break;
262  case 3:
264  break;
265  };
266  if (parConfig_->getPMode() != oldPMode)
267  isModified_ = true;
268 };
269 
270 
271 
272 //
274 {
275  QWidget *w=new QWidget(this);
276  QBoxLayout *layout=new QVBoxLayout(w);
277  QGroupBox *gbox=new QGroupBox("Conventional Parameter", w);
278  layout->addWidget(gbox);
279  QGridLayout *grid=new QGridLayout(gbox);
280  QLabel *label=new QLabel("A priori (initial) sigma (" + parConfig_->getScaleName() + "):", gbox);
281  label->setMinimumSize(label->sizeHint());
282  grid->addWidget(label, 0, 0);
283 
284  leConvApriori_ = new QLineEdit(gbox);
285  leConvApriori_->setText(str_.sprintf("%.4f", parConfig_->getConvAPriori()));
286  leConvApriori_->setMinimumSize(leConvApriori_->sizeHint());
287  grid->addWidget(leConvApriori_, 0, 1);
288 
289  return w;
290 };
291 
292 
293 
294 //
296 {
297  QWidget *w=new QWidget(this);
298  QBoxLayout *layout=new QVBoxLayout(w);
299  QGroupBox *gbox=new QGroupBox("Arc Parameter", w);
300  layout->addWidget(gbox);
301  QGridLayout *grid=new QGridLayout(gbox);
302  QLabel *label=new QLabel("Arc length (hrs):", gbox);
303  label->setMinimumSize(label->sizeHint());
304  grid->addWidget(label, 0, 0);
305 
306  leArcLength_ = new QLineEdit(gbox);
307  leArcLength_->setText(str_.sprintf("%.4f", 24.0*parConfig_->getArcStep()));
308  leArcLength_->setMinimumSize(leArcLength_->sizeHint());
309  grid->addWidget(leArcLength_, 0, 1);
310 
311  return w;
312 };
313 
314 
315 
316 //
318 {
319  QWidget *w=new QWidget(this);
320  QBoxLayout *layout=new QVBoxLayout(w);
321  QGroupBox *gbox=new QGroupBox("PieceWise Linear Parameter", w);
322  layout->addWidget(gbox);
323  QGridLayout *grid=new QGridLayout(gbox);
324 //"<p>&sigma;</p>"
325  QLabel *label=new QLabel("A priori sigmas for rate terms (" +
326  parConfig_->getScaleName() + "/hr):", gbox);
327  label->setMinimumSize(label->sizeHint());
328  grid->setRowStretch(0, 1);
329  grid->addWidget(label, 1, 0);
330  //
331  lePwlApriori_ = new QLineEdit(gbox);
332  lePwlApriori_->setText(str_.sprintf("%.4f", parConfig_->getPwlAPriori()/24.0));
333  lePwlApriori_->setMinimumSize(lePwlApriori_->sizeHint());
334  grid->addWidget(lePwlApriori_, 1, 1);
335 
336  label = new QLabel("Interval length (hrs):", gbox);
337  label->setMinimumSize(label->sizeHint());
338  grid->addWidget(label, 2, 0);
339  //
340  lePwlLength_ = new QLineEdit(gbox);
341  lePwlLength_->setText(str_.sprintf("%.4f", 24.0*parConfig_->getPwlStep()));
342  lePwlLength_->setMinimumSize(lePwlLength_->sizeHint());
343  grid->addWidget(lePwlLength_, 2, 1);
344  grid->setRowStretch(3, 1);
345 
346  return w;
347 };
348 
349 
350 
351 //
353 {
354  static const QString typeNames[] =
355  {
356  QString("White noise"),
357  QString("2-nd order Markov process"),
358  QString("Random Walk"),
359  };
360  QWidget *w=new QWidget(this);
361  QBoxLayout *layout=new QVBoxLayout(w);
362  QGroupBox *gbox=new QGroupBox("Stochastic Parameter", w);
363  layout->addWidget(gbox);
364  QGridLayout *grid=new QGridLayout(gbox);
365 
366  QLabel *label=new QLabel("A priori (initial) sigma (" + parConfig_->getScaleName() + "):", gbox);
367  label->setMinimumSize(label->sizeHint());
368  grid->addWidget(label, 0, 0);
369  //
370  leStcApriori_ = new QLineEdit(gbox);
371  leStcApriori_->setText(str_.sprintf("%.4f", parConfig_->getStocAPriori()));
372  leStcApriori_->setMinimumSize(leStcApriori_->sizeHint());
373  grid->addWidget(leStcApriori_, 0, 1);
374 
375  label = new QLabel("Ruled White Noise Power (" + parConfig_->getScaleName() + "/sqrt(hr)):", gbox);
376  label->setMinimumSize(label->sizeHint());
377  grid->addWidget(label, 1, 0);
378  //
379  leRWNPower_ = new QLineEdit(gbox);
380  leRWNPower_->setText(str_.sprintf("%.4f", parConfig_->getWhiteNoise()));
381  leRWNPower_->setMinimumSize(leRWNPower_->sizeHint());
382  grid->addWidget(leRWNPower_, 1, 1);
383 
384  label = new QLabel("Time of relaxation (hr):", gbox);
385  label->setMinimumSize(label->sizeHint());
386  grid->addWidget(label, 2, 0);
387  //
388  leTau_ = new QLineEdit(gbox);
389  leTau_->setText(str_.sprintf("%.4f", parConfig_->getTau()));
390  leTau_->setMinimumSize(leTau_->sizeHint());
391  grid->addWidget(leTau_, 2, 1);
392 
393  gbox = new QGroupBox("Type of stochastic modelling", gbox);
394  layout = new QVBoxLayout(gbox);
395  QButtonGroup *gr=new QButtonGroup(gbox);
396  for (int i=0; i<3; i++)
397  {
398  rbSType_[i] = new QRadioButton(typeNames[i], gbox);
399  rbSType_[i]->setMinimumSize(rbSType_[i]->sizeHint());
400  layout->addWidget(rbSType_[i]);
401  gr->addButton(rbSType_[i], i);
402  };
403  grid->addWidget(gbox, 3,0, 2,1);
404  connect (gr, SIGNAL(buttonClicked(int)), SLOT(stochasticTypeChanged(int)));
405 // rbSType_[(int)config_.getSType()]->setChecked(true);
406  rbSType_[(int)parConfig_->getSType()]->click();
407  return w;
408 };
409 
410 
411 
412 //
414 {
415  switch (id)
416  {
417  case 0:
418  leRWNPower_->setEnabled(false);
419  leTau_->setEnabled(false);
420  break;
421  case 1:
422  leRWNPower_->setEnabled(true);
423  leTau_->setEnabled(true);
424  break;
425  case 2:
426  default:
427  leRWNPower_->setEnabled(true);
428  leTau_->setEnabled(false);
429  break;
430  };
431 };
432 /*=====================================================================================================*/
433 
434 
435 
436 
437 /*=====================================================================================================*/
const QString typeNames[]
SgParameterCfg * parConfig_
QLineEdit * leArcLength_
QLineEdit * leStcApriori_
SgGuiParameterCfg(SgParameterCfg *, int, bool=false, QWidget *=0, Qt::WindowFlags=Qt::Widget)
virtual void browseData()
QRadioButton * rbSType_[3]
QLineEdit * leRWNPower_
virtual void acquireData()
QLineEdit * leConvApriori_
QTabWidget * tabs4types_
QLineEdit * lePwlLength_
QWidget * tab4StochasticType()
QLineEdit * lePwlApriori_
SgParameterCfg * parConfigOrig_
double getTau() const
double getStocAPriori() const
void setSType(SType type)
void setStocAPriori(double)
const QString & getName() const
double getConvAPriori() const
SType getSType() const
double getPwlStep() const
void setArcStep(double s)
const QString & getScaleName() const
void setTau(double tau)
double getPwlAPriori() const
double getWhiteNoise() const
void setPwlStep(double s)
void setPwlAPriori(double)
void setWhiteNoise(double w)
void setPMode(PMode mode)
PMode getPMode() const
double getArcStep() const
void setConvAPriori(double)
const SgParameterCfg & getParameter(int i) const