1 #include "NewControlPointDialog.h" 
   10 #include <QListWidget> 
   11 #include <QPushButton> 
   12 #include <QRadioButton> 
   16 #include "ControlNet.h" 
   17 #include "ControlPoint.h" 
   19 #include "SerialNumberList.h" 
   46                                                QString defaultPointId,
 
   50                                                bool subpixelRegisterMeasures) : 
QDialog(parent) {
 
   52     m_controlNet = controlNet;
 
   53     m_serialNumberList = serialNumberList;
 
   57     m_subpixelRegisterButton = NULL;
 
   62     m_ptIdLabel = 
new QLabel(
"Point ID:");
 
   63     m_ptIdEdit = 
new QLineEdit;
 
   64     m_ptIdLabel->setBuddy(m_ptIdEdit);
 
   65     m_ptIdEdit->setText(defaultPointId);
 
   66     m_ptIdEdit->selectAll();
 
   67     connect(m_ptIdEdit, SIGNAL(textChanged(
const QString &)),
 
   70     QHBoxLayout *pointTypeLayout = 
new QHBoxLayout();
 
   73       for (
int i=0; i<ControlPoint::PointTypeCount; i++) {
 
   77       m_pointTypeCombo->setCurrentText(
"Free");
 
   78       QLabel *pointTypeLabel = 
new QLabel(
"Point Type:");
 
   79       pointTypeLayout->addWidget(pointTypeLabel);
 
   80       pointTypeLayout->addWidget(m_pointTypeCombo);
 
   81       connect(m_pointTypeCombo, SIGNAL(currentIndexChanged(QString)),
 
   82               this, SLOT(pointTypeChanged(QString)));
 
   85     QHBoxLayout *groundSourceLayout = NULL;
 
   86     QHBoxLayout *radiusSourceLayout = NULL;
 
   88       groundSourceLayout = 
new QHBoxLayout();
 
   90       QLabel *groundSourceLabel = 
new QLabel(
"Ground Source:");
 
   91       groundSourceLayout->addWidget(groundSourceLabel);
 
   92       groundSourceLayout->addWidget(m_groundSourceCombo);
 
   93       m_groundSourceCombo->setVisible(
false);
 
   95       radiusSourceLayout = 
new QHBoxLayout();
 
   97       QLabel *radiusSourceLabel = 
new QLabel(
"Radius Source:");
 
   98       radiusSourceLayout->addWidget(radiusSourceLabel);
 
   99       radiusSourceLayout->addWidget(m_radiusSourceCombo);
 
  100       m_radiusSourceCombo->setVisible(
false);
 
  103     if (subpixelRegisterMeasures) {
 
  104       m_subpixelRegisterButton = 
new QRadioButton(
"Subpixel Register Measures");
 
  105       m_subpixelRegisterButton->setChecked(
true);
 
  106       m_subpixelRegisterButton->setToolTip(
"Each measure will be subpixel registered to the reference" 
  107                                            " as it is created.");
 
  110     QLabel *listLabel = 
new QLabel(
"Select Files:");
 
  112     m_fileList = 
new QListWidget;
 
  113     m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
  116     m_okButton = 
new QPushButton(
"OK");
 
  122     QPushButton *cancelButton = 
new QPushButton(
"Cancel");
 
  123     QHBoxLayout *buttonLayout = 
new QHBoxLayout;
 
  124     buttonLayout->addWidget(m_okButton);
 
  125     buttonLayout->addWidget(cancelButton);
 
  127     connect(m_okButton, SIGNAL(clicked()), 
this, SLOT(accept()));
 
  128     connect(cancelButton, SIGNAL(clicked()), 
this, SLOT(reject()));
 
  130     QHBoxLayout *ptIdLayout = 
new QHBoxLayout;
 
  131     ptIdLayout->addWidget(m_ptIdLabel);
 
  132     ptIdLayout->addWidget(m_ptIdEdit);
 
  134     QVBoxLayout *vLayout = 
new QVBoxLayout;
 
  136     vLayout->addLayout(ptIdLayout);
 
  139       vLayout->addLayout(pointTypeLayout);
 
  143       vLayout->addLayout(groundSourceLayout);
 
  144       vLayout->addLayout(radiusSourceLayout);
 
  147     if (subpixelRegisterMeasures) {
 
  148       vLayout->addWidget(m_subpixelRegisterButton);
 
  151     vLayout->addWidget(listLabel);
 
  152     vLayout->addWidget(m_fileList);
 
  153     vLayout->addLayout(buttonLayout);
 
  156     setWindowTitle(
"Create New ControlPoint");
 
  161   QString NewControlPointDialog::pointId()
 const {
 
  162     return m_ptIdEdit->text();
 
  166   int NewControlPointDialog::pointType()
 const {
 
  168     if (m_pointTypeCombo->currentText() == 
"Constrained") {
 
  171     if (m_pointTypeCombo->currentText() == 
"Fixed") {
 
  178   QStringList NewControlPointDialog::selectedFiles()
 const {
 
  181     foreach (QListWidgetItem *fileItem, m_fileList->selectedItems()) {
 
  182       result.append(fileItem->text());
 
  189   bool NewControlPointDialog::subpixelRegisterPoint() {
 
  190     return m_subpixelRegisterButton->isChecked();
 
  194   QString NewControlPointDialog::groundSource()
 const {
 
  195     return m_groundSourceCombo->currentText();
 
  199   QString NewControlPointDialog::radiusSource()
 const {
 
  200     return m_radiusSourceCombo->currentText();
 
  204   void NewControlPointDialog::pointTypeChanged(QString pointType) {
 
  205     if (pointType == 
"Fixed" || pointType == 
"Constrained") {
 
  206       m_groundSourceCombo->setVisible(
true);
 
  207       m_radiusSourceCombo->setVisible(
true);
 
  212   void NewControlPointDialog::setGroundSource(
QStringList groundFiles, 
int numberShapesWithPoint) {
 
  214     if (groundFiles.count() != 0) {
 
  215       m_groundSourceCombo->addItems(groundFiles); 
 
  216       for (
int i = 0; i < numberShapesWithPoint; i++) {
 
  217         m_groundSourceCombo->setItemData(i, QColor(Qt::red), Qt::ForegroundRole);
 
  219       m_groundSourceCombo->insertSeparator(numberShapesWithPoint);
 
  225       m_pointTypeCombo->setToolTip(
"The Point Type cannot be changed to \"Fixed\" or " 
  226                                    "\"Constrained\", because there are no shapes imported into " 
  228       m_pointTypeCombo->removeItem(m_pointTypeCombo->findText(
"Constrained"));
 
  229       m_pointTypeCombo->removeItem(m_pointTypeCombo->findText(
"Fixed"));
 
  230       m_pointTypeCombo->setCurrentText(
"Free");
 
  235   void NewControlPointDialog::setRadiusSource(
QStringList radiusFiles) {
 
  237     m_radiusSourceCombo->addItem(
"None");
 
  238     m_radiusSourceCombo->setCurrentText(
"None");
 
  239     if (radiusFiles.count() != 0) {
 
  240       m_radiusSourceCombo->addItems(radiusFiles);
 
  254     int bottomMostSelectedItemIndex = 0;
 
  256     for (
int i = 0; i < m_serialNumberList->
size(); i++) {
 
  259       QString label = m_serialNumberList->
fileName(i);
 
  260       QListWidgetItem *item = 
new QListWidgetItem(label);
 
  266       if (pointFiles.contains(label)) {
 
  267         m_fileList->insertItem(bottomMostSelectedItemIndex++, item);
 
  268         item->setSelected(
true);
 
  271         m_fileList->addItem(item);
 
  284     bool enable = !m_ptIdEdit->text().isEmpty() &&
 
  286     m_okButton->setEnabled(enable);
 
  288       m_okButton->setToolTip(
"");
 
  291       m_okButton->setToolTip(
"Cannot create point because Point Id is either empty or the active " 
  292                              "control net already contains a control point with this point Id.");