Unverified Commit b798898b authored by kledmundson's avatar kledmundson Committed by GitHub
Browse files

Merge pull request #114 from TracieSucharski/ipce

Ipce - Fixes to setting new active control. References #5026. 
parents a08b7ae9 219ec554
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -99,9 +99,12 @@ namespace Isis {
    */
   void ControlNetTool::setControlNet(ControlNet *cnet) {
     m_controlNet = cnet;
     // TODO:  TLS 7-25-17  This method is called by Project::open before there are any viewports,
     // so the following command seg faults.  Need to add check for viewports or ??
     //paintAllViewports();
    
     //  Cannot use Tool::cubeViewportList() because it does not properly return a NULL if viewports
     //  don't exist.
     if (workspace() && workspace()->cubeViewportList()) {
       paintAllViewports();
     }
   }


+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ namespace Isis {
   *                           networks Fixes #4567
   *   @history 2018-03-12 Tracie Sucharski - Fixed some documentation leftover from renaming from
   *                           IpceTool.  References #5090.
   *   @history 2018-03-27 Tracie Sucharski - Redraw cube viewports when a new control net is
   *                           loaded.
   */
  class ControlNetTool : public Tool {
    Q_OBJECT
+24 −3
Original line number Diff line number Diff line
@@ -579,19 +579,40 @@ namespace Isis {
  /**
   * New control network being edited
   *
   * @param cnet (ControlNet *) The control network to edit
   * @param filename (Qstring) Need filename to write to widget label.  ControlNet doesn't
   *                       contain a filename.
   * @param cnet (Control *) The control network to edit
   *  
   * @internal
  */
  void ControlPointEditWidget::setControl(Control *control) {
    //  TODO  more error checking
    m_controlNet = control->controlNet();
    m_cnetFileName = control->fileName();

    m_cnetFileNameLabel->setText("Control Network: " + m_cnetFileName);
    setWindowTitle("Control Point Editor- Control Network File: " + m_cnetFileName);

    emit newControlNetwork(m_controlNet);
  }


  /**
   * New active control was set from ipce 
   *  
   * TODO:  This will need to be redesigned with the ::setControl method to better handle editing 
   * points from different cnets. 
   */
  void ControlPointEditWidget::setControlFromActive() {

    if (m_directory->project()->activeControl()) {
      m_controlNet = m_directory->project()->activeControl()->controlNet();
      m_cnetFileName = m_directory->project()->activeControl()->fileName();

      m_cnetFileNameLabel->setText("Control Network: " + m_cnetFileName);
      setWindowTitle("Control Point Editor- Control Network File: " + m_cnetFileName);

      emit newControlNetwork(m_controlNet);    
    }
  }


  /**
+7 −3
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ namespace Isis {
   *                           Fixes #4984.
   *   @history 2017-08-15 Tracie Sucharski - When ControlPoint is deleted, set the visibility of
   *                            this widget to false, then to true in loadPoint().  Fixes #5073.
   *   @history 2018-03-23 Tracie Sucharski - Update the cnet filename with current cnet.
   *   @history 2018-03-26 Tracie Sucharski - Update editor if a new active control net is set in
   *                            ipce. References #4567.
   */
  class ControlPointEditWidget : public QWidget {
    Q_OBJECT
@@ -104,6 +107,7 @@ namespace Isis {
    public slots:
      void setSerialNumberList(SerialNumberList *snList);
      void setControl(Control *control);
      void setControlFromActive();
      void setEditPoint(ControlPoint *controlPoint, QString serialNumber = "");
      void deletePoint(ControlPoint *controlPoint);

+48 −18
Original line number Diff line number Diff line
@@ -533,6 +533,9 @@ namespace Isis {


  void Directory::newActiveControl(bool newControl) {

    // If the new active control is the same as what is showing in the cnetEditorWidget, allow
    // editing of control points from the widget, otherwise turnoff from context menu
    foreach(CnetEditorWidget *cnetEditorView, m_cnetEditorViewWidgets) {
      if (cnetEditorView->control() == project()->activeControl()->controlNet()) {
        cnetEditorView->pointTableView()->content()->setActiveControlNet(true);
@@ -618,6 +621,7 @@ namespace Isis {
    QMenuBar *menuBar = new QMenuBar;
    resultLayout->addWidget(menuBar, row, 0, 1, 2);
    row++;

    CnetEditorWidget *mainWidget = new CnetEditorWidget(network, configFile.expanded());
    resultLayout->addWidget(mainWidget, row, 0, 1, 2);
    row++;
@@ -743,16 +747,19 @@ namespace Isis {
    connect(this, SIGNAL(redrawMeasures()), result, SIGNAL(redrawMeasures()));
    connect(this, SIGNAL(cnetModified()), result, SIGNAL(redrawMeasures()));

    if (!project()->activeControl()) {
    // Note:  This assumes the Control Net tool is the 1st in the toolpad.
    QList<QAction *> toolbar = result->toolPadActions();
    QAction* cnetAction = toolbar[0];
    ControlNetTool *cnetTool = static_cast<ControlNetTool *>(cnetAction->parent());

      cnetAction->setEnabled(false);
    connect (project(), SIGNAL(activeControlSet(bool)),
             cnetAction, SLOT(setEnabled(bool)));
    connect (project(), SIGNAL(activeControlSet(bool)),
             cnetTool, SLOT(loadNetwork()));

    //  If an active control has not been set, make the control net tool inactive
    if (!project()->activeControl()) {
      cnetAction->setEnabled(false);
    }

    return result;
@@ -796,18 +803,19 @@ namespace Isis {
    //  to be drawn with different color/shape.
    connect(this, SIGNAL(redrawMeasures()), result, SIGNAL(redrawMeasures()));

    //  Control Net tool will only be active if the project has an active Control.  Note:  This
    //  assumes the Control Net tool is the 4th in the toolpad.
    if (!project()->activeControl()) {
    // Note:  This assumes the Control Net tool is the 4th in the toolpad.
    QList<QAction *> toolbar = result->toolPadActions();
    QAction* cnetAction = toolbar[3];
      MosaicControlNetTool *cnetButton = static_cast<MosaicControlNetTool *>(cnetAction->parent());
    MosaicControlNetTool *cnetTool = static_cast<MosaicControlNetTool *>(cnetAction->parent());

      cnetAction->setEnabled(false);
    connect (project(), SIGNAL(activeControlSet(bool)),
             cnetAction, SLOT(setEnabled(bool)));
    connect (project(), SIGNAL(activeControlSet(bool)),
              cnetButton, SLOT(loadNetwork()));
             cnetTool, SLOT(loadNetwork()));

    //  Control Net tool will only be active if the project has an active Control.
    if (!project()->activeControl()) {
      cnetAction->setEnabled(false);
    }

    return result;
@@ -865,6 +873,8 @@ namespace Isis {

      connect(result->controlPointEditWidget(), SIGNAL(saveControlNet()),
              this, SLOT(makeBackupActiveControl()));
      connect (project(), SIGNAL(activeControlSet(bool)),
               result->controlPointEditWidget(), SLOT(setControlFromActive()));
    }

    return controlPointEditView();
@@ -1080,6 +1090,26 @@ namespace Isis {
  }


  /**
   * @description Return true if control is not currently being viewed in a CnetEditorWidget 
   *  
   * @param Control * Control used to search current CnetEditorWidgets 
   *  
   * @return @b (bool) Returns true if control is currently being viewed in CnetEditorWidget 
   */
  bool Directory::controlUsedInCnetEditorWidget(Control *control) {

    bool result;
    if ( m_controlMap.count(control) == 0) {
      result = false;
    }
    else {
      result = true;
    }
    return result;
  }


  /**
   * @brief Removes pointers to deleted CubeDnView objects.
   */
Loading