6#include "Application.h" 
    8#include "ControlMeasure.h" 
   10#include "ControlPoint.h" 
   13#include "MdiCubeViewport.h" 
   15#include "QnetFileTool.h" 
   17#include "SerialNumber.h" 
   18#include "SerialNumberList.h" 
   34    m_qnetTool = qnetTool;
 
   36    openAction()->setText(
"Open control network and cube list");
 
   37    openAction()->setToolTip(
"Open control network and cube list");
 
   39      "<b>Function:</b> Open a <i>control network</i> \ 
   40       <p><b>Shortcut:</b>  Ctrl+O\n</p>";
 
   43    saveAction()->setText(
"Save Control Network &As...");
 
   45      "<b>Function:</b> Save the current <i>control network</i> under chosen filename";
 
   51    m_openGround = 
new QAction(parent);
 
   52    m_openGround->setText(
"Open &Ground Source");
 
   53    m_openGround->setStatusTip(
"Open a ground source for choosing ground points");
 
   55      "<b>Function:</b> Open and display a ground source for choosing ground points." 
   56      "This can be level1, level2 or dem cube.";
 
   57    m_openGround->setWhatsThis(whatsThis);
 
   58    m_openGround->setEnabled(
false);
 
   59    connect (m_openGround,SIGNAL(triggered()),
this,SIGNAL(newGroundFile()));
 
   61    m_openDem = 
