Isis 3 Programmer Reference
MatchToolNewPointDialog.cpp
1 #include "MatchToolNewPointDialog.h"
2 
3 #include <algorithm>
4 
5 #include <QAbstractItemView>
6 #include <QHBoxLayout>
7 #include <QVBoxLayout>
8 #include <QLabel>
9 #include <QLineEdit>
10 #include <QListWidget>
11 #include <QPushButton>
12 #include <QtWidgets>
13 
14 #include "ControlNet.h"
15 #include "IString.h"
16 #include "SerialNumberList.h"
17 
18 
19 namespace Isis {
20  // initialize static variable
21 
40  MatchToolNewPointDialog::MatchToolNewPointDialog(const ControlNet &cnet, QString defaultPointId,
41  QWidget *parent) : QDialog(parent) {
42 
43  ptIdLineEdit = NULL;
44  m_fileList = NULL;
45  m_doneButton = NULL;
46 
47  QLabel *ptIdLabel = new QLabel("Point ID:");
48  ptIdLineEdit = new QLineEdit;
49  ptIdLineEdit->setText(defaultPointId);
50  ptIdLineEdit->selectAll();
51  ptIdLabel->setBuddy(ptIdLineEdit);
52  connect(ptIdLineEdit, SIGNAL(textChanged(const QString &)),
53  this, SLOT(enableDoneButton(const QString &)));
54 
55  QLabel *listLabel = new QLabel("Displayed Cubes / Selected measures: \n"
56  "Right click on the cube viewport to select approximate measure "
57  "location.\nCubes will be highlighted below as you select "
58  "measure locations.");
59 
60  m_fileList = new QListWidget;
61  m_fileList->setSelectionMode(QAbstractItemView::NoSelection);
62 
63  // Create Done & Cancel buttons
64  m_doneButton = new QPushButton("Done selecting measures");
65  m_doneButton->setToolTip("All measures have been selected. Load the new point into the "
66  "control point editor for refinement.");
67  m_doneButton->setWhatsThis("You have right-clicked on all cube viewports you want to create "
68  "as a control measure. The new point will be loaded into the "
69  "control point editor for refinement.");
70  // If the last point id used was never saved to network, do not set ok
71  // button to faslse
72  if (defaultPointId.isEmpty() || cnet.ContainsPoint(defaultPointId)) {
73  m_doneButton->setEnabled(false);
74  }
75  QPushButton *cancelButton = new QPushButton("Cancel");
76  cancelButton->setToolTip("Cancel without creating a new point.");
77  QHBoxLayout *buttonLayout = new QHBoxLayout;
78  buttonLayout->addWidget(m_doneButton);
79  buttonLayout->addWidget(cancelButton);
80 
81  connect(m_doneButton, SIGNAL(clicked()), this, SLOT(accept()));
82  connect(m_doneButton, SIGNAL(clicked()), this, SIGNAL(measuresFinished()));
83 
84  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
85  connect(cancelButton, SIGNAL(clicked()), this, SIGNAL(newPointCanceled()));
86 
87  QHBoxLayout *ptIdLayout = new QHBoxLayout;
88  ptIdLayout->addWidget(ptIdLabel);
89  ptIdLayout->addWidget(ptIdLineEdit);
90 
91  QVBoxLayout *vLayout = new QVBoxLayout;
92  vLayout->addLayout(ptIdLayout);
93  vLayout->addWidget(listLabel);
94  vLayout->addWidget(m_fileList);
95  vLayout->addLayout(buttonLayout);
96 
97  setLayout(vLayout);
98  setWindowTitle("Create New ControlPoint");
99  show();
100 
101  }
102 
103 
112 
113  m_fileList->addItems(pointFiles);
114 
115  }
116 
117 
118 
119  void MatchToolNewPointDialog::highlightFile(QString file) {
120 
121  QList<QListWidgetItem *> found = m_fileList->findItems(file, Qt::MatchFixedString);
122  if (!found.isEmpty()) {
123  m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
124  found.at(0)->setSelected(true);
125  m_fileList->setSelectionMode(QAbstractItemView::NoSelection);
126  }
127  }
128 
129 
130 
131  QString MatchToolNewPointDialog::pointId() const {
132  return ptIdLineEdit->text();
133  }
134 
135 
136 
144  void MatchToolNewPointDialog::enableDoneButton(const QString &text) {
145  m_doneButton->setEnabled(!text.isEmpty());
146  }
147 
148 
149 }
QWidget
QList< QListWidgetItem * >
Isis::MatchToolNewPointDialog::MatchToolNewPointDialog
MatchToolNewPointDialog(const ControlNet &cnet, QString defaultPointId, QWidget *parent=0)
MatchToolNewPointDialog constructor.
Definition: MatchToolNewPointDialog.cpp:40
QStringList
Isis::ControlNet
a control network
Definition: ControlNet.h:257
Isis::ControlNet::ContainsPoint
bool ContainsPoint(QString pointId) const
Definition: ControlNet.cpp:951
Isis::MatchToolNewPointDialog::enableDoneButton
void enableDoneButton(const QString &text)
Definition: MatchToolNewPointDialog.cpp:144
QDialog
Isis::MatchToolNewPointDialog::setFiles
void setFiles(QStringList pointFiles)
Definition: MatchToolNewPointDialog.cpp:111
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16