Commit 796ab7e8 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Change shape/color of the control point being edited in the CubeDnView and...

Change shape/color of the control point being edited in the CubeDnView and Footprint2DView.  Update both views when control point is created or deleted.  Fixes #5007, #5008.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7908 41f8697f-d340-4b68-9986-7bafba869bb8
parent 1c9f0926
Loading
Loading
Loading
Loading
+84 −328
Original line number Diff line number Diff line
@@ -79,8 +79,6 @@ namespace Isis {
    m_changeAllGroundLocation = false;
    m_changeGroundLocationInNet = false;

//  qDebug()<<"ControlPointEditWidget::ControlPointEditWidget  #shapes = "<<m_directory->project()->shapes().count()<<"  1st shape= "<<m_directory->project()->shapes().at(0)->at(0)->fileName();

    m_parent = parent;

    createPointEditor(parent, m_addMeasuresButton);
@@ -98,6 +96,26 @@ namespace Isis {
  }


  QString ControlPointEditWidget::editPointId() {

    QString result = "";
    if (m_editPoint) {
      result = m_editPoint->GetId();
    }
    return result;
  }


  ControlPoint *ControlPointEditWidget::editPoint() {

    ControlPoint *result = NULL;
    if (m_editPoint) {
      result = m_editPoint;
    }
    return result;
  }


  /**
   * Create the widget for editing control points
   *
@@ -533,7 +551,6 @@ namespace Isis {
   * @internal
  */  
  void ControlPointEditWidget::setControl(Control *control) {
    //qDebug()<<"ControlPointEditWidget::setControlNet cnet = "<<cnet<<"   filename = "<<cnetFilename;
    //  TODO  more error checking
    m_controlNet = control->controlNet();
    m_cnetFileName = control->fileName();
@@ -704,17 +721,23 @@ namespace Isis {
   * @param controlPoint Pointer to the ControlPoint to edit
   */
  void ControlPointEditWidget::setEditPoint(ControlPoint *controlPoint, QString serialNumber) {
    //qDebug()<<"ControlPointEditWidget::setEditPoint incoming ptId = "<<controlPoint->GetId();

    //  If m_editPoint was never saved to control net (parent=NULL), delete
    if (m_editPoint != NULL && m_editPoint->Parent() == NULL) {
      delete m_editPoint;
      m_editPoint = NULL;
    }

    //  Create copy of ControlPoint.  It will not be saved to net until "Save Point" is selected
    //  If incoming control point is new point (has not been saved to control net, simply assign
    //  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;
    }
    else {
      m_editPoint = new ControlPoint;
      *m_editPoint = *controlPoint;
    //qDebug()<<"ControlPointEditWidget::setEditPoint m_editPoint Id = "<<m_editPoint->GetId();
    }

    loadPoint(serialNumber);
    this->setVisible(true);
@@ -770,9 +793,6 @@ namespace Isis {
    m_rightCombo->clear();
    m_pointFiles.clear();

    m_pointCubes.clear();


    //  If fixed, add ground source file to combos, create a measure for
    //  the ground source, load reference on left, ground source on right
    if (m_editPoint->GetType() != ControlPoint::Free) {
@@ -887,8 +907,6 @@ namespace Isis {
    //  Initialize pointEditor with measures
    selectLeftMeasure(leftIndex);
    selectRightMeasure(rightIndex);

//     loadMeasureTable();
  }


@@ -1002,40 +1020,18 @@ namespace Isis {
      }

      setEditPoint(newPoint);
//    if (m_editPoint != NULL && m_editPoint->Parent() == NULL) {
//      delete m_editPoint;
//      m_editPoint = NULL;
//    }
//    m_editPoint = newPoint;
//
//    //  If the image that the user clicked on to select the point is not
//    //  included, clear out the leftFile value.
//    if (!m_leftFile.isEmpty()) {
//      if (selectedFiles.indexOf(m_leftFile) == -1) {
//        m_leftFile.clear();
//      }
//    }
//
//    //  Load new point in QnetTool
//    loadPoint();
//
//  // If cube valid, use as reference
//  if (cube) {
//
//  }


      emit controlPointAdded(newPoint->GetId());
    }
  }


  /**
   * Gives user options for deleting a control point from the control network.
   * 
   * @param controlPoint (ControlPoint *) Control point to be deleted
   */
  void ControlPointEditWidget::deletePoint(ControlPoint *controlPoint) {

    //  TODO  2016-09-16 TLS   IMPLEMENT!
//  QString message = "Deleting control point not implemented yet";
//  QMessageBox::critical(this, "NOT IMPLEMENTED YET", message);

    // Make a copy and make sure editPoint is a copy (which means it does not
    // have a parent network.
    if (m_editPoint != NULL && m_editPoint->Parent() == NULL) {
@@ -1046,11 +1042,6 @@ namespace Isis {
    *m_editPoint = *controlPoint;
    loadPoint();

    //  Change point in viewport to red so user can see what point they are
    //  about to delete.
    // the nav tool will update edit point
    emit controlPointChanged(m_editPoint->GetId());

    DeleteControlPointDialog *deletePointDialog = new DeleteControlPointDialog;
    QString CPId = m_editPoint->GetId();
    deletePointDialog->pointIdValue->setText(CPId);
@@ -1084,10 +1075,6 @@ namespace Isis {
          }
        }

        //  First get rid of deleted point from m_filteredPoints list
        //  need index in control net for pt
        //int i = m_controlNet->
        //m_filteredPoints.
        // remove this point from the control network
        if (m_controlNet->DeletePoint(m_editPoint->GetId()) ==
                                          ControlPoint::PointLocked) {
@@ -1099,8 +1086,6 @@ namespace Isis {
          delete m_editPoint;
          m_editPoint = NULL;
        }
        //  emit signal so the nav tool refreshes the list
//      emit refreshNavList();
      }

      //  Delete specific measures from control point
@@ -1155,20 +1140,11 @@ namespace Isis {
      // emit a signal to alert user to save when exiting
      emit cnetModified();

      // emit signal so the nav tool can update edit point
      if (m_editPoint != NULL) {
//      emit editPointChanged(m_editPoint->GetId());
        //  Change Save Point button text to red
        colorizeSaveNetButton();
      }
      else {
        // if the entire point is deleted, update with point Id = ""
        // this signal is connected to QnetTool::paintAllViewports
        // and QnetNavTool::updateEditPoint
//      emit editPointChanged("");
      }
    }

  }


@@ -1302,8 +1278,6 @@ namespace Isis {
    // Update measure info
    updateLeftMeasureInfo();
    updateRightMeasureInfo();
    loadMeasureTable();

  }


@@ -1815,224 +1789,6 @@ namespace Isis {
  }


  /**
   * @brief Load measure information into the measure table
   *
   * @internal
   *   @history 2011-12-05 Tracie Sucharski - Turn off sorting until table is loaded.
   *
   */
  void ControlPointEditWidget::loadMeasureTable () {
    if (m_measureWindow == NULL) {
      m_measureWindow = new QMainWindow(m_parent);
      m_measureTable = new QTableWidget();
      m_measureTable->setMinimumWidth(1600);
      m_measureTable->setAlternatingRowColors(true);
      m_measureWindow->setCentralWidget(m_measureTable);
    }
    else {
      m_measureTable->clear();
      m_measureTable->setSortingEnabled(false);
    }
    m_measureTable->setRowCount(m_editPoint->GetNumMeasures());
    m_measureTable->setColumnCount(NUMCOLUMNS);

    QStringList labels;
    for (int i=0; i<NUMCOLUMNS; i++) {
      labels<<measureColumnToString((MeasureColumns)i);
    }
    m_measureTable->setHorizontalHeaderLabels(labels);

    //  Fill in values
    for (int row=0; row<m_editPoint->GetNumMeasures(); row++) {
      int column = 0;
      ControlMeasure &m = *(*m_editPoint)[row];

      QString file = m_serialNumberList->fileName(m.GetCubeSerialNumber());
      QTableWidgetItem *tableItem = new QTableWidgetItem(QString(file));
      m_measureTable->setItem(row,column++,tableItem);

      tableItem = new QTableWidgetItem(QString(m.GetCubeSerialNumber()));
      m_measureTable->setItem(row,column++,tableItem);

      tableItem = new QTableWidgetItem();
      tableItem->setData(0,m.GetSample());
      m_measureTable->setItem(row,column++,tableItem);

      tableItem = new QTableWidgetItem();
      tableItem->setData(0,m.GetLine());
      m_measureTable->setItem(row,column++,tableItem);

      if (m.GetAprioriSample() == Null) {
        tableItem = new QTableWidgetItem("Null");
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,m.GetAprioriSample());
      }
      m_measureTable->setItem(row,column++,tableItem);

      if (m.GetAprioriLine() == Null) {
        tableItem = new QTableWidgetItem("Null");
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,m.GetAprioriLine());
      }
      m_measureTable->setItem(row,column++,tableItem);

      if (m.GetSampleResidual() == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,m.GetSampleResidual());
      }
      m_measureTable->setItem(row,column++,tableItem);

      if (m.GetLineResidual() == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,m.GetLineResidual());
      }
      m_measureTable->setItem(row,column++,tableItem);

      if (m.GetResidualMagnitude() == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,m.GetResidualMagnitude());
      }
      m_measureTable->setItem(row,column++,tableItem);

      double sampleShift = m.GetSampleShift();
      if (sampleShift == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,sampleShift);
      }
      m_measureTable->setItem(row,column++,tableItem);

      double lineShift = m.GetLineShift();
      if (lineShift == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,lineShift);
      }
      m_measureTable->setItem(row,column++,tableItem);

      double pixelShift = m.GetPixelShift();
      if (pixelShift == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,pixelShift);
      }
      m_measureTable->setItem(row,column++,tableItem);

      double goodnessOfFit = m.GetLogData(
                      ControlMeasureLogData::GoodnessOfFit).GetNumericalValue();
      if (goodnessOfFit == Null) {
        tableItem = new QTableWidgetItem(QString("Null"));
      }
      else {
        tableItem = new QTableWidgetItem();
        tableItem->setData(0,goodnessOfFit);
      }
      m_measureTable->setItem(row,column++,tableItem);

      if (m.IsIgnored()) tableItem = new QTableWidgetItem("True");
      if (!m.IsIgnored()) tableItem = new QTableWidgetItem("False");
      m_measureTable->setItem(row,column++,tableItem);

      if (IsMeasureLocked(m.GetCubeSerialNumber()))
        tableItem = new QTableWidgetItem("True");
      if (!IsMeasureLocked(m.GetCubeSerialNumber()))
        tableItem = new QTableWidgetItem("False");
      m_measureTable->setItem(row,column++,tableItem);

      tableItem = new QTableWidgetItem(
                  ControlMeasure::MeasureTypeToString(m.GetType()));
      m_measureTable->setItem(row,column,tableItem);

      //  If reference measure set font on this row to bold
      if (m_editPoint->IsReferenceExplicit() &&
          (QString)m.GetCubeSerialNumber() == m_editPoint->GetReferenceSN()) {
        QFont font;
        font.setBold(true);

        for (int col=0; col<m_measureTable->columnCount(); col++)
          m_measureTable->item(row, col)->setFont(font);
      }

    }

    m_measureTable->resizeColumnsToContents();
    m_measureTable->resizeRowsToContents();
    m_measureTable->setSortingEnabled(true);
    m_measureWindow->show();
  }


  /**
   * Gets a string representation of a measure column
   *
   * @param column MeasureColumn to get the string representation of
   *
   * @throws IException::Programmer "Invalid measure column passed to measureColumnToString"
   *
   * @return @b QString String representation of the passed measure column
   */
  QString ControlPointEditWidget::measureColumnToString(
      ControlPointEditWidget::MeasureColumns column) {

    switch (column) {
      case FILENAME:
        return "FileName";
      case CUBESN:
        return "Serial #";
      case SAMPLE:
        return "Sample";
      case LINE:
        return "Line";
      case SAMPLERESIDUAL:
        return "Sample Residual";
      case LINERESIDUAL:
        return "Line Residual";
      case RESIDUALMAGNITUDE:
        return "Residual Magnitude";
      case SAMPLESHIFT:
        return "Sample Shift";
      case LINESHIFT:
        return "Line Shift";
      case PIXELSHIFT:
        return "Pixel Shift";
      case GOODNESSOFFIT:
        return "Goodness of Fit";
      case IGNORED:
        return "Ignored";
      case EDITLOCK:
        return "Edit Lock";
      case TYPE:
        return "Measure Type";
      case APRIORISAMPLE:
        return "Apriori Sample";
      case APRIORILINE:
        return "Apriori Line";
    }
    throw IException(IException::Programmer,
        "Invalid measure column passed to measureColumnToString", _FILEINFO_);
  }


  /**
   * @brief Selects the next right measure when activated by key shortcut
   *
@@ -2599,8 +2355,8 @@ namespace Isis {
  /**
   * Turn "Save Net" button text to red
   *  
   * @TODO  Need whoever is actually saving network to emit signal when net has been saved, so
   * that button can be set back to black.
   * TODO  Need whoever is actually saving network to emit signal when net has been saved, so that 
   * button can be set back to black. 
   *  
   * @author 2014-07-11 Tracie Sucharski
   */
