Commit 879ca3a6 authored by Summer Stapleton's avatar Summer Stapleton
Browse files

The bulk of the template changes implementation. ControlPointEditWidget fully...

The bulk of the template changes implementation. ControlPointEditWidget fully implemented, and TemplateEditorWidget only needing pop-up warning box now. (Much of the skeleton code for this exists as comments.)
parent 783a0a68
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1594,6 +1594,7 @@ namespace Isis {
          m_templateFileName, _FILEINFO_);
      QString message = fullError.toString();
      QMessageBox::information((QWidget *)parent(), "Error", message);
      emit setTemplateFailed(m_templateFileName);
      return false;
    }
  }
+2 −1
Original line number Diff line number Diff line
@@ -164,7 +164,6 @@ namespace Isis {
      QString templateFileName() {
        return m_templateFileName;
      };
      bool setTemplateFile(QString);
      void allowLeftMouse(bool allowMouse);

    signals:
@@ -172,9 +171,11 @@ namespace Isis {
      void updateRightView(double sample, double line);
      void measureSaved();
      void newControlNetwork(ControlNet *);
      void setTemplateFailed(QString);
      void stretchChipViewport(Stretch *, CubeViewport *);

    public slots:
      bool setTemplateFile(QString);
      void setPoint(ControlPoint *editPoint, SerialNumberList *snList);
      void setLeftMeasure(ControlMeasure *leftMeasure,
                          Cube *leftCube, QString pointId);
+60 −13
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include "Shape.h"
#include "ShapeList.h"
#include "SpecialPixel.h"
#include "TemplateList.h"
#include "ToolPad.h"
#include "UniversalGroundMap.h"
#include "ViewportMainWindow.h"
@@ -85,6 +86,9 @@ namespace Isis {

    connect(this, SIGNAL(newControlNetwork(ControlNet *)),
            m_measureEditor, SIGNAL(newControlNetwork(ControlNet *)));

    connect(m_directory->project(), SIGNAL(templatesAdded(TemplateList *)),
            this, SLOT(addTemplates(TemplateList *)));
}


@@ -220,18 +224,31 @@ namespace Isis {

    m_cnetFileNameLabel = new QLabel("Control Network: " + m_cnetFileName);

    m_templateFileNameLabel = new QLabel("Template File: " +
        m_measureEditor->templateFileName());
    m_templateFileNameLabel->setToolTip("Sub-pixel registration template File.");
    m_templateFileNameLabel->setWhatsThis("FileName of the sub-pixel "
    m_templateComboBox = new QComboBox();
    m_templateComboBox->setToolTip("Choose a template file");
    m_templateComboBox->setWhatsThis("FileName of the sub-pixel "
                  "registration template.  Refer to $ISISROOT/doc/documents/"
                  "PatternMatch/PatternMatch.html for a description of the "
                  "contents of this file.");
    m_templateComboBox->addItem(m_measureEditor->templateFileName());
    QList <TemplateList *> regTemplates = m_directory->project()->registrationTemplates();
    foreach(TemplateList *templateList, regTemplates) {
      foreach(Template *templateFile, *templateList){
        m_templateComboBox->addItem(templateFile->fileName());
      }
    }
    QFormLayout *templateFileLayout = new QFormLayout();
    templateFileLayout->addRow("Template File:", m_templateComboBox);

    connect(m_templateComboBox, SIGNAL(activated(QString)), 
            m_measureEditor, SLOT(setTemplateFile(QString)));
    connect(m_measureEditor, SIGNAL(setTemplateFailed(QString)), 
            this, SLOT(resetTemplateComboBox(QString)));

    QVBoxLayout * centralLayout = new QVBoxLayout;

    centralLayout->addWidget(m_cnetFileNameLabel);
    centralLayout->addWidget(m_templateFileNameLabel);
    centralLayout->addLayout(templateFileLayout);
    centralLayout->addWidget(createTopSplitter());
    centralLayout->addStretch();
    centralLayout->addWidget(m_measureEditor);
@@ -805,7 +822,6 @@ namespace Isis {
    //  to m_editPoint, otherwise create copy.  It will not be saved to net until "Save Point"
    //  is selected
    if (controlPoint->Parent() == NULL) {

      m_editPoint = controlPoint;
      // New point in editor, so colorize all save buttons
      colorizeAllSaveButtons("red");
@@ -814,8 +830,8 @@ namespace Isis {
      m_editPoint = controlPoint;
      // New point loaded, make sure all save button's text is default black color
      colorizeAllSaveButtons("black");

    }
    
    loadPoint(serialNumber);
    loadTemplateFile(m_measureEditor->templateFileName());
  }
@@ -1995,7 +2011,9 @@ namespace Isis {
      m_leftMeasure = NULL;
    }

    m_leftMeasure = ((*m_editPoint)[serial]);
    m_leftMeasure = new ControlMeasure();
    //  Find measure for each file    
    *m_leftMeasure = *((*m_editPoint)[serial]);
    
    //  If m_leftCube is not null, delete before creating new one
    m_leftCube.reset(new Cube(file, "r"));
@@ -2042,7 +2060,10 @@ namespace Isis {
      delete m_rightMeasure;
      m_rightMeasure = NULL;
    }
    m_rightMeasure = ((*m_editPoint)[serial]);

    m_rightMeasure = new ControlMeasure();
    //  Find measure for each file
    *m_rightMeasure = *((*m_editPoint)[serial]);
    
    //  If m_rightCube is not null, delete before creating new one
    m_rightCube.reset(new Cube(file, "r"));
@@ -2241,7 +2262,6 @@ namespace Isis {

    m_templateModified = false;
    m_saveTemplateFile->setEnabled(false);
    m_templateFileNameLabel->setText("Template File: " + fn);
  }


@@ -2327,7 +2347,6 @@ namespace Isis {
    if (m_measureEditor->setTemplateFile(fn)) {
      m_templateModified = false;
      m_saveTemplateFile->setEnabled(false);
      m_templateFileNameLabel->setText("Template File: " + fn);
    }
  }

@@ -2388,6 +2407,34 @@ namespace Isis {
  }


  /**
  * Add registration TemplateList to combobox when imported to project
  *
  * @param templateList Reference to TemplateList that was imported
  */
  void ControlPointEditWidget::addTemplates(TemplateList *templateList) {
    if(templateList->type() == "registrations") {
      for(int i = 0; i < templateList->size(); i++) {
        m_templateComboBox->addItem(templateList->at(i)->fileName());
      }
    }
  }
  
  
  /**
  * Reset the selected template in teh template combobox if the template selected by the user does 
  * not satisfy requirements for the control measure.
  *
  * @param fielName The filename that was previously selected in the template combo box
  */
  void ControlPointEditWidget::resetTemplateComboBox(QString fileName) {
    int index = m_templateComboBox->findText(fileName);
    if (index != -1) {
      m_templateComboBox->setCurrentIndex(index);
    }
  }


  /**
   * Update the current editPoint information in the Point Editor labels
   *
+5 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

#include "ControlPoint.h"
#include "FileName.h"
#include "TemplateList.h"

#include <QCloseEvent>
#include <QDir>
@@ -136,6 +137,8 @@ namespace Isis {
      // is red. This default was used so that current calls did not need to be changed.
      void colorizeSaveNetButton(bool reset = false);
      
      void addTemplates(TemplateList *templateList);

    protected:
      bool eventFilter(QObject *o,QEvent *e);

@@ -174,6 +177,7 @@ namespace Isis {
      void saveTemplateFileAs();
      void setTemplateModified();
      void writeTemplateFile(QString);
      void resetTemplateComboBox(QString fileName);
      void clearEditPoint();

    private:
@@ -230,7 +234,7 @@ namespace Isis {
      QPointer<QWidget> m_templateEditorWidget; //!< Template editor widget
      bool m_templateModified; //!< Indicates if the registration template was edited

      QPointer<QLabel> m_templateFileNameLabel; //!< Label for the template filename
      QPointer<QComboBox> m_templateComboBox; //!< ComboBox of importd registration templates
      QPointer<QLabel> m_ptIdValue; //!< Label for the point id of the current point
      QPointer<QComboBox> m_pointType; //!< Combobox to change the type of the current point
      QPointer<QLabel> m_numMeasures;
+18 −0
Original line number Diff line number Diff line
@@ -1243,6 +1243,24 @@ namespace Isis {
    if (!templateEditorWidget) {
      return;
    }
    
    // if (templateEditorWidget->textChanged()) {
    //   QMessageBox *box = new QMessageBox(QMessageBox::NoIcon, QString("Current Template Has Unsaved Changes"),
    //                          QString("Would you like to save your current template?"),
    //                          NULL, qobject_cast<QWidget *>(parent()), Qt::Dialog);
    //   QPushButton *save = box->addButton("Save", QMessageBox::AcceptRole);
    //   box->addButton("Don't Save", QMessageBox::RejectRole);
    //   QPushButton *cancel = box->addButton("Cancel", QMessageBox::NoRole);
    //   box->exec();
    // 
    //   if (box->clickedButton() == (QAbstractButton*)cancel) {
    //     return;
    //   }
    //   else if (box->clickedButton() == (QAbstractButton*)save) {
    //     templateEditorWidget->saveAsText();
    //   }
    // }
    
    m_templateEditorWidgets.removeAll(templateEditorWidget);
    m_project->setClean(false);
  }
Loading