General Purpose Geodetic Library
SgGuiVlbiSourceList.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 
24 
25 #include <SgLogger.h>
26 
27 #include <SgGuiVlbiSourceList.h>
28 
29 #if QT_VERSION >= 0x050000
30 # include <QtWidgets/QBoxLayout>
31 # include <QtWidgets/QGroupBox>
32 # include <QtWidgets/QLabel>
33 # include <QtWidgets/QLineEdit>
34 # include <QtWidgets/QMessageBox>
35 # include <QtWidgets/QPushButton>
36 #else
37 # include <QtGui/QBoxLayout>
38 # include <QtGui/QGroupBox>
39 # include <QtGui/QLabel>
40 # include <QtGui/QLineEdit>
41 # include <QtGui/QMessageBox>
42 # include <QtGui/QPushButton>
43 #endif
44 
45 #include <QtGui/QFontMetrics>
46 
47 
49 {
51  SCI_NAME = 1,
56  //
67  //
74 };
75 
76 
78 {
79  MCI_IDX = 0,
80  MCI_X = 1,
81  MCI_Y = 2,
82  MCI_ER = 3,
83  MCI_K = 4,
84  MCI_EK = 5,
85  MCI_B = 6,
86  MCI_EB = 7,
87 };
88 
89 
90 
91 
92 /*=======================================================================================================
93 *
94 * SgGuiVlbiSourceItem METHODS:
95 *
96 *======================================================================================================*/
98 {
99  int column=treeWidget()->sortColumn();
100  double dL, dR;
101  bool isOk;
102  dL = text(column).toDouble(&isOk);
103  if (isOk)
104  {
105  dR = other.text(column).toDouble(&isOk);
106  if (isOk)
107  return dL < dR;
108  };
109  return QTreeWidgetItem::operator<(other);
110 };
111 /*=====================================================================================================*/
112 
113 
114 
115 
116 /*=======================================================================================================
117 *
118 * SgGuiVlbiSourceList METHODS:
119 *
120 *======================================================================================================*/
122  QMap<QString, SgVlbiSourceInfo*>* map, QWidget* parent, Qt::WindowFlags f)
123  : QWidget(parent, f),
124  ownerName_(ownerName)
125 {
126  browseMode_ = mode;
127  constColumns_ = -1;
128  sourcesByName_ = map;
129  scl4delay_ = 1.0e12;
130  scl4rate_ = 1.0e15;
131  QString str;
132  QBoxLayout *layout=new QVBoxLayout(this);
133  QStringList headerLabels;
134  headerLabels
135  << "Idx"
136  << "Name"
137  << "Scans"
138  << "Tot.Obs"
139  << "GoodObs"
140  << "Prc.Obs"
141  ;
142  switch (browseMode_)
143  {
144  case OBM_BAND:
145  constColumns_ = 12;
146  headerLabels
147  << "Disp(ps)"
148  << "Disp(fs/s)"
149  << "Sig0(ps)"
150  << "Sig0(fs/s)"
151  << "WRMS(ps)"
152  << "WRMS(fs/s)"
153  ;
154  break;
155  case OBM_SESSION:
156  constColumns_ = 7;
157  headerLabels
158  << "WRMS(ps)"
159 // << "WRMS(fs/s)"
160  << "Omit"
161  << "k:Est"
162  << "k:C"
163  << "E.A."
164  << "E.A.Status"
165  << "2E.A."
166  << "2Estd"
167  << "UseSSM"
168  << "#SSMpts"
169  ;
170  break;
171  case OBM_PROJECT:
172  break;
173  };
174  //
175  tweSources_ = new SgGuiQTreeWidgetExt(this);
176  tweSources_->setColumnCount(headerLabels.count());
177  tweSources_->setHeaderLabels(headerLabels);
178 
179  QMap<QString, SgVlbiSourceInfo*>::const_iterator i = sourcesByName_->constBegin();
180  for (; i!=sourcesByName_->constEnd(); ++i)
181  {
182  SgVlbiSourceInfo* srInfo = i.value();
183 
185  item->setSrInfo(srInfo);
186  item->setText(SCI_NUMBER, str.sprintf("%4d", srInfo->getIdx()));
187  item->setData(SCI_NUMBER, Qt::TextAlignmentRole, Qt::AlignRight);
188  item->setText(SCI_NAME, srInfo->getKey());
189  item->setData(SCI_NAME, Qt::TextAlignmentRole, Qt::AlignLeft);
190  item->setText(SCI_TOT_SCANS, str.sprintf("%7d", srInfo->getTotalScanNum()));
191  item->setData(SCI_TOT_SCANS, Qt::TextAlignmentRole, Qt::AlignRight);
192  item->setText(SCI_TOT_OBS, str.sprintf("%7d", srInfo->numTotal(DT_DELAY)));
193  item->setData(SCI_TOT_OBS, Qt::TextAlignmentRole, Qt::AlignRight);
194  item->setText(SCI_USB_OBS, str.sprintf("%7d", srInfo->numUsable(DT_DELAY)));
195  item->setData(SCI_USB_OBS, Qt::TextAlignmentRole, Qt::AlignRight);
196  item->setText(SCI_PRC_OBS, str.sprintf("%7d", srInfo->numProcessed(DT_DELAY)));
197  item->setData(SCI_PRC_OBS, Qt::TextAlignmentRole, Qt::AlignRight);
198 
199  if (browseMode_==OBM_BAND)
200  {
201  item->setText(SCI_B_DISP_DEL, str.sprintf("%.1f", srInfo->dispersion(DT_DELAY)*scl4delay_));
202  item->setData(SCI_B_DISP_DEL, Qt::TextAlignmentRole, Qt::AlignRight);
203  item->setText(SCI_B_DISP_RAT, str.sprintf("%.1f", srInfo->dispersion(DT_RATE )*scl4rate_));
204  item->setData(SCI_B_DISP_RAT, Qt::TextAlignmentRole, Qt::AlignRight);
205  item->setText(SCI_B_SIG0_DEL, str.sprintf("%.1f", srInfo->getSigma2add(DT_DELAY)*scl4delay_));
206  item->setData(SCI_B_SIG0_DEL, Qt::TextAlignmentRole, Qt::AlignRight);
207  item->setText(SCI_B_SIG0_RAT, str.sprintf("%.1f", srInfo->getSigma2add(DT_RATE )*scl4rate_));
208  item->setData(SCI_B_SIG0_RAT, Qt::TextAlignmentRole, Qt::AlignRight);
209  item->setText(SCI_B_WRMS_DEL, str.sprintf("%.1f", srInfo->wrms(DT_DELAY)*scl4delay_));
210  item->setData(SCI_B_WRMS_DEL, Qt::TextAlignmentRole, Qt::AlignRight);
211  item->setText(SCI_B_WRMS_RAT, str.sprintf("%.1f", srInfo->wrms(DT_RATE )*scl4rate_));
212  item->setData(SCI_B_WRMS_RAT, Qt::TextAlignmentRole, Qt::AlignRight);
213  }
214  else if (browseMode_==OBM_SESSION)
215  {
216  item->setText(SCI_S_WRMS_DEL, str.sprintf("%.1f", srInfo->wrms(DT_DELAY)*scl4delay_));
217  item->setData(SCI_S_WRMS_DEL, Qt::TextAlignmentRole, Qt::AlignRight);
218 // item->setText(SCI_S_WRMS_RAT, str.sprintf("%.1f", srInfo->wrms(DT_RATE )*scl4rate_));
219 // item->setData(SCI_S_WRMS_RAT, Qt::TextAlignmentRole, Qt::AlignRight);
220  item->setText(SCI_S_IGNORE, srInfo->isAttr(SgVlbiSourceInfo::Attr_NOT_VALID)? "X" : "");
221  item->setData(SCI_S_IGNORE, Qt::TextAlignmentRole, Qt::AlignCenter);
222  item->setText(SCI_S_COO_EST, srInfo->isAttr(SgVlbiSourceInfo::Attr_ESTIMATE_COO)? "Y" : "");
223  item->setData(SCI_S_COO_EST, Qt::TextAlignmentRole, Qt::AlignCenter);
224  item->setText(SCI_S_COO_CON, srInfo->isAttr(SgVlbiSourceInfo::Attr_CONSTRAIN_COO)? "*" : "");
225  item->setData(SCI_S_COO_CON, Qt::TextAlignmentRole, Qt::AlignCenter);
226  item->setText(SCI_S_AP_EXIST, srInfo->isAttr(SgVlbiSourceInfo::Attr_HAS_A_PRIORI_POS)?"Y":"-");
227  item->setData(SCI_S_AP_EXIST, Qt::TextAlignmentRole, Qt::AlignCenter);
228  item->setText(SCI_S_AP_COMMENT, srInfo->getAprioriComments());
229  item->setData(SCI_S_AP_COMMENT, Qt::TextAlignmentRole, Qt::AlignLeft);
230  item->setText(SCI_S_AL_2EXT, str.sprintf("%.3f", srInfo->getAl2ExtA()*RAD2MAS));
231  item->setData(SCI_S_AL_2EXT, Qt::TextAlignmentRole, Qt::AlignRight);
232  item->setText(SCI_S_AL_2EST, str.sprintf("%.3f", srInfo->getAl2Estd()*RAD2MAS));
233  item->setData(SCI_S_AL_2EST, Qt::TextAlignmentRole, Qt::AlignRight);
234  str = "";
236  {
237  str = "Y";
238  if (srInfo->calcNumOfEstimatedSsmParameters())
239  str += QString("").sprintf("(%d)", srInfo->calcNumOfEstimatedSsmParameters());
240  };
241  item->setText(SCI_S_USE_SSM, str);
242  item->setData(SCI_S_USE_SSM, Qt::TextAlignmentRole, Qt::AlignCenter);
243  item->setText(SCI_S_SSM_PTS, srInfo->sModel().size()?str.sprintf("%d", srInfo->sModel().size()):"");
244  item->setData(SCI_S_SSM_PTS, Qt::TextAlignmentRole, Qt::AlignRight);
245  };
246  };
247 
248  tweSources_->header()->resizeSections(QHeaderView::ResizeToContents);
249  #if QT_VERSION >= 0x050000
250  tweSources_->header()->setSectionResizeMode(QHeaderView::Interactive);
251 #else
252  tweSources_->header()->setResizeMode(QHeaderView::Interactive);
253 #endif
254  tweSources_->header()->setStretchLastSection(false);
255 
256  tweSources_->setSortingEnabled(true);
257  tweSources_->setUniformRowHeights(true);
258  tweSources_->sortByColumn(1, Qt::AscendingOrder);
259  tweSources_->setFocus();
260  tweSources_->setItemsExpandable(false);
261  tweSources_->setAllColumnsShowFocus(true);
262 
263  layout->addWidget(tweSources_);
264 
265  if (browseMode_!=OBM_BAND)
266  connect(tweSources_,
267  SIGNAL(moveUponItem(QTreeWidgetItem*, int, Qt::MouseButton, Qt::KeyboardModifiers)),
268  SLOT (toggleEntryMoveEnable(QTreeWidgetItem*, int, Qt::MouseButton, Qt::KeyboardModifiers)));
269 
270  connect(tweSources_,
271  SIGNAL(itemDoubleClicked (QTreeWidgetItem*, int)),
272  SLOT (entryDoubleClicked(QTreeWidgetItem*, int))
273  );
274 
275 };
276 
277 
278 
279 //
281  Qt::MouseButton /* mouseButtonState */, Qt::KeyboardModifiers /* modifiers */)
282 {
283  if (!item) // may be NULL
284  return;
285 
286  SgVlbiSourceInfo* srInfo=((SgGuiVlbiSourceItem*)item)->getSrInfo();
287  QString str("");
288  switch (n)
289  {
290  case SCI_S_IGNORE:
292  item->setText(SCI_S_IGNORE, srInfo->isAttr(SgVlbiSourceInfo::Attr_NOT_VALID)? "X" : "");
293  break;
294  case SCI_S_COO_EST:
296  item->setText(SCI_S_COO_EST, srInfo->isAttr(SgVlbiSourceInfo::Attr_ESTIMATE_COO)? "Y" : "");
297  break;
298  case SCI_S_COO_CON:
300  item->setText(SCI_S_COO_CON, srInfo->isAttr(SgVlbiSourceInfo::Attr_CONSTRAIN_COO)? "*" : "");
301  break;
302  case SCI_S_USE_SSM:
304  str = "";
306  {
307  str = "Y";
308  if (srInfo->calcNumOfEstimatedSsmParameters())
309  str += QString("").sprintf("(%d)", srInfo->calcNumOfEstimatedSsmParameters());
310  };
311  item->setText(SCI_S_USE_SSM, str);
312  break;
313  default:
314  //std::cout << "default, n=" << n << "\n";
315  break;
316  };
317 };
318 
319 
320 
321 //
323 {
324  if (!item || column>=constColumns_)
325  return;
326  SgVlbiSourceInfo *src = ((SgGuiVlbiSourceItem*)item)->getSrInfo();
327  if (src)
328  {
329  if (browseMode_ == OBM_SESSION)
330  {
331  SgGuiVlbiSrcInfoEditor *siEditor=new SgGuiVlbiSrcInfoEditor(src, ownerName_, this);
332  connect(siEditor, SIGNAL(contentModified(bool)), SLOT(modifySourceInfo(bool)));
333  siEditor->show();
334  };
335  };
336 };
337 
338 
339 
340 //
342 {
343  if (isModified)
344  updateContent();
345 };
346 
347 
348 
349 //
351 {
352  QString str("");
353  SgVlbiSourceInfo *srInfo=NULL;
354  SgGuiVlbiSourceItem *item=NULL;
355  QTreeWidgetItemIterator it(tweSources_);
356  while (*it)
357  {
358  item = (SgGuiVlbiSourceItem*)(*it);
359  srInfo = item->getSrInfo();
360  item->setText(SCI_NUMBER, str.sprintf("%4d", srInfo->getIdx()));
361  item->setText(SCI_NAME, srInfo->getKey());
362  item->setText(SCI_TOT_SCANS, str.sprintf("%7d", srInfo->getTotalScanNum()));
363  item->setText(SCI_TOT_OBS, str.sprintf("%7d", srInfo->numTotal(DT_DELAY)));
364  item->setText(SCI_USB_OBS, str.sprintf("%7d", srInfo->numUsable(DT_DELAY)));
365  item->setText(SCI_PRC_OBS, str.sprintf("%7d", srInfo->numProcessed(DT_DELAY)));
366  if (browseMode_==OBM_BAND)
367  {
368  item->setText(SCI_B_DISP_DEL, str.sprintf("%.1f", srInfo->dispersion(DT_DELAY)*scl4delay_));
369  item->setText(SCI_B_DISP_RAT, str.sprintf("%.1f", srInfo->dispersion(DT_RATE )*scl4rate_));
370  item->setText(SCI_B_SIG0_DEL, str.sprintf("%.1f", srInfo->getSigma2add(DT_DELAY)*scl4delay_));
371  item->setText(SCI_B_SIG0_RAT, str.sprintf("%.1f", srInfo->getSigma2add(DT_RATE )*scl4rate_));
372  item->setText(SCI_B_WRMS_DEL, str.sprintf("%.1f", srInfo->wrms(DT_DELAY)*scl4delay_));
373  item->setText(SCI_B_WRMS_RAT, str.sprintf("%.1f", srInfo->wrms(DT_RATE )*scl4rate_));
374  }
375  else if (browseMode_==OBM_SESSION)
376  {
377  item->setText(SCI_S_WRMS_DEL, str.sprintf("%.1f", srInfo->wrms(DT_DELAY)*scl4delay_));
378 // item->setText(SCI_S_WRMS_RAT, str.sprintf("%.1f", srInfo->wrms(DT_RATE )*scl4rate_));
379  item->setText(SCI_S_IGNORE, srInfo->isAttr(SgVlbiSourceInfo::Attr_NOT_VALID)? "X" : "");
380  item->setText(SCI_S_COO_EST, srInfo->isAttr(SgVlbiSourceInfo::Attr_ESTIMATE_COO)? "Y" : "");
381  item->setText(SCI_S_COO_CON, srInfo->isAttr(SgVlbiSourceInfo::Attr_CONSTRAIN_COO)? "*" : "");
382  item->setText(SCI_S_AP_EXIST, srInfo->isAttr(SgVlbiSourceInfo::Attr_HAS_A_PRIORI_POS)?"Y":"-");
383  item->setText(SCI_S_AP_COMMENT, srInfo->getAprioriComments());
384  item->setText(SCI_S_AL_2EXT, str.sprintf("%.3f", srInfo->getAl2ExtA()*RAD2MAS));
385  item->setText(SCI_S_AL_2EST, str.sprintf("%.3f", srInfo->getAl2Estd()*RAD2MAS));
386  str = "";
388  {
389  str = "Y";
390  if (srInfo->calcNumOfEstimatedSsmParameters())
391  str += QString("").sprintf("(%d)", srInfo->calcNumOfEstimatedSsmParameters());
392  };
393  item->setText(SCI_S_USE_SSM, str);
394  item->setText(SCI_S_SSM_PTS, srInfo->sModel().size()?str.sprintf("%d", srInfo->sModel().size()):"");
395  };
396  ++it;
397  };
398 };
399 /*=====================================================================================================*/
400 
401 
402 
403 
404 
405 
406 
407 /*=======================================================================================================
408 *
409 * SgGuiVlbiSrcInfoEditor METHODS:
410 *
411 *======================================================================================================*/
413  QWidget* parent, Qt::WindowFlags flags)
414  : QDialog(parent, flags)
415 {
416  static const QString attrNames[] =
417  {
418  QString("Ignore the source"),
419  QString("Estimate source positions"),
420  QString("Constrain source position in estimation"),
421  QString("Apply the multi point source structure model"),
422  QString("Test"),
423  };
424  const int numOfAttr=5;
425  QString str;
426  QSize btnSize;
427  sourceInfo_ = srcInfo;
428  isModified_ = false;
429 
430  setWindowTitle("The source " + sourceInfo_->getKey() + " at " + ownerName + " session");
431 
432  //
433  QVBoxLayout *mainLayout=new QVBoxLayout(this);
434 
435  // clock breaks:
436  QGroupBox *gBox=new QGroupBox("Components of the multi point source structure model",
437  this);
438  QBoxLayout *layout=new QVBoxLayout(gBox);
439  QStringList headerLabels;
440  headerLabels
441  << "idx"
442  << "x (mas)"
443  << "y (mas)"
444  << "Est P?"
445  << "k"
446  << "Est K?"
447  << "B"
448  << "Est B?"
449  ;
450 
452  twSrcStModels_->setColumnCount(8);
453  twSrcStModels_->setHeaderLabels(headerLabels);
454  //
455  //
456  for (int i=0; i<sourceInfo_->sModel().size(); i++)
457  {
459  *ss=&sourceInfo_->sModel()[i];
461  item->setPoint(ss);
462  item->setModelIdx(i);
463 
464  item->setText(MCI_IDX, QString("").sprintf("%d", i));
465  item->setData(MCI_IDX, Qt::TextAlignmentRole, Qt::AlignRight);
466 
467  item->setText(MCI_X, QString("").sprintf("%.4f", ss->getX()*RAD2MAS));
468  item->setData(MCI_X, Qt::TextAlignmentRole, Qt::AlignRight);
469 
470  item->setText(MCI_Y, QString("").sprintf("%.4f", ss->getY()*RAD2MAS));
471  item->setData(MCI_Y, Qt::TextAlignmentRole, Qt::AlignRight);
472 
473  item->setText(MCI_ER, ss->getEstimatePosition()?"Y":"N");
474  item->setData(MCI_ER, Qt::TextAlignmentRole, Qt::AlignCenter);
475 
476  item->setText(MCI_K, QString("").sprintf("%.4f", ss->getK()));
477  item->setData(MCI_K, Qt::TextAlignmentRole, Qt::AlignRight);
478 
479  item->setText(MCI_EK, ss->getEstimateRatio()?"Y":"N");
480  item->setData(MCI_EK, Qt::TextAlignmentRole, Qt::AlignCenter);
481 
482  item->setText(MCI_B, QString("").sprintf("%.4f", ss->getB()));
483  item->setData(MCI_B, Qt::TextAlignmentRole, Qt::AlignRight);
484 
485  item->setText(MCI_EB, ss->getEstimateSpIdx()?"Y":"N");
486  item->setData(MCI_EB, Qt::TextAlignmentRole, Qt::AlignCenter);
487  };
488  twSrcStModels_->resizeColumnToContents(0);
489  twSrcStModels_->resizeColumnToContents(1);
490  twSrcStModels_->resizeColumnToContents(2);
491  twSrcStModels_->resizeColumnToContents(3);
492  twSrcStModels_->resizeColumnToContents(4);
493  twSrcStModels_->resizeColumnToContents(5);
494  twSrcStModels_->resizeColumnToContents(6);
495  twSrcStModels_->resizeColumnToContents(7);
496 
497  twSrcStModels_->header()->resizeSections(QHeaderView::ResizeToContents);
498 #if QT_VERSION >= 0x050000
499  twSrcStModels_->header()->setSectionResizeMode(QHeaderView::Interactive);
500 #else
501  twSrcStModels_->header()->setResizeMode(QHeaderView::Interactive);
502 #endif
503  twSrcStModels_->header()->setStretchLastSection(false);
504  twSrcStModels_->setSortingEnabled(true);
505  twSrcStModels_->setUniformRowHeights(true);
506  twSrcStModels_->sortByColumn(0, Qt::AscendingOrder);
507  twSrcStModels_->setFocus();
508  twSrcStModels_->setItemsExpandable(false);
509  twSrcStModels_->setAllColumnsShowFocus(true);
510  twSrcStModels_->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
511  twSrcStModels_->setMinimumSize(twSrcStModels_->sizeHint());
512  layout->addWidget(twSrcStModels_);
513 
514  QPushButton *bAdd =new QPushButton("Add", this);
515  QPushButton *bEdit =new QPushButton("Edit", this);
516  QPushButton *bDelete=new QPushButton("Delete", this);
517 
518  bDelete->setMinimumSize((btnSize=bDelete->sizeHint()));
519  bAdd->setMinimumSize(btnSize);
520  bEdit->setMinimumSize(btnSize);
521 
522  QBoxLayout *subLayout=new QHBoxLayout();
523  layout->addLayout(subLayout);
524  subLayout->addStretch(1);
525  subLayout->addSpacing(3*btnSize.width());
526  subLayout->addWidget(bAdd);
527  subLayout->addWidget(bEdit);
528  subLayout->addWidget(bDelete);
529 
530  mainLayout->addWidget(gBox);
531 
532  // attributes:
533  QGroupBox *gboxAttr=new QGroupBox("Attributes of Source", this);
534  layout = new QVBoxLayout(gboxAttr);
535  for (int i=0; i<numOfAttr; i++)
536  {
537  cbAttributes_[i] = new QCheckBox(attrNames[i], gboxAttr);
538  cbAttributes_[i]->setMinimumSize(cbAttributes_[i]->sizeHint());
539  layout->addWidget(cbAttributes_[i]);
540  };
546  //
547  // options:
548  mainLayout->addSpacing(15);
549  mainLayout->addWidget(gboxAttr, 10);
550  //
551  //
552  //---
553  subLayout = new QHBoxLayout();
554  mainLayout->addSpacing(15);
555  mainLayout->addStretch(1);
556  mainLayout->addLayout(subLayout);
557 
558  QPushButton *bOk=new QPushButton("OK", this);
559  QPushButton *bCancel=new QPushButton("Cancel", this);
560  bOk->setDefault(true);
561 
562  bCancel->setMinimumSize((btnSize=bCancel->sizeHint()));
563  bOk->setMinimumSize(btnSize);
564 
565  subLayout->addStretch(1);
566  subLayout->addWidget(bOk);
567  subLayout->addWidget(bCancel);
568 
569 
570  connect(twSrcStModels_,
571  SIGNAL(moveUponItem(QTreeWidgetItem*, int, Qt::MouseButton, Qt::KeyboardModifiers)),
572  SLOT (toggleEntryMoveEnable(QTreeWidgetItem*, int, Qt::MouseButton, Qt::KeyboardModifiers)));
573 
574  connect(twSrcStModels_, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
575  SLOT(editSrcStModel(QTreeWidgetItem*, int)));
576 
577  connect(bOk, SIGNAL(clicked()), SLOT(accept()));
578  connect(bAdd, SIGNAL(clicked()), SLOT(insertSsmPoint()));
579  connect(bEdit, SIGNAL(clicked()), SLOT(editSsmPoint()));
580  connect(bDelete, SIGNAL(clicked()), SLOT(deleteSsmPoint()));
581  connect(bCancel, SIGNAL(clicked()), SLOT(reject()));
582 
583  mainLayout->activate();
584 };
585 
586 
587 
588 //
590 {
591  sourceInfo_ = NULL;
593 };
594 
595 
596 
597 //
599  Qt::MouseButton /* mouseButtonState */, Qt::KeyboardModifiers /* modifiers */)
600 {
601  if (!item) // may be NULL
602  return;
603 
605  ss=((SgGuiVlbiSrcStrModelItem*)item)->getPoint();
606  QString str("");
607  switch (n)
608  {
609  case MCI_ER:
611  item->setText(MCI_ER, ss->getEstimatePosition()?"Y":"N");
612  isModified_ = true;
613  break;
614  case MCI_EK:
616  item->setText(MCI_EK, ss->getEstimateRatio()?"Y":"N");
617  isModified_ = true;
618  break;
619  case MCI_EB:
621  item->setText(MCI_EB, ss->getEstimateSpIdx()?"Y":"N");
622  isModified_ = true;
623  break;
624  default:
625  //std::cout << "default, n=" << n << "\n";
626  break;
627  };
628 };
629 
630 
631 
632 //
634 {
635  acquireData();
637  QDialog::accept();
638  deleteLater();
639 };
640 
641 
642 
643 //
645 {
646  // Attributes:
648  {
650  isModified_ = true;
651  };
653  {
655  isModified_ = true;
656  };
658  {
660  isModified_ = true;
661  };
663  {
665  isModified_ = true;
666  };
668  {
670  isModified_ = true;
671  };
672 };
673 
674 
675 
676 //
678 {
679  if (item && column>-1)
680  {
681  SgGuiVlbiSrcStrModelEditor *ssmEditor=
683  connect(ssmEditor, SIGNAL(ssmPointModified(bool)), SLOT(updateModifyStatus(bool)));
684  ssmEditor->show();
685  };
686 };
687 
688 
689 
690 //
692 {
693  isModified_ = isModified_ || isModified;
694 };
695 
696 
697 
698 //
700 {
701  if (twSrcStModels_->selectedItems().size())
702  {
703  SgGuiVlbiSrcStrModelEditor *ssmEditor=
705  (SgGuiVlbiSrcStrModelItem*)(twSrcStModels_->selectedItems().at(0)), this);
706  connect (ssmEditor, SIGNAL(ssmPointModified(bool)), SLOT(updateModifyStatus(bool)));
707  ssmEditor->show();
708  };
709 };
710 
711 
712 
713 //
715 {
716  if (twSrcStModels_->selectedItems().size())
717  {
718  SgGuiVlbiSrcStrModelItem *item=(SgGuiVlbiSrcStrModelItem*)(twSrcStModels_->selectedItems().at(0));
720  *p=item->getPoint();
721  int idx=item->getModelIdx();
722  if (QMessageBox::warning(this, "Delete?",
723  "Are you sure to delete a component #" + QString("").setNum(idx) +
724  " of a source structure model at " +
725  QString("").sprintf("(x=%.4f, y=%.4f)?\n", p->getX()*RAD2MAS, p->getY()*RAD2MAS),
726  QMessageBox::No | QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes)
727  {
728  delete item;
729  sourceInfo_->sModel().removeAt(idx);
730  isModified_ = true;
731  };
732  };
733 };
734 
735 
736 
737 //
739 {
741  connect (ssmEditor, SIGNAL(ssmPointModified(bool)), SLOT(updateModifyStatus(bool)));
742  connect (ssmEditor, SIGNAL(ssmPointCreated(SgVlbiSourceInfo::StructModelMp*)),
744  ssmEditor->show();
745 };
746 
747 
748 
749 //
751 {
752  if (ss)
753  {
754  int idx=sourceInfo_->sModel().size();
755  sourceInfo_->sModel().append(*ss);
757  item->setPoint(ss);
758  item->setModelIdx(idx);
759 /*
760  item->setText( 0, QString("").sprintf("%d", idx));
761  item->setData( 0, Qt::TextAlignmentRole, Qt::AlignRight);
762  item->setText( 1, QString("").sprintf("%.4f", ss->getX()*RAD2MAS));
763  item->setData( 1, Qt::TextAlignmentRole, Qt::AlignRight);
764  item->setText( 2, QString("").sprintf("%.4f", ss->getY()*RAD2MAS));
765  item->setData( 2, Qt::TextAlignmentRole, Qt::AlignRight);
766  item->setText( 3, ss->getEstimatePosition()?"Y":"N");
767  item->setData( 3, Qt::TextAlignmentRole, Qt::AlignCenter);
768  item->setText( 4, QString("").sprintf("%.4f", ss->getK()));
769  item->setData( 4, Qt::TextAlignmentRole, Qt::AlignRight);
770  item->setText( 5, ss->getEstimateRatio()?"Y":"N");
771  item->setData( 5, Qt::TextAlignmentRole, Qt::AlignCenter);
772  item->setText( 6, QString("").sprintf("%.4f", ss->getB()));
773  item->setData( 6, Qt::TextAlignmentRole, Qt::AlignRight);
774  item->setText( 7, ss->getEstimateSpIdx()?"Y":"N");
775  item->setData( 7, Qt::TextAlignmentRole, Qt::AlignCenter);
776 */
777  item->setText(MCI_IDX, QString("").sprintf("%d", idx));
778  item->setData(MCI_IDX, Qt::TextAlignmentRole, Qt::AlignRight);
779  item->setText(MCI_X, QString("").sprintf("%.4f", ss->getX()*RAD2MAS));
780  item->setData(MCI_X, Qt::TextAlignmentRole, Qt::AlignRight);
781  item->setText(MCI_Y, QString("").sprintf("%.4f", ss->getY()*RAD2MAS));
782  item->setData(MCI_Y, Qt::TextAlignmentRole, Qt::AlignRight);
783  item->setText(MCI_ER, ss->getEstimatePosition()?"Y":"N");
784  item->setData(MCI_ER, Qt::TextAlignmentRole, Qt::AlignCenter);
785  item->setText(MCI_K, QString("").sprintf("%.4f", ss->getK()));
786  item->setData(MCI_K, Qt::TextAlignmentRole, Qt::AlignRight);
787  item->setText(MCI_EK, ss->getEstimateRatio()?"Y":"N");
788  item->setData(MCI_EK, Qt::TextAlignmentRole, Qt::AlignCenter);
789  item->setText(MCI_B, QString("").sprintf("%.4f", ss->getB()));
790  item->setData(MCI_B, Qt::TextAlignmentRole, Qt::AlignRight);
791  item->setText(MCI_EB, ss->getEstimateSpIdx()?"Y":"N");
792  item->setData(MCI_EB, Qt::TextAlignmentRole, Qt::AlignCenter);
793 // twSrcStModels_->resizeColumnToContents(0);
794  twSrcStModels_->resizeColumnToContents(1);
795  twSrcStModels_->resizeColumnToContents(2);
796 // twSrcStModels_->resizeColumnToContents(3);
797  twSrcStModels_->resizeColumnToContents(4);
798 // twSrcStModels_->resizeColumnToContents(5);
799  twSrcStModels_->resizeColumnToContents(6);
800 // twSrcStModels_->resizeColumnToContents(7);
801  };
802 };
803 /*=====================================================================================================*/
804 
805 
806 
807 
808 
809 
810 
811 
812 
813 /*=======================================================================================================
814 *
815 * SgGuiVlbiSrcStrModelEditor METHODS:
816 *
817 *======================================================================================================*/
819  SgGuiVlbiSrcStrModelItem* twItem, QWidget* parent, Qt::WindowFlags flags)
820  : QDialog(parent, flags)
821 {
822  src_ = src;
823  twItem_ = twItem;
824  ssmPoint_ = twItem_?twItem_->getPoint():NULL;
825  isModified_ = false;
826  isNewPoint_ = false;
827  setWindowTitle("SS Model Editor");
828 
829  QLabel *label;
830  QGroupBox *gbox;
831  QBoxLayout *layout, *subLayout;
832  QGridLayout *grid;
833 
834  QString str;
835 
836  if (!ssmPoint_)
837  {
838  ssmPoint_ = new SgVlbiSourceInfo::StructModelMp(0.0, 0.0, 0.0, 0.0, false, false, false);
839  isModified_ = true;
840  isNewPoint_ = true;
841  };
842 
843  gbox = new QGroupBox("SS Model", this);
844  grid = new QGridLayout(gbox);
845 
846  label= new QLabel("x (mas):", gbox);
847  label->setMinimumSize(label->sizeHint());
848  grid ->addWidget(label, 0, 0, Qt::AlignLeft | Qt::AlignVCenter);
849  label= new QLabel("y (mas):", gbox);
850  label->setMinimumSize(label->sizeHint());
851  grid ->addWidget(label, 1, 0, Qt::AlignLeft | Qt::AlignVCenter);
852  label= new QLabel("k: ", gbox);
853  label->setMinimumSize(label->sizeHint());
854  grid ->addWidget(label, 2, 0, Qt::AlignLeft | Qt::AlignVCenter);
855  label= new QLabel("b: ", gbox);
856  label->setMinimumSize(label->sizeHint());
857  grid ->addWidget(label, 3, 0, Qt::AlignLeft | Qt::AlignVCenter);
858 
859 
860  //
861  leX_ = new QLineEdit(str.sprintf("%.4f", ssmPoint_->getX()*RAD2MAS), gbox);
862  leX_->setFixedWidth(leX_->fontMetrics().width("YYYYYYYY") + 10);
863  grid ->addWidget(leX_, 0, 1);
864 
865  leY_ = new QLineEdit(str.sprintf("%.4f", ssmPoint_->getY()*RAD2MAS), gbox);
866  leY_->setFixedWidth(leY_->fontMetrics().width("YYYYYYYY") + 10);
867  grid ->addWidget(leY_, 1, 1);
868 
869  leK_ = new QLineEdit(str.sprintf("%.4f", ssmPoint_->getK()), gbox);
870  leK_->setFixedWidth(leK_->fontMetrics().width("YYYYYYYY") + 10);
871  grid ->addWidget(leK_, 2, 1);
872 
873  leB_ = new QLineEdit(str.sprintf("%.4f", ssmPoint_->getB()), gbox);
874  leB_->setFixedWidth(leB_->fontMetrics().width("YYYYYYYY") + 10);
875  grid ->addWidget(leB_, 3, 1);
876 
877 
878  grid->addItem(new QSpacerItem(15, 0), 0, 6);
879 
880 
881  //---
882  layout = new QVBoxLayout(this);
883  layout -> addWidget(gbox);
884 
885  cbEstPosition_ = new QCheckBox("Estimate position of the component", this);
887  cbEstPosition_->setMinimumSize(cbEstPosition_->sizeHint());
888  layout->addWidget(cbEstPosition_);
889 
890  cbEstK_ = new QCheckBox("Estimate brightness ratio", this);
891  cbEstK_->setChecked(ssmPoint_->getEstimateRatio());
892  cbEstK_->setMinimumSize(cbEstK_->sizeHint());
893  layout->addWidget(cbEstK_);
894 
895  cbEstB_ = new QCheckBox("Estimate a difference of spectral indices", this);
896  cbEstB_->setChecked(ssmPoint_->getEstimateSpIdx());
897  cbEstB_->setMinimumSize(cbEstB_->sizeHint());
898  layout->addWidget(cbEstB_);
899 
900  layout->addSpacing(15);
901 
902  subLayout = new QHBoxLayout();
903  layout->addLayout(subLayout);
904  subLayout->addStretch(1);
905 
906  QPushButton *bOk=new QPushButton("OK", this);
907  QPushButton *bCancel=new QPushButton("Cancel", this);
908  bOk->setDefault(true);
909  QSize btnSize;
910 
911  bCancel->setMinimumSize((btnSize=bCancel->sizeHint()));
912  bOk->setMinimumSize(btnSize);
913  subLayout->addWidget(bOk);
914  subLayout->addWidget(bCancel);
915  connect(bOk, SIGNAL(clicked()), SLOT(accept()));
916  connect(bCancel, SIGNAL(clicked()), SLOT(reject()));
917 };
918 
919 
920 
921 //
923 {
924  acquireData();
925  QDialog::accept();
926  if (isNewPoint_)
928  else if (isModified_)
929  {
930  twItem_->setText( 1, QString("").sprintf("%.4f", ssmPoint_->getX()*RAD2MAS));
931  twItem_->setText( 2, QString("").sprintf("%.4f", ssmPoint_->getY()*RAD2MAS));
932  twItem_->setText( 3, ssmPoint_->getEstimatePosition()?"Y":"N");
933  twItem_->setText( 4, QString("").sprintf("%.4f", ssmPoint_->getK()));
934  twItem_->setText( 5, ssmPoint_->getEstimateRatio()?"Y":"N");
935  twItem_->setText( 6, QString("").sprintf("%.4f", ssmPoint_->getB()));
936  twItem_->setText( 7, ssmPoint_->getEstimateSpIdx()?"Y":"N");
937  };
939  deleteLater();
940 };
941 
942 
943 
944 //
946 {
947  emit ssmPointModified(false);
948  QDialog::reject();
949  if (ssmPoint_ && isNewPoint_)
950  delete ssmPoint_;
951  deleteLater();
952 };
953 
954 
955 
956 //
958 {
959  if (!src_)
960  return;
961 
962  bool isOK=true;
963  double d=0.0;
964 
965  if (isOK)
966  d = leX_->text().toDouble(&isOK);
967  if (isOK && d!=ssmPoint_->getX()*RAD2MAS)
968  {
969  isModified_ = true;
970  ssmPoint_->setX(d/RAD2MAS);
971  };
972  if (isOK)
973  d = leY_->text().toDouble(&isOK);
974  if (isOK && d!=ssmPoint_->getY()*RAD2MAS)
975  {
976  isModified_ = true;
977  ssmPoint_->setY(d/RAD2MAS);
978  };
979 
980  if (isOK)
981  d = leK_->text().toDouble(&isOK);
982  if (isOK && d!=ssmPoint_->getK())
983  {
984  isModified_ = true;
985  ssmPoint_->setK(d);
986  };
987  if (isOK)
988  d = leB_->text().toDouble(&isOK);
989  if (isOK && d!=ssmPoint_->getB())
990  {
991  isModified_ = true;
992  ssmPoint_->setB(d);
993  };
994 
995  if (isOK && cbEstPosition_->isChecked()!=ssmPoint_->getEstimatePosition())
996  {
998  isModified_ = true;
999  };
1000  if (isOK && cbEstK_->isChecked()!=ssmPoint_->getEstimateRatio())
1001  {
1002  ssmPoint_->setEstimateRatio(cbEstK_->isChecked());
1003  isModified_ = true;
1004  };
1005  if (isOK && cbEstB_->isChecked()!=ssmPoint_->getEstimateSpIdx())
1006  {
1007  ssmPoint_->setEstimateSpIdx(cbEstB_->isChecked());
1008  isModified_ = true;
1009  };
1010 };
1011 /*=====================================================================================================*/
1012 
1013 
1014 
1015 
1016 /*=====================================================================================================*/
1017 
1018 
1019 
1020 
1021 
1022 
SourceColumnIndex
@ SCI_S_AL_2EXT
@ SCI_S_COO_EST
@ SCI_S_WRMS_DEL
@ SCI_S_SSM_PTS
@ SCI_B_DISP_DEL
@ SCI_B_WRMS_RAT
@ SCI_NUMBER
@ SCI_PRC_OBS
@ SCI_USB_OBS
@ SCI_S_COO_CON
@ SCI_S_USE_SSM
@ SCI_S_AP_EXIST
@ SCI_B_SIG0_DEL
@ SCI_B_SIG0_RAT
@ SCI_TOT_OBS
@ SCI_S_IGNORE
@ SCI_S_AP_COMMENT
@ SCI_B_DISP_RAT
@ SCI_B_WRMS_DEL
@ SCI_S_AL_2EST
@ SCI_TOT_SCANS
bool operator<(const SgMJD &T1, const SgMJD &T2)
Definition: SgMJD.h:552
#define RAD2MAS
radians to ms:
Definition: SgMathSupport.h:73
SgObjectBrowseMode
Definition: SgObjectInfo.h:46
@ OBM_BAND
Definition: SgObjectInfo.h:46
@ OBM_PROJECT
Definition: SgObjectInfo.h:46
@ OBM_SESSION
Definition: SgObjectInfo.h:46
@ DT_DELAY
Definition: SgWrmsable.h:44
@ DT_RATE
Definition: SgWrmsable.h:45
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void xorAttr(uint a)
Definition: SgAttribute.h:218
SgVlbiSourceInfo * getSrInfo()
void setSrInfo(SgVlbiSourceInfo *info)
virtual bool operator<(const QTreeWidgetItem &other) const
void entryDoubleClicked(QTreeWidgetItem *, int)
void toggleEntryMoveEnable(QTreeWidgetItem *, int, Qt::MouseButton, Qt::KeyboardModifiers)
SgObjectBrowseMode browseMode_
SgGuiQTreeWidgetExt * tweSources_
SgGuiVlbiSourceList(SgObjectBrowseMode, const QString &, QMap< QString, SgVlbiSourceInfo * > *, QWidget *=0, Qt::WindowFlags=0)
QMap< QString, SgVlbiSourceInfo * > * sourcesByName_
void addNewSsmPoint(SgVlbiSourceInfo::StructModelMp *)
SgGuiVlbiSrcInfoEditor(SgVlbiSourceInfo *, const QString &, QWidget *=0, Qt::WindowFlags=0)
void editSrcStModel(QTreeWidgetItem *, int)
void toggleEntryMoveEnable(QTreeWidgetItem *, int, Qt::MouseButton, Qt::KeyboardModifiers)
SgVlbiSourceInfo * sourceInfo_
SgGuiQTreeWidgetExt * twSrcStModels_
SgGuiVlbiSrcStrModelEditor(SgVlbiSourceInfo *, SgGuiVlbiSrcStrModelItem *, QWidget *=0, Qt::WindowFlags=0)
SgVlbiSourceInfo::StructModelMp * ssmPoint_
void ssmPointCreated(SgVlbiSourceInfo::StructModelMp *)
SgGuiVlbiSrcStrModelItem * twItem_
SgVlbiSourceInfo::StructModelMp * getPoint()
void setPoint(SgVlbiSourceInfo::StructModelMp *p)
int getIdx() const
Definition: SgObjectInfo.h:335
double dispersion(DataType, bool=false) const
Definition: SgObjectInfo.h:439
double getSigma2add(DataType) const
Definition: SgObjectInfo.h:367
const QString & getKey() const
Definition: SgObjectInfo.h:319
int numProcessed(DataType dType) const
Definition: SgObjectInfo.h:351
int numUsable(DataType) const
Definition: SgObjectInfo.h:359
double wrms(DataType) const
Definition: SgObjectInfo.h:567
int numTotal(DataType dType) const
Definition: SgObjectInfo.h:343
const QString & getAprioriComments() const
double getAl2Estd() const
double getAl2ExtA() const
int getTotalScanNum() const
QList< StructModelMp > & sModel()
int calcNumOfEstimatedSsmParameters() const
@ Attr_TEST
for testing purposes.
@ Attr_APPLY_SSM
apply the source structure model;
@ Attr_HAS_A_PRIORI_POS
indicates that the source has a priori position;
@ Attr_CONSTRAIN_COO
constrain source position in estimation;
@ Attr_NOT_VALID
omit the source;
@ Attr_ESTIMATE_COO
estimate source position;