Isis 3.0 Programmer Reference
Back | Home
NewControlPointDialog.cpp
1 #include "NewControlPointDialog.h"
2 
3 #include <algorithm>
4 
5 #include <QComboBox>
6 
7 #include <QHBoxLayout>
8 #include <QLabel>
9 #include <QLineEdit>
10 #include <QListWidget>
11 #include <QPushButton>
12 #include <QRadioButton>
13 #include <QString>
14 #include <QtDebug>
15 
16 #include "ControlNet.h"
17 #include "ControlPoint.h"
18 #include "IString.h"
19 #include "SerialNumberList.h"
20 
21 namespace Isis {
39  SerialNumberList *serialNumberList,
40  QString defaultPointId,
41  QWidget *parent) : QDialog(parent) {
42 
43  m_controlNet = controlNet;
44  m_serialNumberList = serialNumberList;
45 
46  m_ptIdEdit = NULL;
47 
48  m_subpixelRegisterButton = NULL;
49  m_fileList = NULL;
50  m_ptIdLabel = NULL;
51  m_okButton = NULL;
52 
53  m_ptIdLabel = new QLabel("Point ID:");
54  m_ptIdEdit = new QLineEdit;
55  m_ptIdLabel->setBuddy(m_ptIdEdit);
56  m_ptIdEdit->setText(defaultPointId);
57  m_ptIdEdit->selectAll();
58  connect(m_ptIdEdit, SIGNAL(textChanged(const QString &)),
59  this, SLOT(enableOkButton(const QString &)));
60 
61  m_pointTypeCombo = new QComboBox;
62  for (int i=0; i<ControlPoint::PointTypeCount; i++) {
63  m_pointTypeCombo->insertItem(i, ControlPoint::PointTypeToString(
65  }
66  m_pointTypeCombo->setCurrentIndex(2);
67  QHBoxLayout *pointTypeLayout = new QHBoxLayout;
68  QLabel *pointTypeLabel = new QLabel("PointType:");
69  pointTypeLayout->addWidget(pointTypeLabel);
70  pointTypeLayout->addWidget(m_pointTypeCombo);
71  connect(m_pointTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pointTypeChanged(int)));
72 
73  m_groundSourceCombo = new QComboBox;
74  QHBoxLayout *m_groundSourceLayout = new QHBoxLayout;
75  QLabel *groundSourceLabel = new QLabel("Ground Source:");
76  m_groundSourceLayout->addWidget(groundSourceLabel);
77  m_groundSourceLayout->addWidget(m_groundSourceCombo);
78  m_groundSourceCombo->setVisible(false);
79 
80  m_subpixelRegisterButton = new QRadioButton("Subpixel Register Measures");
81  m_subpixelRegisterButton->setChecked(true);
82  m_subpixelRegisterButton->setToolTip("Each measure will be subpixel registered to the reference"
83  " as it is created.");
84 
85  QLabel *listLabel = new QLabel("Select Files:");
86 
87  m_fileList = new QListWidget;
88  m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
89 
90  // Create OK & Cancel buttons
91  m_okButton = new QPushButton("OK");
92  // If the last point id used was never saved to network, do not set ok
93  // button to faslse
94  enableOkButton("");
95 
96  QPushButton *cancelButton = new QPushButton("Cancel");
97  QHBoxLayout *buttonLayout = new QHBoxLayout;
98  buttonLayout->addWidget(m_okButton);
99  buttonLayout->addWidget(cancelButton);
100 
101  connect(m_okButton, SIGNAL(clicked()), this, SLOT(accept()));
102  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
103 
104  QHBoxLayout *ptIdLayout = new QHBoxLayout;
105  ptIdLayout->addWidget(m_ptIdLabel);
106  ptIdLayout->addWidget(m_ptIdEdit);
107 
108  QVBoxLayout *vLayout = new QVBoxLayout;
109  vLayout->addLayout(ptIdLayout);
110  vLayout->addLayout(pointTypeLayout);
111  vLayout->addLayout(m_groundSourceLayout);
112  vLayout->addWidget(m_subpixelRegisterButton);
113  vLayout->addWidget(listLabel);
114  vLayout->addWidget(m_fileList);
115  vLayout->addLayout(buttonLayout);
116 
117  setLayout(vLayout);
118  setWindowTitle("Create New ControlPoint");
119 
120  }
121 
122 
123  QString NewControlPointDialog::pointId() const {
124  return m_ptIdEdit->text();
125  }
126 
127 
128  int NewControlPointDialog::pointType() const {
129  return m_pointTypeCombo->currentIndex();
130  }
131 
132 
133  QStringList NewControlPointDialog::selectedFiles() const {
134  QStringList result;
135 
136  foreach (QListWidgetItem *fileItem, m_fileList->selectedItems()) {
137  result.append(fileItem->text());
138  }
139 
140  return result;
141  }
142 
143 
144  bool NewControlPointDialog::subpixelRegisterPoint() {
145  return m_subpixelRegisterButton->isChecked();
146  }
147 
148 
149  QString NewControlPointDialog::groundSource() const {
150  return m_groundSourceCombo->currentText();
151  }
152 
153 
154  void NewControlPointDialog::pointTypeChanged(int pointType) {
155  if (pointType == ControlPoint::Constrained || pointType == ControlPoint::Fixed) {
156  m_groundSourceCombo->setVisible(true);
157  }
158  }
159 
160 
161  void NewControlPointDialog::setGroundSource(QStringList groundFiles, int numberShapesWithPoint) {
162  m_groundSourceCombo->addItems(groundFiles);
163  for (int i = 0; i < numberShapesWithPoint; i++) {
164  m_groundSourceCombo->setItemData(i, QColor(Qt::red), Qt::ForegroundRole);
165  }
166  m_groundSourceCombo->insertSeparator(numberShapesWithPoint);
167  }
168 
169 
178 
179  int bottomMostSelectedItemIndex = 0;
180 
181  for (int i = 0; i < m_serialNumberList->size(); i++) {
182 
183  // build new item...
184  QString label = m_serialNumberList->fileName(i);
185  QListWidgetItem *item = new QListWidgetItem(label);
186 
187  // if this entry of the SerialNumberList is also in the pointFiles then
188  // mark it as selected and insert after the last selected item (toward
189  // the top of the list). Otherwise just add the item to the end of the
190  // list
191  if (pointFiles.contains(label)) {
192  m_fileList->insertItem(bottomMostSelectedItemIndex++, item);
193  item->setSelected(true);
194  }
195  else {
196  m_fileList->addItem(item);
197  }
198  }
199  }
200 
201 
209  m_okButton->setEnabled(!m_ptIdEdit->text().isEmpty() &&
210  !m_controlNet->ContainsPoint(m_ptIdEdit->text()));
211  }
212 }
A Constrained point is a Control Point whose lat/lon/radius is somewhat established and should not be...
Definition: ControlPoint.h:361
A Fixed point is a Control Point whose lat/lon is well established and should not be changed...
Definition: ControlPoint.h:356
bool ContainsPoint(QString pointId) const
Definition: ControlNet.cpp:781
int size() const
How many serial number / filename combos are in the list.
NewControlPointDialog(ControlNet *controlNet, SerialNumberList *serialNumberList, QString defaultPointId, QWidget *parent=0)
NewControlPointDialog constructor.
PointType
These are the valid &#39;types&#39; of point.
Definition: ControlPoint.h:349
QString fileName(const QString &sn)
Return a filename given a serial number.
void enableOkButton(const QString &text)
a control network
Definition: ControlNet.h:207
void setFiles(QStringList pointFiles)
Serial Number list generator.
static QString PointTypeToString(PointType type)
Obtain a string representation of a given PointType.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:24:26