Isis 3 Programmer Reference
QnetFixedPointDialog.cpp
1 #include "QnetFixedPointDialog.h"
2 
3 
4 #include <QDialog>
5 #include <QGroupBox>
6 #include <QLabel>
7 #include <QLineEdit>
8 #include <QListWidget>
9 #include <QPushButton>
10 #include <QRadioButton>
11 #include <QtWidgets>
12 #include <QVBoxLayout>
13 
14 
15 #include <algorithm>
16 
17 #include "SerialNumberList.h"
18 #include "ControlPoint.h"
19 #include "Camera.h"
20 #include "QnetTool.h"
21 
22 using namespace std;
23 
24 namespace Isis {
36  QnetFixedPointDialog::QnetFixedPointDialog(QnetTool *qnetTool, QString defaultPointId,
37  QWidget *parent) : QDialog (parent) {
38  m_qnetTool = qnetTool;
39 
40  m_avg = new QRadioButton("Average Measures");
41  m_avg->setChecked(true);
42  m_select = new QRadioButton("Select Measures");
43  m_select->setChecked(false);
44  //connect(m_avg,SIGNAL(clicked()),this,SLOT(selectMeasures()));
45  //connect(m_select,SIGNAL(clicked()),this,SLOT(selectMeasures()));
46  m_ptIdValue = NULL;
47  m_fileList = NULL;
48  m_ptIdLabel = NULL;
49  m_okButton = NULL;
50  m_pointFiles = NULL;
51 
52  m_ptIdLabel = new QLabel("Point ID:");
53  m_ptIdValue = new QLineEdit;
54  m_ptIdLabel->setBuddy(m_ptIdValue);
55  m_ptIdValue->setText(defaultPointId);
56  m_ptIdValue->selectAll();
57  connect(m_ptIdValue,SIGNAL(textChanged(const QString &)),
58  this,SLOT(enableOkButton(const QString &)));
59 
60  QGroupBox *pointTypeGroup = new QGroupBox("Point Type");
61  m_fixed = new QRadioButton("Fixed");
62  m_constrained = new QRadioButton("Constrained");
63  m_constrained->setChecked(true);
64  QVBoxLayout *pointTypeLayout = new QVBoxLayout;
65  pointTypeLayout->addWidget(m_fixed);
66  pointTypeLayout->addWidget(m_constrained);
67  pointTypeGroup->setLayout(pointTypeLayout);
68 
69  QLabel *listLabel = new QLabel("Select Files:");
70 
71  m_fileList = new QListWidget();
72  m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
73  //m_fileList->setEnabled(false);
74 
75  // Create OK & Cancel buttons
76  m_okButton = new QPushButton("OK");
77  m_okButton->setEnabled(false);
78  QPushButton *cancelButton = new QPushButton("Cancel");
79  QHBoxLayout *buttonLayout = new QHBoxLayout;
80  buttonLayout->addWidget(m_okButton);
81  buttonLayout->addWidget(cancelButton);
82 
83  connect(m_okButton, SIGNAL(clicked()), this, SLOT(accept()));
84  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
85 
86  QHBoxLayout *ptIdLayout = new QHBoxLayout;
87  ptIdLayout->addWidget(m_ptIdLabel);
88  ptIdLayout->addWidget(m_ptIdValue);
89 
90  QVBoxLayout *vLayout = new QVBoxLayout;
91  vLayout->addLayout(ptIdLayout);
92  vLayout->addWidget(pointTypeGroup);
93  vLayout->addWidget(listLabel);
94  vLayout->addWidget(m_fileList);
95  vLayout->addLayout(buttonLayout);
96 
97  setLayout(vLayout);
98  setWindowTitle("Create Fixed or Constrained ControlPoint");
99 
100  }
101 
102 
103  QnetFixedPointDialog::~QnetFixedPointDialog() {
104  delete m_pointFiles;
105  m_pointFiles = NULL;
106  }
107 
108 
109  bool QnetFixedPointDialog::isFixed() const {
110  return m_fixed->isChecked();
111  }
112 
113 
114  bool QnetFixedPointDialog::isConstrained() const {
115  return m_constrained->isChecked();
116  }
117 
118 
119  QString QnetFixedPointDialog::pointId() const {
120  return m_ptIdValue->text();
121  }
122 
123 
124  QStringList QnetFixedPointDialog::selectedFiles() const {
125  QStringList result;
126 
127  foreach (QListWidgetItem *fileItem, m_fileList->selectedItems()) {
128  result.append(fileItem->text());
129  }
130 
131  return result;
132  }
133 
134 
145  m_pointFiles = new QStringList(pointFiles);
146 
147  int bottomMostSelectedItemIndex = 0;
148 
149  // Add all files to list , selecting those in pointFiles which are
150  // those files which contain the point.
151  SerialNumberList *snList = m_qnetTool->serialNumberList();
152  for (int i = 0; i < snList->size(); i++) {
153  QString label = snList->fileName(i);
154  QListWidgetItem *item = new QListWidgetItem(label);
155 
156  // if this entry of the SerialNumberList is also in the pointFiles then
157  // mark it as selected and insert after the last selected item (toward
158  // the top of the list). Otherwise just add the item to the end of the
159  // list
160  if (pointFiles.contains(label)) {
161  m_fileList->insertItem(bottomMostSelectedItemIndex++, item);
162  item->setSelected(true);
163  }
164  else {
165  m_fileList->addItem(item);
166  }
167  }
168  }
169 
170 
178  void QnetFixedPointDialog::enableOkButton (const QString &text) {
179  m_okButton->setEnabled(!text.isEmpty());
180  }
181 }
Namespace for the standard library.
QString fileName(const QString &sn)
Return a filename given a serial number.
void enableOkButton(const QString &text)
int size() const
How many serial number / filename combos are in the list.
void setFiles(QStringList pointFiles)
Set files found containing selected point.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Qnet tool operations.
Definition: QnetTool.h:256
Serial Number list generator.