Commit 555c678b authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Changed JigsawDialog::acceptBundleResults to write updated cnet. Moved...

Changed JigsawDialog::acceptBundleResults to write updated cnet. Moved commented out code from bundleFinished to acceptBundleResults; some of this will be needed to update cube labels.  Temporarily commented out functionality of disabling the Bundle from the Project menu. This was not working if opening an existing project. Fixes #4783.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce_FY17-Sprint1@7585 41f8697f-d340-4b68-9986-7bafba869bb8
parent 679e6fe6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -358,12 +358,14 @@ namespace Isis {
    // NOTE: Trying to set a what's this on the clone doesn't seem to work for disabled actions,
    // even though Qt's documentation says it should work on disabled actions.
    clone = m_runJigsawWorkOrder->clone();
    if (project()->controls().count() && project()->images().count()) {
      clone->setEnabled(false);
    }

    // Listen for when both an active control and active image list have been set.
    // When this happens, we can enable the JigsawWorkOrder.
    connect(m_project, &Project::activeControlAndImageListSet,
            clone, &WorkOrder::enableWorkOrder);
//  connect(m_project, &Project::activeControlAndImageListSet,
//          clone, &WorkOrder::enableWorkOrder);

    m_projectMenuActions.append(clone);

+114 −94
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "BundleAdjust.h"
#include "BundleSolutionInfo.h"
#include "Directory.h"
#include "FileName.h"
#include "IException.h"
#include "JigsawSetupDialog.h"
#include "Control.h"
@@ -220,6 +221,10 @@ namespace Isis {
//                                            *m_selectedControl,
//                                            m_project->images(),
//                                            false);

//    qDebug()<<"JigsawDialog::on_jigsawRun  #imagelists = "<<m_project->images().count();
//    qDebug()<<"JigsawDialog::on_jigsawRun  images = "<<m_project->images();

      m_bundleAdjust = new BundleAdjust(m_bundleSettings, *m_selectedControl, m_project->images(),
                                        false);

@@ -281,12 +286,7 @@ namespace Isis {
      }
    }

    // ********************************************** ****************************
//#if 0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    m_ui->useLastSettings->setEnabled(true);
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//#endif
  }


@@ -296,8 +296,75 @@ namespace Isis {
   */
  void JigsawDialog::acceptBundleResults() {
    qDebug() << "\n*** Accepting the results...\n";

    m_accept->setEnabled(false);
    m_reject->setEnabled(false);

    m_bundleSolutionInfo->setRunTime( Isis::iTime::CurrentLocalTime().toLatin1().data() );
    m_project->addBundleSolutionInfo( new BundleSolutionInfo(*m_bundleSolutionInfo) );

    // create output control net
    // Write the new jigged control net with correct path to results folder + runtime
    FileName jiggedControlName(m_project->bundleSolutionInfoRoot() + "/" +
                               m_bundleSolutionInfo->runTime() + "/" +
                               FileName(m_bundleSolutionInfo->controlNetworkFileName()).name());
    m_bundleSolutionInfo->bundleResults().outputControlNet()->Write(jiggedControlName.toString());


      //TODO: move correlation matrix to correct position in project directory

  //
  //       for (int i = 0; i < bundleAdjustment.images(); i++) {
  //         Process p;
  //         CubeAttributeInput inAtt;
  //  4-18-2017 TLS  bundleAdjustment.fileName is an .ecub.  code encompassed by my comment
  //                 is test code.

//      Cube *c = 
//    Cube *c = p.SetInputCube(bundleAdjustment.fileName(i), inAtt, ReadWrite);







  //  4-18-2017 TLS  bundleAdjustment.fileName is an .ecub.  code encompassed by my comment
  //                 is test code.
  //         Cube *c = p.SetInputCube(bundleAdjustment.fileName(i), inAtt, ReadWrite);
  //         //check for existing polygon, if exists delete it
  //         if (c->label()->hasObject("Polygon")) {
  //           c->label()->deleteObject("Polygon");
  //         }
  //
  //         // check for CameraStatistics Table, if exists, delete
  //         for (int iobj = 0; iobj < c->label()->objects(); iobj++) {
  //           PvlObject obj = c->label()->object(iobj);
  //           if (obj.name() != "Table") continue;
  //           if (obj["Name"][0] != QString("CameraStatistics")) continue;
  //           c->label()->deleteObject(iobj);
  //           break;
  //         }
  //
  //         //  Get Kernel group and add or replace LastModifiedInstrumentPointing
  //         //  keyword.
  //         Table cmatrix = bundleAdjustment.cMatrix(i);
  //         QString jigComment = "Jigged = " + Isis::iTime::CurrentLocalTime();
  //         cmatrix.Label().addComment(jigComment);
  //         Table spvector = bundleAdjustment.spVector(i);
  //         spvector.Label().addComment(jigComment);
  //         c->write(cmatrix);
  //         c->write(spvector);
  //         p.WriteHistory(*c);
  //       }
  //       m_ui->convergenceStatusLabel->setText("Bundle converged, camera pointing updated");
    //This bundle was bad so we should delete all remenants.

    //TODO: delete correlation matrix cov file...
    //TODO: delete bundle results object

//       m_ui->convergenceStatusLabel->setText("Bundle did not converge, camera pointing NOT updated");

  }


@@ -309,6 +376,8 @@ namespace Isis {
    qDebug() << "\n*** Rejecting the results...\n";
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);

    m_bundleSolutionInfo = NULL;
  }


