Commit eb6e7518 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Modified ControlPointEdit. In qnet, loading a registration template file after...

Modified ControlPointEdit. In qnet, loading a registration template file after registering a measure will undo registration instead of displaying an error dialog. Fixes #2041.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6025 41f8697f-d340-4b68-9986-7bafba869bb8
parent 061140cb
Loading
Loading
Loading
Loading
+33 −16
Original line number Diff line number Diff line
@@ -861,7 +861,6 @@ namespace Isis {
  }



  /**
   * Find point from left ChipViewport in the right ChipViewport
   *
@@ -896,6 +895,7 @@ namespace Isis {

  }

  
  /**
   * Sub-pixel register point in right chipViewport with point in
   * left.
@@ -1048,11 +1048,11 @@ namespace Isis {
    p_autoReg->setText("Undo Registration");
  }

  
  /**
   * Save control measure under the crosshair in right ChipViewport
   * @internal
   *   @history 2008-12-30 Jeannie Walldren - Modified to update
   *                          user (chooser) name and date when
   *   @history 2008-12-30 Jeannie Walldren - Modified to update user (chooser) name and date when
   *                           point is saved
   *   @history 2010-11-19 Tracie Sucharski - Renamed from savePoint.
   *   @history 2011-03-04 Tracie Sucharski - If auto reg info is shown, save
@@ -1077,7 +1077,9 @@ namespace Isis {
   *                           QnetTool::measureSaved to ::saveMeasure.  The error checking now
   *                           forces the edit lock check box to be unchecked before the measure
   *                           can be saved.
   *
   *   @history 2014-01-09 Ian Humphrey - Modified to prevent segmentation fault that arises when
   *                           registering, opening a template file, and saving the measure.
   *                           Fixes #2041.
   */
  void ControlPointEdit::saveMeasure() {

@@ -1091,13 +1093,7 @@ namespace Isis {
      }

      if (p_autoRegShown) {
        //  Reset AprioriSample/Line to the current coordinate, before the
        //  coordinate is updated with the registered coordinate.
        p_rightMeasure->SetAprioriSample(p_rightMeasure->GetSample());
        p_rightMeasure->SetAprioriLine(p_rightMeasure->GetLine());

        p_rightMeasure->SetChooserName("Application qnet");
        p_rightMeasure->SetType(ControlMeasure::RegisteredSubPixel);
        try {
          //  Save  autoreg parameters to the right measure log entry
          //  Eccentricity may be invalid, check before writing.
          p_rightMeasure->SetLogData(ControlMeasureLogData(
@@ -1111,6 +1107,22 @@ namespace Isis {
          p_rightMeasure->SetLogData(ControlMeasureLogData(
                                     ControlMeasureLogData::MaximumPixelZScore,
                                     maxZScore));
        } 
        // need to handle exception that SetLogData throws if our data is invalid -
        // unhandled exceptions thrown in Qt signal and slot connections produce undefined behavior
        catch (IException &e) {
          QString message = e.toString();
          QMessageBox::critical((QWidget *)parent(), "Error", message);
          return;
        }
        
        //  Reset AprioriSample/Line to the current coordinate, before the
        //  coordinate is updated with the registered coordinate.
        p_rightMeasure->SetAprioriSample(p_rightMeasure->GetSample());
        p_rightMeasure->SetAprioriLine(p_rightMeasure->GetLine());

        p_rightMeasure->SetChooserName("Application qnet");
        p_rightMeasure->SetType(ControlMeasure::RegisteredSubPixel);

        p_autoRegShown = false;
        p_autoRegExtension->hide();
@@ -1167,14 +1179,12 @@ namespace Isis {
  }



  /**
   * Slot to update the geomed right ChipViewport for zoom
   * operations
   * @internal
   *   @history 2008-15-2008  Jeannie Walldren - Added error string to
   *                            iException::Message before
   *                            creating QMessageBox
   *                              iException::Message before creating QMessageBox
   */
  void ControlPointEdit::updateRightGeom() {

@@ -1265,8 +1275,7 @@ namespace Isis {
   *
   * @internal
   *   @history  2007-06-15 Tracie Sucharski - Grey out zoom buttons
   *   @history 2008-15-2008 Jeannie Walldren - Added error string to
   *                            iException::Message before
   *   @history 2008-15-2008 Jeannie Walldren - Added error string to iException::Message before
   *                             creating QMessageBox
   **/
  void ControlPointEdit::setGeom() {
@@ -1465,6 +1474,8 @@ namespace Isis {
   *                          only allow the template file to be modified if
   *                          registration is successfull, otherwise the
   *                          original template file is kept.
   *   @history 2014-12-11 Ian Humphrey - Modified code so opening a template file will undo 
   *                           registration if a point is already registered. Fixes #2041.
   */
  bool ControlPointEdit::setTemplateFile(QString fn) {

@@ -1485,6 +1496,12 @@ namespace Isis {
      p_autoRegFact = reg;

      p_templateFileName = fn;
      
      // undo registration if a point is already registered
      // this prevents the user from saving a measure with invalid data
      if (p_autoRegShown)
        registerPoint();
      
      return true;
    }
    catch (IException &e) {