USGS

Isis 3.0 Application Source Code Reference

Home

QnetFixedPointDialog.cpp

Go to the documentation of this file.
00001 #include "QnetFixedPointDialog.h"
00002 
00003 #include <QtGui>
00004 
00005 #include <algorithm>
00006 
00007 #include "SerialNumberList.h"
00008 #include "ControlPoint.h"
00009 #include "Camera.h"
00010 
00011 #include "qnet.h"
00012 
00013 using namespace Isis::Qnet;
00014 using namespace std;
00015 
00016 namespace Isis {
00017   // initialize static variable
00018   QString QnetFixedPointDialog::lastPtIdValue = "";
00019 
00020   /** 
00021    * QnetNewPointDialog constructor 
00022    * @param parent The parent widget for the
00023    *               cube points filter
00024    *  
00025    * @internal 
00026    *   @history 2008-11-26 Jeannie Walldren - Set lastPointIdValue
00027    *   @history 2010-06-03 Jeannie Walldren - Initialized pointers
00028    *                          to null.
00029    *  
00030    */ 
00031   QnetFixedPointDialog::QnetFixedPointDialog (QWidget *parent) : QDialog (parent) {
00032 
00033     
00034     p_avg = new QRadioButton("Average Measures");
00035     p_avg->setChecked(true);
00036     p_select = new QRadioButton("Select Measures");
00037     p_select->setChecked(false);
00038     //connect(p_avg,SIGNAL(clicked()),this,SLOT(selectMeasures()));
00039     //connect(p_select,SIGNAL(clicked()),this,SLOT(selectMeasures()));
00040     ptIdValue = NULL;
00041     fileList = NULL;
00042     p_ptIdLabel = NULL;
00043     p_okButton = NULL;
00044     p_pointFiles = NULL;
00045 
00046     p_ptIdLabel = new QLabel("Point ID:");
00047     ptIdValue = new QLineEdit;
00048     p_ptIdLabel->setBuddy(ptIdValue);
00049     ptIdValue->setText(lastPtIdValue);
00050     ptIdValue->selectAll();
00051     connect(ptIdValue,SIGNAL(textChanged(const QString &)),
00052             this,SLOT(enableOkButton(const QString &)));
00053 
00054     QGroupBox *pointTypeGroup = new QGroupBox("Point Type");
00055     fixed = new QRadioButton("Fixed");
00056     constrained = new QRadioButton("Constrained");
00057     constrained->setChecked(true);
00058     QVBoxLayout *pointTypeLayout = new QVBoxLayout;
00059     pointTypeLayout->addWidget(fixed);
00060     pointTypeLayout->addWidget(constrained);
00061     pointTypeGroup->setLayout(pointTypeLayout);
00062 
00063     QLabel *listLabel = new QLabel("Select Files:");
00064 
00065     fileList = new QListWidget();
00066     fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
00067     //fileList->setEnabled(false);
00068 
00069     //  Create OK & Cancel buttons
00070     p_okButton = new QPushButton("OK");
00071     p_okButton->setEnabled(false);
00072     QPushButton *cancelButton = new QPushButton("Cancel");
00073     QHBoxLayout *buttonLayout = new QHBoxLayout;
00074     buttonLayout->addWidget(p_okButton);
00075     buttonLayout->addWidget(cancelButton);
00076 
00077     connect(p_okButton, SIGNAL(clicked()), this, SLOT(accept()));
00078     connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
00079 
00080     QHBoxLayout *ptIdLayout = new QHBoxLayout;
00081     ptIdLayout->addWidget(p_ptIdLabel);
00082     ptIdLayout->addWidget(ptIdValue);
00083 
00084     QVBoxLayout *vLayout = new QVBoxLayout;
00085     vLayout->addLayout(ptIdLayout);
00086     vLayout->addWidget(pointTypeGroup);
00087     vLayout->addWidget(listLabel);
00088     vLayout->addWidget(fileList);
00089     vLayout->addLayout(buttonLayout);
00090 
00091     setLayout(vLayout);
00092     setWindowTitle("Create Fixed or Constrained ControlPoint");
00093 
00094   }
00095 
00096 
00097 
00098   /** 
00099    * Set files found containing selected point 
00100    *  
00101    * @author 2010-11-10 Tracie Sucharski 
00102    *  
00103    * @internal 
00104    * @history 2011-09-16 Tracie Sucharski - List images that insersect 
00105    *                        point at the top of the list. 
00106    */
00107   void QnetFixedPointDialog::SetFiles (QStringList &pointFiles) {
00108     //  TODO::  make pointFiles const???
00109     p_pointFiles = &pointFiles;
00110 
00111     int bottomMostSelectedItemIndex = 0;
00112 
00113     //  Add all files to list , selecting those in pointFiles which are
00114     //  those files which contain the point.
00115     for (int i=0; i<g_serialNumberList->Size(); i++) {
00116       iString label = g_serialNumberList->Filename(i);
00117       QListWidgetItem *item = new QListWidgetItem(label);
00118 
00119       // if this entry of the SerialNumberList is also in the pointFiles then
00120       // mark it as selected and insert after the last selected item (toward
00121       // the top of the list).  Otherwise just add the item to the end of the
00122       // list
00123       if (pointFiles.contains(label)) {
00124         fileList->insertItem(bottomMostSelectedItemIndex++, item);
00125         item->setSelected(true);
00126       }
00127       else {
00128         fileList->addItem(item);
00129       }
00130     }
00131   }
00132 
00133 
00134   /** 
00135    *  
00136    * @param text 
00137    * @internal 
00138    *   @history 2008-11-26 Jeannie Walldren - Set lastPointIdValue
00139    *            to the p_ptIdValue 
00140    */
00141   void QnetFixedPointDialog::enableOkButton (const QString &text) {
00142     QnetFixedPointDialog::lastPtIdValue = ptIdValue->text();
00143     p_okButton->setEnabled(!text.isEmpty());
00144   }
00145 }