Commit 1aaf3b4f authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

PROG: Added connections so that Control's write method is used to write...

PROG: Added connections so that Control's write method is used to write control net rather than using the control net's write method, which allows Control to maintain the modification state of it's control net. Added slot to reload the active control in the cneteditorview which effective discards any edits.
parent 9ddccab7
Loading
Loading
Loading
Loading
+53 −3
Original line number Diff line number Diff line
@@ -135,8 +135,11 @@ namespace Isis {
    connect( m_project, SIGNAL(projectLoaded(Project *) ),
              this, SLOT(updateRecentProjects(Project *) ) );

    connect(this, SIGNAL(cnetModified()), m_project, SLOT(activeControlModified()));

    connect(m_project, SIGNAL(activeControlSet(bool)), this, SLOT(newActiveControl(bool)));
    connect(m_project, SIGNAL(discardActiveControlEdits()),
            this, SLOT(reloadActiveControlInCnetEditorView()));

    m_projectItemModel = new ProjectItemModel(this);
    m_projectItemModel->addProject(m_project);
@@ -532,8 +535,38 @@ namespace Isis {
  }


  /**
   * @description This slot was created specifically for the CnetEditorWidgets when user chooses a 
   * new active control and wants to discard any edits in the old active control.  The only view 
   * which will not be updated with the new control are any CnetEditorViews showing the old active 
   * control.  CnetEditorWidget classes do not have the ability to reload a control net, so the 
   * CnetEditor view displaying the old control is removed, then recreated.
   *  
   */
  void Directory::reloadActiveControlInCnetEditorView() {
    qDebug()<<"Directory::reloadActiveControlInCnetEditorView";
    foreach(CnetEditorWidget *cnetEditorView, m_cnetEditorViewWidgets) {
      if (cnetEditorView->control() == project()->activeControl()->controlNet()) {
        emit viewClosed(cnetEditorView);
//      cnetEditorView->close();
//      delete cnetEditorView;
        project()->activeControl()->closeControlNet();
        project()->activeControl()->openControlNet();
        addCnetEditorView(project()->activeControl());
      }
    }
  }


  void Directory::newActiveControl(bool newControl) {

//  if (newControl && m_controlPointEditViewWidget) {
//    bool closed = m_controlPointEditViewWidget->close();
//    qDebug()<<"Directory::newActiveControl  CPEditor closed = "<<closed;
//    emit viewClosed(m_controlPointEditViewWidget);
//    delete m_controlPointEditViewWidget;
//  }

    // 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) {
@@ -607,7 +640,6 @@ namespace Isis {
  CnetEditorWidget *Directory::addCnetEditorView(Control *network) {

    QString title = tr("Cnet Editor View %1").arg( network->displayProperties()->displayName() );

    FileName configFile("$HOME/.Isis/" + QApplication::applicationName() + "/" + title + ".config");

    // TODO: This layout should be inside of the cnet editor widget, but I put it here to not
@@ -868,8 +900,14 @@ namespace Isis {

      //  Create connections between signals from control point edit view and equivalent directory
      //  signals that can then be connected to other views that display control nets.
      qDebug()<<"ControlPointEditView::addControlPointEditView  before cnetModified connection.";
//      connect(mainWidget, SIGNAL(cnetModified()),
//              this, SIGNAL(cnetModified()));
      connect(result->controlPointEditWidget(), SIGNAL(cnetModified()),
              this, SIGNAL(cnetModified()));
      connect(result->controlPointEditWidget(), SIGNAL(cnetModified()),
              m_project, SLOT(activeControlModified()));
      qDebug()<<"ControlPointEditView::addControlPointEditView  after cnetModified connection.";

      connect(result->controlPointEditWidget(), SIGNAL(saveControlNet()),
              this, SLOT(makeBackupActiveControl()));
@@ -1071,7 +1109,7 @@ namespace Isis {
   * @brief Removes pointers to deleted CnetEditorWidget objects.
   */
  void Directory::cleanupCnetEditorViewWidgets(QObject *obj) {

    qDebug()<<"Directory::cleanupCnetEditorViewWidgets";
    CnetEditorWidget *cnetEditorWidget = static_cast<CnetEditorWidget *>(obj);
    if (!cnetEditorWidget) {
      return;
@@ -1157,10 +1195,12 @@ namespace Isis {
   */
  void Directory::cleanupControlPointEditViewWidget(QObject *obj) {

    qDebug()<<"Directory::cleanupControlPointEditView";
     ControlPointEditView *controlPointEditView = static_cast<ControlPointEditView *>(obj);
     if (!controlPointEditView) {
       return;
     }
     m_controlPointEditViewWidget = NULL;
     m_project->setClean(false);

   }
@@ -1818,6 +1858,16 @@ namespace Isis {
  }


  /**
   * Save the current active control.
   *
   */
  void Directory::saveActiveControl() {

    project()->activeControl()->write();
  }


  /**
   * Autosave for control net.  The control net is auto saved to the same directory as the input
   * net.  It is saved to controlNetFilename.net.bak.
+15 −1
Original line number Diff line number Diff line
@@ -215,7 +215,17 @@ namespace Isis {
   *                           addCubeDnView. Added method controlUsedInCnetEditorWidget so Project
   *                           knows whether it is safe to close a control net when a new active is
   *                           set. References #5026.
   *  
   *   @history 2018-03-30 Tracie Sucharski - Use the Control::write to write the control net to
   *                           disk instead of directly calling ControlNet::Write, so that the
   *                           Control can keep track of the modified status of the control net.
   *                           Connect cnetModified signal to Project::activeControlModified so
   *                           modified state of the active control can be set so project knows
   *                           that control has unsaved changes.
   *   @history 2018-04-02 Tracie Sucharski - Cleanup m_controlPointEditViewWidget pointer when
   *                           the ControlPointEditView is deleted. Added slot to reload the active
   *                           control net in cneteditor view, effectively discarding any edits.
   *                           This was done because there is no way to re-load a control net in the
   *                           CnetEditor widget classes.
   */
  class Directory : public QObject {
    Q_OBJECT
@@ -336,6 +346,8 @@ namespace Isis {
      void newWarning();
      void newWidgetAvailable(QWidget *newWidget);

      void viewClosed(QWidget *widget);

      void cnetModified();
      void redrawMeasures();

@@ -355,6 +367,7 @@ namespace Isis {
      //void imagesAddedToProject(ImageList *images);
      void updateControlNetEditConnections();

      void saveActiveControl();
      // TODO temporary slot until autosave is implemented
      void makeBackupActiveControl();

@@ -372,6 +385,7 @@ namespace Isis {
    private slots:
      void initiateRenameProjectWorkOrder(QString projectName);
      void newActiveControl(bool newControl);
      void reloadActiveControlInCnetEditorView();

    private:
      /**