USGS

Isis 3.0 Object Programmers' Reference

Home

MatchToolNewPointDialog.cpp
1 #include "MatchToolNewPointDialog.h"
2 
3 #include <QtGui>
4 #include <algorithm>
5 
6 #include "ControlNet.h"
7 #include "IString.h"
8 #include "SerialNumberList.h"
9 
10 
11 namespace Isis {
12  // initialize static variable
13 
32  MatchToolNewPointDialog::MatchToolNewPointDialog(const ControlNet &cnet, QString defaultPointId,
33  QWidget *parent) : QDialog(parent) {
34 
35  ptIdLineEdit = NULL;
36  m_fileList = NULL;
37  m_doneButton = NULL;
38 
39  QLabel *ptIdLabel = new QLabel("Point ID:");
40  ptIdLineEdit = new QLineEdit;
41  ptIdLineEdit->setText(defaultPointId);
42  ptIdLineEdit->selectAll();
43  ptIdLabel->setBuddy(ptIdLineEdit);
44  connect(ptIdLineEdit, SIGNAL(textChanged(const QString &)),
45  this, SLOT(enableDoneButton(const QString &)));
46 
47  QLabel *listLabel = new QLabel("Displayed Cubes / Selected measures: \n"
48  "Right click on the cube viewport to select approximate measure "
49  "location.\nCubes will be highlighted below as you select "
50  "measure locations.");
51 
52  m_fileList = new QListWidget;
53  m_fileList->setSelectionMode(QAbstractItemView::NoSelection);
54 
55  // Create Done & Cancel buttons
56  m_doneButton = new QPushButton("Done selecting measures");
57  m_doneButton->setToolTip("All measures have been selected. Load the new point into the "
58  "control point editor for refinement.");
59  m_doneButton->setWhatsThis("You have right-clicked on all cube viewports you want to create "
60  "as a control measure. The new point will be loaded into the "
61  "control point editor for refinement.");
62  // If the last point id used was never saved to network, do not set ok
63  // button to faslse
64  if (defaultPointId.isEmpty() || cnet.ContainsPoint(defaultPointId)) {
65  m_doneButton->setEnabled(false);
66  }
67  QPushButton *cancelButton = new QPushButton("Cancel");
68  cancelButton->setToolTip("Cancel without creating a new point.");
69  QHBoxLayout *buttonLayout = new QHBoxLayout;
70  buttonLayout->addWidget(m_doneButton);
71  buttonLayout->addWidget(cancelButton);
72 
73  connect(m_doneButton, SIGNAL(clicked()), this, SLOT(accept()));
74  connect(m_doneButton, SIGNAL(clicked()), this, SIGNAL(measuresFinished()));
75 
76  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
77  connect(cancelButton, SIGNAL(clicked()), this, SIGNAL(newPointCanceled()));
78 
79  QHBoxLayout *ptIdLayout = new QHBoxLayout;
80  ptIdLayout->addWidget(ptIdLabel);
81  ptIdLayout->addWidget(ptIdLineEdit);
82 
83  QVBoxLayout *vLayout = new QVBoxLayout;
84  vLayout->addLayout(ptIdLayout);
85  vLayout->addWidget(listLabel);
86  vLayout->addWidget(m_fileList);
87  vLayout->addLayout(buttonLayout);
88 
89  setLayout(vLayout);
90  setWindowTitle("Create New ControlPoint");
91  show();
92 
93  }
94 
95 
104 
105  m_fileList->addItems(pointFiles);
106 
107  }
108 
109 
110 
111  void MatchToolNewPointDialog::highlightFile(QString file) {
112 
113  QList<QListWidgetItem *> found = m_fileList->findItems(file, Qt::MatchFixedString);
114  if (!found.isEmpty()) {
115  m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
116  found.at(0)->setSelected(true);
117  m_fileList->setSelectionMode(QAbstractItemView::NoSelection);
118  }
119  }
120 
121 
122 
123  QString MatchToolNewPointDialog::pointId() const {
124  return ptIdLineEdit->text();
125  }
126 
127 
128 
136  void MatchToolNewPointDialog::enableDoneButton(const QString &text) {
137  m_doneButton->setEnabled(!text.isEmpty());
138  }
139 
140 
141 }