Commit 9def357f authored by Makayla Shepherd's avatar Makayla Shepherd
Browse files

Modified the Radius Source File label behavior on the Qnet Tool. When there is...

Modified the Radius Source File label behavior on the Qnet Tool. When there is not a radius source open, a point is selected, and a ground source is opened, the radius source will be the ShapeModel of the reference measure if the ShapeModel is a cube. If the ShapeModel is not a cube, the ABC of the target body will be displayed as the Radius Source on the Qnet Tool. If there is not a radius source open, there is not a point selected, and a ground source is opened, the tool will exhibit the same behavior as before. Fixes #2099.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7160 41f8697f-d340-4b68-9986-7bafba869bb8
parent a9f557c3
Loading
Loading
Loading
Loading
+111 −54
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@
#include "PvlEditDialog.h"
#include "SerialNumber.h"
#include "SpecialPixel.h"
#include "Spice.h"
#include "SurfacePoint.h"
#include "Target.h"
#include "ToolPad.h"
#include "UniversalGroundMap.h"
#include "ViewportMainWindow.h"
@@ -190,7 +192,7 @@ namespace Isis {
                             "a projected basemap or an unprojected cube with "
                             "corrected camera pointing.  This will be used "
                             "to set the apriori latitude, longitude.");
    m_radiusFileNameLabel = new QLabel("Radius Source File: ");
    m_radiusFileNameLabel = new QLabel("Radius Source: ");
    m_radiusFileNameLabel->setToolTip("Dem used to set the radius of ground "
                             "control points, Fixed or Constrained.  This must "
                             "be a Dem and is strictly used to set the apriori "
@@ -2232,6 +2234,8 @@ namespace Isis {
   *                          labels.  Fixes #1018
   *   @history 2015-05-19 Ian Humphrey and Makayla Shepherd - moved duplicated code to 
   *                          findPointLocation() and createTemporaryGroundMeasure().
   *   @history 2016-10-07 Makayla Shepherd - Added radius source handling if there is a ground 
   *                          source and there is not a radius source already open. 
   */
  void QnetTool::loadPoint () {

@@ -2282,6 +2286,11 @@ namespace Isis {
      }
    }
    
    //  Load a radius source if there isn't a radius source already open, and there is a ground source
    if (m_groundOpen && !m_demOpen) {
      openReferenceRadius();
    }


    //  Need all files for this point
    for (int i=0; i<m_editPoint->GetNumMeasures(); i++) {
@@ -3632,12 +3641,15 @@ namespace Isis {
   *                           information.
   *   @history 2012-10-05 Tracie Sucharski - Re-factored most of this method, attempting to clean
   *                           up logic, error checking and recovery.
   *   @history 2016-09-26 Makayla Shepherd - Changed the logic for determining the radius source
   *                           when there is not a radius source already open.
   */
  void QnetTool::openGround() {

    QString filter = "Isis cubes (*.cub *.cub.*);;";
    filter += "Detached labels (*.lbl);;";
    filter += "All (*)";
    
    QString ground = QFileDialog::getOpenFileName((QWidget*)parent(),
                                                  "Open ground source",
                                                  ".",
@@ -3739,9 +3751,15 @@ namespace Isis {
      }
    }
    
    if (!m_demOpen) {
      //  If there isn't a radius source already open and there is a point selected
      if (m_editPoint != NULL) {
        openReferenceRadius();
      }
      
      //  Determine file type of ground for setting AprioriSurfacePointSource
      //  and AprioriRadiusSource.
    if (m_groundCube->hasTable("ShapeModelStatistics")) {
      else if (m_groundCube->hasTable("ShapeModelStatistics")) {
        m_groundSurfacePointSource = ControlPoint::SurfacePointSource::Basemap;
        if (!m_demOpen) {
          m_groundRadiusSource = ControlPoint::RadiusSource::DEM;
@@ -3753,14 +3771,8 @@ namespace Isis {
        try {
          ProjectionFactory::CreateFromCube(*m_groundCube);
          m_groundSurfacePointSource = ControlPoint::SurfacePointSource::Basemap;
        // TODO  Add Basemap to ControlPoint::RadiusSource
          if (!m_demOpen) {
          // TODO m_groundRadiusSource = ControlPoint::RadiusSource::Basemap;
            m_groundRadiusSource = ControlPoint::RadiusSource::Ellipsoid;
          PvlGroup mapping = m_groundCube->group("Mapping");
          m_demFile = mapping ["EquatorialRadius"][0]
                         + ", " + mapping ["PolarRadius"][0];
          //
            m_radiusSourceFile = "";
          }
        }
@@ -3769,18 +3781,14 @@ namespace Isis {
            CameraFactory::Create(*m_groundCube);
            m_groundSurfacePointSource = ControlPoint::SurfacePointSource::Reference;
            if (!m_demOpen) {
            //  If level 1, determine the shape model
              PvlGroup kernels = m_groundCube->group("Kernels");
              QString shapeFile = kernels ["ShapeModel"];
              if (shapeFile.contains("dem")) {
                m_groundRadiusSource = ControlPoint::RadiusSource::DEM;
                m_radiusSourceFile = shapeFile;
              //  Open shape file for reading radius later
              initDem(shapeFile);
              }
              else {
                m_groundRadiusSource = ControlPoint::RadiusSource::Ellipsoid;
              m_demFile = "Ellipsoid";
                //  Find pck file from Kernels group
                m_radiusSourceFile = (QString) kernels["TargetAttitudeShape"];
              }
@@ -3800,11 +3808,11 @@ namespace Isis {
          }
        }
      }
    }

    if (m_editPoint != NULL &&
        (m_editPoint->GetType() != ControlPoint::Free)) loadPoint();
    m_groundFileNameLabel->setText("Ground Source File:  " + m_groundFile);
    m_radiusFileNameLabel->setText("Radius Source File:  " + m_demFile);
    

    emit refreshNavList();
    QApplication::restoreOverrideCursor();
@@ -3839,6 +3847,55 @@ namespace Isis {

  }
  
  /** 
   * Open a radius source using the shape model of the reference measure of m_editPoint
   * 
   * @author 2016-10-07 Makayla Shepherd - Changed radius source handling and moved it from OpenGround.
   * 
   * 
   */
  void QnetTool::openReferenceRadius() {
    //Get the reference image's shape model
    QString referenceSN = m_editPoint->GetReferenceSN();
    QString referenceFileName = m_serialNumberList->fileName(referenceSN);
    QScopedPointer<Cube> referenceCube(new Cube(referenceFileName, "r"));
    PvlGroup kernels = referenceCube->group("Kernels");
    QString shapeFile = kernels["ShapeModel"];
    
    //  If the reference measure has a shape model cube then set that as the radius
    //  This will NOT WORK for shape model files (not the default of Null or Ellipsoid)
    //  that are not cubes
    if (shapeFile.contains(".cub")) {
      if (shapeFile.contains("dem")) {
        m_groundRadiusSource = ControlPoint::RadiusSource::DEM;
      }
      else {
        m_groundRadiusSource = ControlPoint::RadiusSource::Ellipsoid;
      }
      
      m_radiusSourceFile = shapeFile;
      
      //  Open shape file for reading radius later
      initDem(shapeFile);  //This will write the labels for us
    }
    
    //  If no shape model then use the ABC of the target body
    else {
      m_groundRadiusSource = ControlPoint::RadiusSource::Ellipsoid;
      Spice *refSpice = new Spice(*referenceCube);
      Distance refRadii[3];
      refSpice->radii(refRadii);
      m_demFile = QString::number(refRadii[0].meters()) + ", " + 
                  QString::number(refRadii[1].meters()) + ", " +
                  QString::number(refRadii[2].meters());
                  
      m_radiusSourceFile = "";
      
      //  Write out the labels
      m_groundFileNameLabel->setText("Ground Source File:  " + m_groundFile);
      m_radiusFileNameLabel->setText("Radius Source:  " + m_demFile);
    }
  }

  void QnetTool::initDem (QString demFile) {

+10 −0
Original line number Diff line number Diff line
@@ -234,6 +234,15 @@ namespace Isis {
   *   @history 2016-03-17 Makayla Shepherd - Modified addMeasures so that new measures use the
   *                           Reference Measure in order to keep the behavior consistent. 
   *                           Fixes #2326.
   *   @history 2016-10-07 Makayla Shepherd - Modified the Radius Source File label behavior on the 
   *                           Qnet Tool. When there is not a radius source open, a point is 
   *                           selected, and a ground source is opened, the radius source will be 
   *                           the ShapeModel of the reference measure if the ShapeModel is a cube. 
   *                           If the ShapeModel is not a cube, the ABC of the target body will be 
   *                           displayed as the Radius Source on the Qnet Tool. If there is not a 
   *                           radius source open, there is not a point selected, and a ground 
   *                           source is opened, the tool will exhibit the same behavior as before. 
   *                           Fixes #2099.
   *                           
   */
  class QnetTool : public Tool {
@@ -344,6 +353,7 @@ namespace Isis {
      void openGround();
      void groundViewportClosed(CubeViewport *);
      void openDem();
      void openReferenceRadius();
      void showHideTemplateEditor();
      void saveTemplateFile();
      void saveTemplateFileAs();