+11 −33
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ namespace Isis {
   *                           includes allowing the option to change the location in the active
   *                           control for all ground points.
   *   @history 2017-05-18 Tracie Sucharski - Added serialNumber to the setEditPoint slot.
   *   @history 2017-08-02 Tracie Sucharski - Added methods to return the current editPoint and
   *                           current editPoint Id.  Removed measure table methods. Fixes #5007,
   *                           #5008.
   */
  class ControlPointEditWidget : public QWidget {
    Q_OBJECT
@@ -71,30 +74,8 @@ namespace Isis {
      ControlPointEditWidget(Directory *directory, QWidget *parent, bool addMeasures = false);
      virtual ~ControlPointEditWidget();

      //! Measure column values for the measure table
      enum MeasureColumns{
        FILENAME,
        CUBESN,
        SAMPLE,
        LINE,
        APRIORISAMPLE,
        APRIORILINE,
        SAMPLERESIDUAL,
        LINERESIDUAL,
        RESIDUALMAGNITUDE,
        SAMPLESHIFT,
        LINESHIFT,
        PIXELSHIFT,
        GOODNESSOFFIT,
        IGNORED,
        EDITLOCK,
        TYPE
      };
      //! Number of entries (columns) in the measure table
      static const int NUMCOLUMNS = 16;

      QString measureColumnToString(MeasureColumns column);

      QString editPointId();
      ControlPoint *editPoint();

    signals:
      void controlPointChanged(QString pointId);
@@ -118,7 +99,6 @@ namespace Isis {
                              bool isGroundSource = false);

      void updatePointInfo(ControlPoint &updatedPoint);
//    void refresh();

    protected:
      bool eventFilter(QObject *o,QEvent *e);
@@ -126,7 +106,6 @@ namespace Isis {
    private slots:
//    void enterWhatsThisMode();
      void saveNet();
//    void saveAsNet();
//    void addMeasure();
//    void setPointType (int pointType);
      void setLockPoint (bool ignore);
@@ -251,12 +230,11 @@ namespace Isis {
      QScopedPointer<Cube> m_leftCube; //!< Left cube
      QScopedPointer<Cube> m_rightCube; //!< Right cube

      QList<Cube *> m_pointCubes;

      QString m_groundSN;
      bool m_changeAllGroundLocation;
      bool m_changeGroundLocationInNet;
      QString m_newGroundDir;
      QString m_groundSN; //!< Serial number of ground source file
      bool m_changeAllGroundLocation; //!< Change the ground source location of all fixed,
                                      //!  constrained points in the network
      bool m_changeGroundLocationInNet; //!< Change the ground source location 
      QString m_newGroundDir; //!< Contains the ground source location
  };
};
#endif
+5 −1
Original line number Diff line number Diff line
@@ -172,7 +172,11 @@ namespace Isis {

    // Pass on signals emitted from Directory (by way of ControlPointEditWidget)
    // This is done to redraw the control points on the cube viewports
    connect(this, SIGNAL(controlPointAdded(QString)), ipceTool, SLOT(refresh()));
    connect(this, SIGNAL(controlPointAdded(QString)), ipceTool, SLOT(paintAllViewports()));

    //  Pass on redrawMeasure signal from Directory, so the control measures are redrawn on all
    //  CubeViewports.
    connect(this, SIGNAL(redrawMeasures()), ipceTool, SLOT(paintAllViewports()));

    tools->append(new BandTool(this));
    tools->append(new ZoomTool(this));
+4 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ namespace Isis {
   *   @history 2017-07-27 Tyler Wilson - Added a slot function (enableIPCETool) which is called
   *                           when a control network (or list of control networks) is added to
   *                           the active project.  Fixes #4994.
   *   @history 2017-08-02 Tracie Sucharski - Added redrawMeasures signal which calls a slot in
   *                           ipce tool to redraw control measures on cube viewports. Fixes #5007,
   *                           #5008.
   */
  class CubeDnView : public AbstractProjectItemView {

@@ -111,6 +114,7 @@ namespace Isis {
                              bool isGroundSource = false);

      void controlPointAdded(QString newPointId);
      void redrawMeasures();

    public slots:
      void addItem(ProjectItem *item);
+80 −33

File changed.

Preview size limit exceeded, changes collapsed.

Loading