new QAction(parent);
 
   62    m_openDem->setText(
"Open &Radius Source");
 
   64      "<b>Function:</b> Open a DEM for determining the radius when " 
   65      "choosing ground points.  This is not the file that will be displayed " 
   66      "to be used for visually picking points.  This is strictly used to " 
   67      "determine the radius value.";
 
   68    m_openDem->setWhatsThis(whatsThis);
 
   69    m_openDem->setEnabled(
false);
 
   70    connect (m_openDem,SIGNAL(triggered()),
this,SIGNAL(newDemFile()));
 
 
   74  QnetFileTool::~QnetFileTool() {
 
   79    menu->addAction(m_openGround);
 
   80    menu->addAction(m_openDem);
 
 
   87    return m_qnetTool->controlNet();
 
   91  SerialNumberList *QnetFileTool::serialNumberList() {
 
   92    return m_qnetTool->serialNumberList();
 
  121    if (serialNumberList() != NULL && m_isDirty) {
 
  123      int resp = QMessageBox::warning((
QWidget *)parent(), 
"Qnet",
 
  124          "The control network files has been modified.\n" 
  125          "Do you want to save your changes?",
 
  126          QMessageBox::Yes | QMessageBox::Default,
 
  128          QMessageBox::Cancel | QMessageBox::Escape);
 
  129      if (resp == QMessageBox::Yes) {
 
  135    QString filter = 
"List of cubes (*.lis *.lst *.list);;";
 
  136    filter += 
"Text file (*.txt);;";
 
  138    QString list = QFileDialog::getOpenFileName((
QWidget *)parent(),
 
  139        "Select a list of cubes",
 
  147    QString dir = file.path();
 
  149    QApplication::setOverrideCursor(Qt::WaitCursor);
 
  156      QString message = 
"Error processing cube list.  \n";
 
  157      QString errors = e.toString();
 
  159      QMessageBox::information((
QWidget *)parent(), 
"Error", message);
 
  160      QApplication::restoreOverrideCursor();
 
  164    QApplication::restoreOverrideCursor();
 
  165    filter = 
"Control net (*.net *.cnet *.ctl);;";
 
  166    filter += 
"Pvl file (*.pvl);;";
 
  167    filter += 
"Text file (*.txt);;";
 
  169    QString cNetFileName = QFileDialog::getOpenFileName((
QWidget *)parent(),
 
  170        "Select a control network",
 
  173    QApplication::setOverrideCursor(Qt::WaitCursor);
 
  174    if (cNetFileName.isEmpty()) {
 
  178      QScopedPointer<Cube> cube(
new Cube());
 
  179      cube->open(serialNumberList()->fileName(0));
 
  185        *controlNet() = 
ControlNet(cNetFileName, &progress);
 
  188        QString message = 
"Invalid control network.  \n";
 
  189        QString errors = e.toString();
 
  191        QMessageBox::information((
QWidget *)parent(), 
"Error", message);
 
  192        QApplication::restoreOverrideCursor();
 
  200      controlNet()->
SetImages(*serialNumberList(), &progress);
 
  203      QString message = 
"Cannot initialize images in control network.  \n";
 
  204      QString errors = e.toString();
 
  206      QMessageBox::information((
QWidget *)parent(), 
"Error", message);
 
  207      QApplication::restoreOverrideCursor();
 
  211    m_openGround->setEnabled(
true);
 
  212    m_openDem->setEnabled(
true);
 
  214    QApplication::restoreOverrideCursor();
 
  216    m_cnetFileName = cNetFileName;
 
  217    emit serialNumberListUpdated();
 
  218    emit controlNetworkUpdated(cNetFileName);
 
  219    emit newControlNetwork(controlNet());
 
 
  237      int resp = QMessageBox::warning((
QWidget *)parent(), 
"QnetTool",
 
  238          "The control network files has been modified.\n" 
  239          "Do you want to save your changes?",
 
  240          QMessageBox::Yes | QMessageBox::Default,
 
  242          QMessageBox::Cancel | QMessageBox::Escape);
 
  243      if (resp == QMessageBox::Yes) {
 
  246      if (resp == QMessageBox::Cancel) {
 
  248          event->setAccepted(
false);
 
 
  266    controlNet()->
Write(m_cnetFileName);
 
 
  282    QString filter = 
"Control net (*.net *.cnet *.ctl);;";
 
  283    filter += 
"Pvl file (*.pvl);;";
 
  284    filter += 
"Text file (*.txt);;";
 
  286    QString fn = QFileDialog::getSaveFileName((
QWidget *)parent(),
 
  287        "Choose filename to save under",
 
  291        controlNet()->
Write(fn);
 
  294        QString message = 
"Error saving control network.  \n";
 
  295        QString errors = e.toString();
 
  297        QMessageBox::information((
QWidget *)parent(), 
"Error", message);
 
  302      QMessageBox::information((
QWidget *)parent(),
 
  303          "Error", 
"Saving Aborted");
 
  306    emit controlNetworkUpdated(fn);
 
 
  331    QString tempFileName = serialNumberList()->
fileName(serialNumber);
 
  332    QString filename = tempFileName;
 
  333    QVector< MdiCubeViewport * > * cvpList = m_qnetTool->workspace()->
cubeViewportList();
 
  335    for (
int i = 0; i < (int)cvpList->size(); i++) {
 
  337      if (sn == serialNumber) {
 
  338        m_qnetTool->workspace()->
mdiArea()->setActiveSubWindow(
 
 
  360    for (
int i = 0; i < point->GetNumMeasures(); i++) {
 
  361      QString cubeSN = (*point)[i]->GetCubeSerialNumber();
 
 
static QString UserName()
Returns the user name.
 
void SetImages(const QString &imageListFile)
Creates the ControlNet's image cameras based on an input file.
 
void Write(const QString &filename, bool pvl=false)
Writes out the control network.
 
void SetUserName(const QString &name)
Set the user name of the control network.
 
void SetTarget(const QString &target)
Sets the target name and target radii, if available.
 
IO Handler for Isis Cubes.
 
File name manipulation and expansion.
 
Program progress reporter.
 
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
 
Serial Number list generator.
 
QString fileName(const QString &sn)
Return a filename given a serial number.
 
QMdiArea * mdiArea()
This method returns the QMdiArea.
 
QVector< MdiCubeViewport * > * cubeViewportList()
This method returns a Vector of MdiCubeViewports.
 
This is free and unencumbered software released into the public domain.
 
Namespace for the standard library.