Commit 26cb341e authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Changed the handling of choosing ground/radius source files for constrained...

Changed the handling of choosing ground/radius source files for constrained and fixed points. Fixed seg fault when saving project containing footprint view containing a shape model. Update the control net name on the Footprint view when a new active control is chosen. Allow shape models without a footprint in the cube labels to be shown in the footprint view.  Fixes #5518, #5504, #5495.
parent 67b5958e
Loading
Loading
Loading
Loading
+65 −29
Original line number Diff line number Diff line
@@ -47,8 +47,6 @@ namespace Isis {
   * @param allowLeftMouse[in] Allow/Disallow mouse events on Left ChipViewport
   * @param useGeometry[in]    Allow/Disallow geometry and rotation on right ChipViewport
   *
   * @throws IException::Io    "Cannot create AutoRegFactory. As a result, sub-pixel registration
   *                            will not work."
   * @author Tracie Sucharski
   * @internal
   *   @history 2008-15-??  Jeannie Walldren - Added error
@@ -72,20 +70,7 @@ namespace Isis {
    m_leftGroundMap = 0;
    m_rightGroundMap = 0;

    try {
    m_templateFileName = "$base/templates/autoreg/qnetReg.def";
      Pvl pvl(m_templateFileName);
      m_autoRegFact = AutoRegFactory::Create(pvl);
    }
    catch (IException &e) {
      m_autoRegFact = NULL;
      IException fullError(e, IException::Io,
                           "Cannot create AutoRegFactory. As a result, "
                           "sub-pixel registration will not work.",
                           _FILEINFO_);
      QString message = fullError.toString();
      QMessageBox::information((QWidget *)parent, "Error", message);
    }

    createMeasureEditor(parent);
  }
@@ -769,6 +754,20 @@ namespace Isis {
  }


  void ControlMeasureEditWidget::setLeftPosition(double sample, double line) {

    m_leftChip->TackCube(sample, line);
    emit updateLeftView(sample, line);
  }


  void ControlMeasureEditWidget::setRightPosition(double sample, double line) {

    m_rightChip->TackCube(sample, line);
    emit updateRightView(sample, line);
  }


  /**
   * Set the measure displayed in the right ChipViewport
   *
@@ -1012,10 +1011,29 @@ namespace Isis {
   *                             successful, change save button to red.
   *   @history 2011-10-21  Tracie Sucharski - Add try/catch around registration
   *                             to catch errors thrown from autoreg class.
   *   @history 2017-04-21 Marjorie Hahn - Added auto registration factory creation.
   *
   */
  void ControlMeasureEditWidget::registerPoint() {

    // if the auto registration factory has not been initialized, do it here
    if (m_autoRegFact == NULL) {
      try {
        Pvl pvl(m_templateFileName);
        m_autoRegFact = AutoRegFactory::Create(pvl);
      }
      catch (IException &e) {
        m_autoRegFact = NULL;
        IException fullError(e, IException::Io,
                            "Cannot create AutoRegFactory. As a result, "
                            "sub-pixel registration will not work.",
                            _FILEINFO_);
        QString message = fullError.toString();
        QMessageBox::information((QWidget *)parent(), "Error", message);
        return;
      }
    }

    if ( m_autoRegShown ) {
      //  Undo Registration
      m_autoRegShown = false;
@@ -1174,6 +1192,11 @@ 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 2015-01-09 Ian Humphrey - Modified to prevent segmentation fault that arises when
   *                           registering, opening a template file, and saving the measure. This
   *                           was caused by not handling the exception thrown by
   *                           ControlMeasure::SetLogData(), which produces undefined behavior
   *                           within the Qt signal-slot connection mechanism.
   *
   */
  void ControlMeasureEditWidget::saveMeasure() {
@@ -1188,13 +1211,7 @@ namespace Isis {
      }

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

        m_rightMeasure->SetChooserName("Application qnet");
        m_rightMeasure->SetType(ControlMeasure::RegisteredSubPixel);
        try {
          //  Save  autoreg parameters to the right measure log entry
          //  Eccentricity may be invalid, check before writing.
          m_rightMeasure->SetLogData(ControlMeasureLogData(
@@ -1208,10 +1225,29 @@ namespace Isis {
          m_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.
        m_rightMeasure->SetAprioriSample(m_rightMeasure->GetSample());
        m_rightMeasure->SetAprioriLine(m_rightMeasure->GetLine());

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

        m_autoRegShown = false;
        m_autoRegExtension->hide();
        m_autoReg->setText("Register");
        m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
                              "<strong>Shortcut: R</strong>");
        m_autoReg->setShortcut(Qt::Key_R);
      }
      else {
        m_rightMeasure->SetChooserName(Application::UserName());
+12 −0
Original line number Diff line number Diff line
@@ -148,6 +148,15 @@ namespace Isis {
    *                           shortcut errors. Set the shortcut and tooltip of m_autoReg inside of
    *                           registerPoint() to allow the user to use the shortcut after an
    *                           undo-registration ocurs.
    *   @history 2018-09-06 Tracie Sucharski - Added bug fixes from qnet's ControlPointEdit class
    *                           including moving the creation of AutoRegFactory from constructor
    *                           to the registerPoint method and fixing seg fault happening in
    *                           saveMeasure when calling ControlMeasure::SetLogData.
    *   @history 2018-09-24 Tracie Sucharski - Fixed right measure chooser name to the
    *                           Application::User.
    *   @history 2018-09-26 Tracie Sucharski - Added public method to allow change measure tack
    *                           points.
    *                          
    *   @todo  Re-think design of the change made on 2012-07-26.  The linking was put into
    *                          ::updateLeftPositionLabel because it was the fastest solution, but
    *                          should this be put somewhere else.
@@ -169,6 +178,9 @@ namespace Isis {
      };
      void allowLeftMouse(bool allowMouse);

      void setLeftPosition(double sample, double line);
      void setRightPosition(double sample, double line);

    signals:
      void updateLeftView(double sample, double line);
      void updateRightView(double sample, double line);
+104 −16
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@
#include "MdiCubeViewport.h"
#include "Project.h"
#include "SerialNumber.h"
#include "Shape.h"
#include "ShapeList.h"
#include "ToolPad.h"
#include "UniversalGroundMap.h"
#include "ViewportMainWindow.h"
@@ -140,12 +142,13 @@ namespace Isis {

    if (s == Qt::LeftButton) {

//      if (sn == m_groundSN) {
//        QString message = "Cannot select point for editing on ground source.  Select ";
//        message += "point using un-projected images or the Navigator Window.";
//        QMessageBox::critical(m_ControlNetTool, "Error", message);
//        return;
//      }
      if (isGroundSource) {
        QString message = "Cannot select point for editing on ground source.  Select ";
        message += "point using un-projected images or the Cnet Editor View (choose \"View Network\" ";
        message += "from the context menu for control nets on the project tree).";
        QMessageBox::critical(m_ControlNetTool, "Error", message);
        return;
      }

      //  Find closest control point in network
      // since we are in a connected slot, we need to handle exceptions thrown by FindClosest
@@ -170,12 +173,13 @@ namespace Isis {
        return;
      }

//      if (m_groundOpen && file == m_groundCube->fileName()) {
//        QString message = "Cannot select point for deleting on ground source.  Select ";
//        message += "point using un-projected images or the Navigator Window.";
//        QMessageBox::critical(m_ControlNetTool, "Error", message);
//        return;
//      }
      if (isGroundSource) {
        QString message = "Cannot select point for deleting on ground source.  Select ";
        message += "point using un-projected images or the Cnet Editor View (choose \"View Network\" ";
        message += "from the context menu for control nets on the project tree).";
        QMessageBox::critical(m_ControlNetTool, "Error", message);
        return;
      }

      //  Find closest control point in network
      ControlPoint *point = NULL;
@@ -284,10 +288,23 @@ namespace Isis {
    // TODO: Should we add the SN to the viewPort
    QString serialNumber = SerialNumber::Compose(*vp->cube(), true);

//    if (serialNumber == m_groundSN) {
//      drawGroundMeasures(vp, painter);
//      return;
//    }
    // Get list of shapes in the ipce project and see if the serial number for viewport passed in
    // matches any of the project shapes.  If there's a match, draw any ground measures.
    QList<ShapeList *> projectShapes = m_directory->project()->shapes();
    foreach (ShapeList *shapeList, projectShapes) {
      foreach (Shape *shape, *shapeList) {
        QString shapeSn = shape->serialNumber();
        if (serialNumber == shapeSn) {
          //  Get cube, then ground map so that location can be calculated
          UniversalGroundMap *gmap = new UniversalGroundMap(*(shape->cube()));
          drawGroundMeasures(vp, painter, gmap);
          delete gmap;
          gmap = NULL;
          return;
        }
      }
    }


    if (!m_controlNet->GetCubeSerials().contains(
                      serialNumber)) return;
@@ -352,4 +369,75 @@ namespace Isis {
      }
    }
  }


  /**
   * Draw all Fixed or Constrained points on the ground source viewport
   * @param vp Viewport whose measurements will be drawn
   * @param painter
   *
   * @author 2011-09-16  Tracie Sucharski
   *
   * @internal
   */
  void ControlNetTool::drawGroundMeasures(MdiCubeViewport *vp, QPainter *painter,
                                          UniversalGroundMap *groundMap) {


    // if ControlPointEditView is open, the editPointId will contain the ControlPoint Id of the
    // current edit point. Save so that when drawing point, it can be drawn to indicate current
    // edit point.
    ControlPoint *currentEditPoint = NULL;
    if (m_directory->controlPointEditView()) {
      currentEditPoint = m_directory->controlPointEditView()->controlPointEditWidget()->editPoint();
    }


    // loop through control network looking for fixed and constrained points
    for (int i = 0; i < m_controlNet->GetNumPoints(); i++) {
      ControlPoint &p = *((*m_controlNet)[i]);
      if (p.GetType() == ControlPoint::Free) continue;
      if (!p.HasAprioriCoordinates()) continue;

      // Find the measure on the ground image
      if (groundMap->SetGround(p.GetAprioriSurfacePoint().GetLatitude(),
                               p.GetAprioriSurfacePoint().GetLongitude())) {
        double samp = groundMap->Sample();
        double line = groundMap->Line();
        int x, y;
        vp->cubeToViewport(samp, line, x, y);

        // if the point is ignored,
        if (p.IsIgnored()) {
          painter->setPen(QColor(255, 255, 0)); // set point marker yellow
          // draw points
          painter->drawLine(x - 5, y, x + 5, y);
          painter->drawLine(x, y - 5, x, y + 5);
        }
        // If this point is the current edit point in ControlPointEditView
        else if (currentEditPoint != NULL && &p == currentEditPoint) {
          //  Draw circle, then crosshair inside circle
          QPainterPath path;
          path.addEllipse(QPointF(x,y), 5., 5.);
          path.moveTo(x, y-5);
          path.lineTo(x, y+5);
          path.moveTo(x-5, y);
          path.lineTo(x+5, y);
          // set point marker red
          QBrush brush(Qt::red);
          // set point marker bold - line width 2
          QPen pen(brush, 2);
          painter->setPen(pen);
          painter->drawPath(path);
        }
        //  Only Constrained or Fixed pts.  If Free, we've already skipped.
        else {
          painter->setPen(Qt::magenta);// set point marker magenta
          // draw points
          painter->drawLine(x - 5, y, x + 5, y);
          painter->drawLine(x, y - 5, x, y + 5);
        }
      }
    }
  }
}
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ namespace Isis {
   *                           loaded.
   *   @history 2018-04-13 Tracie Sucharski - In mouseButtonRelease method return if a control net
   *                           has not been set.
   *   @history 2018-09-21 Tracie Sucharski - Draw Fixed and Constrained points on ground cubes.
   *                           Refereces #5504.
   */
  class ControlNetTool : public Tool {
    Q_OBJECT
@@ -91,6 +93,7 @@ namespace Isis {
      void createActions();
      void createMenus();
      void drawAllMeasurements(MdiCubeViewport *vp, QPainter *painter);
      void drawGroundMeasures (MdiCubeViewport *vp, QPainter *painter, UniversalGroundMap *groundMap);

      QPointer<MainWindow> m_ControlNetTool;
      Directory *m_directory;
+793 −301

File changed.

Preview size limit exceeded, changes collapsed.

Loading