Unverified Commit 55322118 authored by ihumphrey's avatar ihumphrey Committed by GitHub
Browse files

Merge pull request #281 from twilson271828/ipceBundleWindow

Fixed an edge-case scenario with ProjectItemModel::selectedBossImages()
parents 0aa9c52c 820e1d62
Loading
Loading
Loading
Loading
+158 −1
Original line number Diff line number Diff line
@@ -10,10 +10,13 @@
#include <QStandardItemModel>
#include <QItemSelection>

#include "BundleObservationSolveSettings.h"
#include "BundleSolutionInfo.h"
#include "BundleSettings.h"
#include "BundleTargetBody.h"
#include "Control.h"
#include "Cube.h"
#include "Image.h"
#include "IString.h"
#include "MaximumLikelihoodWFunctions.h"
#include "Project.h"
@@ -783,6 +786,154 @@ namespace Isis {
  }

  

  /**
   * @brief updateBundleObservationSolveSettings:  This function sets the parameters of
   * a BundleObservationSolveSettings object by reading user settings from the BOSS
   * tab, as well as reading in the selected images on the BOSS QTreeView these
   * BOSS settings are to be applied to.
   * @param BundleObservationSolveSettings &boss The object which stores user-specified
   * settings from the BOSS tab.
   */
  void JigsawSetupDialog::updateBundleObservationSolveSettings(BundleObservationSolveSettings &boss)
    {

      int ckSolveDegree = m_ui->ckSolveDegreeSpinBox->value();
      int spkSolveDegree = m_ui->spkSolveDegreeSpinBox->value();
      int ckDegree = m_ui->ckDegreeSpinBox->value();
      int spkDegree = m_ui->spkDegreeSpinBox->value();
      int instrumentPointingSolveOption=m_ui->pointingComboBox->currentIndex();
      int instrumentPositionSolveOption=m_ui->positionComboBox->currentIndex();

      BundleObservationSolveSettings::InstrumentPointingSolveOption  pointSolvingOption;
      BundleObservationSolveSettings::InstrumentPositionSolveOption  positionSolvingOption;

      double anglesAprioriSigma(-1.0);
      double angularVelocityAprioriSigma(-1.0);
      double angularAccelerationAprioriSigma(-1.0);
      QList<double> additionalAngularCoefficients;

      double positionAprioriSigma(-1.0);
      double velocityAprioriSigma(-1.0);
      double accelerationAprioriSigma(-1.0);
      QList<double> additionalPositionCoefficients;

      bool solveTwist(false);
      bool solvePolynomialOverExisting(false);
      bool positionOverHermite(false);

      if (m_ui->pointingAprioriSigmaTable->item(0,3))
        anglesAprioriSigma = m_ui->pointingAprioriSigmaTable->item(0,3)->data(0).toDouble();

      if (m_ui->pointingAprioriSigmaTable->item(1,3))
        angularVelocityAprioriSigma = m_ui->pointingAprioriSigmaTable->item(1,3)->data(0).toDouble();

      if (m_ui->pointingAprioriSigmaTable->item(2,3) )
        angularAccelerationAprioriSigma = m_ui->pointingAprioriSigmaTable->item(2,3)->data(0).toDouble();

      if (m_ui->positionAprioriSigmaTable->item(0,3))
        positionAprioriSigma = m_ui->positionAprioriSigmaTable->item(0,3)->data(0).toDouble();

      if (m_ui->positionAprioriSigmaTable->item(1,3))
        velocityAprioriSigma = m_ui->positionAprioriSigmaTable->item(1,3)->data(0).toDouble();

      if (m_ui->positionAprioriSigmaTable->item(2,3) )
        accelerationAprioriSigma = m_ui->positionAprioriSigmaTable->item(2,3)->data(0).toDouble();


      //Saving additionalPositional/Angular coefficients (deg >=3) in case they are needed
      //later.
      if (spkSolveDegree >2) {
        for (int i = 3;i <= spkSolveDegree;i++ ) {
          if (m_ui->positionAprioriSigmaTable->item(i,3))
            additionalPositionCoefficients.append(m_ui->positionAprioriSigmaTable->item(i,3)->data(0).toDouble() );
        }
      }

      if (ckSolveDegree > 2) {
         for (int i = 3;i <= ckSolveDegree;i++ ) {
           if (m_ui->pointingAprioriSigmaTable->item(i,3))
             additionalAngularCoefficients.append(m_ui->pointingAprioriSigmaTable->item(i,3)->data(0).toDouble() );
         }

      }


      if (m_ui->twistCheckBox->checkState() == Qt::Checked)
        solveTwist = true;
      if (m_ui-> fitOverPointingCheckBox->checkState() == Qt::Checked)
        solvePolynomialOverExisting = true;

      switch(instrumentPointingSolveOption) {

      case 0: pointSolvingOption = BundleObservationSolveSettings::InstrumentPointingSolveOption::NoPointingFactors;
        break;
      case 1:pointSolvingOption = BundleObservationSolveSettings::InstrumentPointingSolveOption::AnglesOnly;
        break;
      case 2:pointSolvingOption = BundleObservationSolveSettings::InstrumentPointingSolveOption::AnglesVelocity;
        break;
      case 3:pointSolvingOption = BundleObservationSolveSettings::InstrumentPointingSolveOption::AnglesVelocityAcceleration;
        break;

      case 4:pointSolvingOption = BundleObservationSolveSettings::InstrumentPointingSolveOption::AllPointingCoefficients;
        break;
      default:  pointSolvingOption = BundleObservationSolveSettings::InstrumentPointingSolveOption::NoPointingFactors;
        break;

      }

      switch(instrumentPositionSolveOption) {

      case 0: positionSolvingOption = BundleObservationSolveSettings::InstrumentPositionSolveOption::NoPositionFactors;
        break;
      case 1:positionSolvingOption = BundleObservationSolveSettings::InstrumentPositionSolveOption::PositionOnly;
        break;
      case 2:positionSolvingOption = BundleObservationSolveSettings::InstrumentPositionSolveOption::PositionVelocity;
        break;
      case 3:positionSolvingOption = BundleObservationSolveSettings::InstrumentPositionSolveOption::PositionVelocityAcceleration;
        break;

      case 4:positionSolvingOption = BundleObservationSolveSettings::InstrumentPositionSolveOption::AllPositionCoefficients;
        break;
      default:  positionSolvingOption = BundleObservationSolveSettings::InstrumentPositionSolveOption::NoPositionFactors;
        break;

      }


      boss.setInstrumentPositionSettings(positionSolvingOption,spkDegree,spkSolveDegree,positionOverHermite,
                                         positionAprioriSigma,velocityAprioriSigma,accelerationAprioriSigma);

      boss.setInstrumentPointingSettings(pointSolvingOption,solveTwist,ckDegree,ckSolveDegree,solvePolynomialOverExisting,
                                         anglesAprioriSigma,angularVelocityAprioriSigma,angularAccelerationAprioriSigma);

      //What if multiple instrument IDs are represented?
      boss.setInstrumentId("");


      SortFilterProxyModel* proxyModel = (SortFilterProxyModel *)m_ui->treeView->model();
      ProjectItemModel* sourceModel = (ProjectItemModel *)proxyModel->sourceModel();
      QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedIndexes();

      foreach (QModelIndex index, selectedIndexes) {

        QModelIndex sourceix = proxyModel->mapToSource(index);
        ProjectItem * projItem = sourceModel->itemFromIndex(sourceix);

        if (projItem) {

          if (projItem->isImage() ) {
            Image * img = projItem->data().value<Image *>();
            boss.addObservationNumber(img->serialNumber() );
            //qDebug() << "serial num:  " << img->serialNumber();
          }
        }

      }

    }


  QString JigsawSetupDialog::outputControlName() {
    return QString(m_ui->outputControlNetLineEdit->text());
  }