@@ -412,57 +481,8 @@ namespace Isis {
    m_accept->setEnabled(true);
    m_reject->setEnabled(true);
    // m_close->setEnabled(false);
    if ( bundleSolutionInfo->bundleResults().converged() ) {
      bundleSolutionInfo->setRunTime( Isis::iTime::CurrentLocalTime().toLatin1().data() );
      m_project->addBundleSolutionInfo( new BundleSolutionInfo(*bundleSolutionInfo) );

      //TODO: move correlation matrix to correct position in project directory

      // create output control net
  //     bundleAdjustment.controlNet()->Write("ONET.net");
  //
  //       for (int i = 0; i < bundleAdjustment.images(); i++) {
  //         Process p;
  //         CubeAttributeInput inAtt;
  //         Cube *c = p.SetInputCube(bundleAdjustment.fileName(i), inAtt, ReadWrite);
  //         //check for existing polygon, if exists delete it
  //         if (c->label()->hasObject("Polygon")) {
  //           c->label()->deleteObject("Polygon");
  //         }
  //
  //         // check for CameraStatistics Table, if exists, delete
  //         for (int iobj = 0; iobj < c->label()->objects(); iobj++) {
  //           PvlObject obj = c->label()->object(iobj);
  //           if (obj.name() != "Table") continue;
  //           if (obj["Name"][0] != QString("CameraStatistics")) continue;
  //           c->label()->deleteObject(iobj);
  //           break;
  //         }
  //
  //         //  Get Kernel group and add or replace LastModifiedInstrumentPointing
  //         //  keyword.
  //         Table cmatrix = bundleAdjustment.cMatrix(i);
  //         QString jigComment = "Jigged = " + Isis::iTime::CurrentLocalTime();
  //         cmatrix.Label().addComment(jigComment);
  //         Table spvector = bundleAdjustment.spVector(i);
  //         spvector.Label().addComment(jigComment);
  //         c->write(cmatrix);
  //         c->write(spvector);
  //         p.WriteHistory(*c);
  //       }
  //       m_ui->convergenceStatusLabel->setText("Bundle converged, camera pointing updated");
  }
  else {
    //This bundle was bad so we should delete all remenants.

    //TODO: delete correlation matrix cov file...
    //TODO: delete bundle results object

//       m_ui->convergenceStatusLabel->setText("Bundle did not converge, camera pointing NOT updated");
  }

  // TODO: Give user the option to keep or throw away the bundle. Even if the bundle converged it
  //       could still be worthless.
    m_bundleSolutionInfo = bundleSolutionInfo;
  }
}

+5 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <QPointer>
#include <QWidget>

#include "BundleAdjustWorkOrder.h"
#include "BundleSettings.h"
#include "IException.h"

@@ -47,6 +48,8 @@ namespace Isis {
   *                           to the project (or when to discard the results). Added placeholder
   *                           private slots for accepting and rejecting the results. Removed
   *                           default OK and Cancel buttons from UI file. Fixes #4781.
   *   @history 2017-04-18 Tracie Sucharski - Write the updated control net to the runtime
   *                           folder under results folder.  Fixes #4783.
   */
  class JigsawDialog : public QDialog {
    Q_OBJECT
@@ -90,6 +93,8 @@ namespace Isis {

  private:
    Ui::JigsawDialog *m_ui; /**< Reference to self's UI generated with QtDesigner. */

    BundleSolutionInfo *m_bundleSolutionInfo;
  };
};
#endif
+4 −4
Original line number Diff line number Diff line
@@ -213,10 +213,10 @@ namespace Isis {

    // Listen for when an active control is set and when an active image list is set.
    // This is used for enabling the JigsawWorkOrder (the Bundle Adjustment menu action).
    connect(this, &Project::activeControlSet,
            this, &Project::checkActiveControlAndImageList);
    connect(this, &Project::activeImageListSet,
            this, &Project::checkActiveControlAndImageList);
//  connect(this, &Project::activeControlSet,
//          this, &Project::checkActiveControlAndImageList);
//  connect(this, &Project::activeImageListSet,
//          this, &Project::checkActiveControlAndImageList);
    // TODO: ken testing
//    m_bundleSettings = NULL;
//    m_bundleSettings = new BundleSettings();