@@ -1592,7 +1743,13 @@ namespace Isis {

// Commented out since it contains some unimplemented functions (i.e. pseudo-code)

  void JigsawSetupDialog::on_applySettingsPushButton_clicked() {}
  void JigsawSetupDialog::on_applySettingsPushButton_clicked() {

    BundleObservationSolveSettings boss;

    updateBundleObservationSolveSettings(boss);

  }
#if 0
    // Get the current selected images
    QAbstractProxyModel *model = m_ui->treeView->model();
+7 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ class QItemSelection;
class QTableWidgetItem;

namespace Isis {
  class BundleObservationSolveSettings;
  class Project;
  class ProjectItem;
  class Control;
@@ -72,6 +73,10 @@ namespace Isis {
   *                           createObservationSolveSettingsTreeView() function.  References #497.
   *   @history 2018-06-25 Ian Humphrey - Implemented the position and pointing a priori sigma
   *                           tables in the observation solve settings tab. References #497.
   *   @history 2018-06-26 Tyler Wilson - Added the function 
   *                           updateBundleObservationSolveSettings(BundleObservationSolveSettings &) 
   *                           which grabs BOSS settings from the JSD BOSS tab for selected images 
   *                           in the BOSS QTreeView and saves them in a BOSS object. 
   */

  class JigsawSetupDialog : public QDialog {
@@ -160,6 +165,7 @@ namespace Isis {
    void fillFromSettings(const BundleSettingsQsp settings);
    void showTargetParametersGroupBox();
    void hideTargetParametersGroupBox();
    void updateBundleObservationSolveSettings(BundleObservationSolveSettings &boss);

    void createObservationSolveSettingsTreeView();

+32 −4
Original line number Diff line number Diff line
@@ -190,9 +190,11 @@ namespace Isis {

    QItemSelection selection = selectionModel()->selection();
    QList<ProjectItem *> items;
    QModelIndexList indices = selection.indexes();


    //Query the selected items to see if they have children
    foreach ( QModelIndex ix, selection.indexes() ) {
    foreach ( QModelIndex ix, indices ) {

      ProjectItem *item = this->itemFromIndex(ix);

@@ -206,16 +208,42 @@ namespace Isis {
        return items;
      }

      //If the selected ImageList has children, include all of the children.
      //If the selected ImageList has children, we have to handle
      //the case where some of the children are selected, or
      //the possibility that the user wants all of the children selected.
      if (this->hasChildren(ix)) {

        //If the node has children, loop through all of them
        //and add them to selected items.
        bool childrenSelected(false);
        int numChildren = this->rowCount(ix);

        //First loop through the children to see if any of them are also selected
        for (int i = 0; i < numChildren;i++) {
          QModelIndex ixchild = this->index(i,0,ix);
          if (indices.contains(ixchild) ){
              childrenSelected=true;
              break;
          }
        }
          //If they are, then add them to selected items
          if (childrenSelected) {
            for (int i =0;i < numChildren;i++) {
              QModelIndex ixchild = this->index(i,0,ix);
              if (indices.contains(ixchild))
                items.append(this->itemFromIndex(ixchild ));
          }  //end for
            }
          }
          //No children selected, so we are assuming that the user
          //wanted to select all of the children under the parent.
          else {
            for (int i =0;i < numChildren;i++) {
               QModelIndex ixchild = this->index(i,0,ix);
               items.append(this->itemFromIndex(ixchild ));
            }

          }

      }//end if

      //Append the parent of any selected child.  This is so
+5 −1
Original line number Diff line number Diff line
@@ -134,7 +134,11 @@ namespace Isis {
   *                           refinement of selectedItems and is used by the JigsawSetupDialog
   *                           Bundle Observation Solve Settings (BOSS) tab when displaying a
   *                           subset of user-selected images.  References #497
   *
   *   @history 2018-06-24 Tyler Wilson - Fixed an edge-case scenario in the selection criteria for
   *                           selectedBOSSImages().   If a user selected an image list and some
   *                           (but not all) of the images within that list, the function returned
   *                           all of the images in the list and not just the selected ones.
   *                           References #497.
   */
  class ProjectItemModel : public QStandardItemModel {