Commit dfe8e3e3 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

For IPCE, remove load net button from Footprint2DView, use the active control...

For IPCE, remove load net button from Footprint2DView, use the active control instead.  For Footprint2DView, add Track tool; allow user to either select a current view or create new when when choosing to show footprints;  move all work to the execute method in Footprint2DViewWorkOrder, this WorkOrder will not be undone.  Change WorkOrder to allow setting whether a specific WorkOrder is put on undo stack, save active ImageList and Control to project.  Restore toolbars for restored views when opening a project.  Fixes #2146, #4475, #4546, #4598.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce_FY17-Sprint1@7484 41f8697f-d340-4b68-9986-7bafba869bb8
parent fa91c755
Loading
Loading
Loading
Loading
+34 −5
Original line number Diff line number Diff line
@@ -22,10 +22,17 @@
 */
#include "CNetSuiteMainWindow.h"

#include <QtDebug>
#include <QApplication>
#include <QColor>
#include <QDockWidget>
#include <QMdiArea>
#include <QObject>
#include <QtWidgets>
#include <QSettings>
#include <QStatusBar>
#include <QTreeView>
#include <QVariant>

#include "AbstractProjectItemView.h"
#include "Directory.h"
@@ -174,18 +181,20 @@ namespace Isis {
    centralWidget->setTabsMovable(true);
    centralWidget->setTabsClosable(true);

    // ken testing
    setActiveView(projectTreeView);
    // ken testing

    if (args.count() == 2) {
      m_directory->project()->open(args.last());
    }

    // ken testing  If this is used, we will not need to call updateMenuActions() or updateToolBar()
    // above.  They are both called from setActiveView.
    //  setActiveView(projectTreeView);
    // ken testing
  }


  /**
   * 
   * This is connected from Directory's newWidgetAvailable signal and called when re-attaching a 
   * view which was detached from the MDI main window. 
   *
   * @param[in] newWidget (QWidget *)
   */
@@ -201,6 +210,8 @@ namespace Isis {
      if ( QMdiArea *mdiArea = qobject_cast<QMdiArea *>( centralWidget() ) ) {
        mdiArea->addSubWindow(newWidget);
        newWidget->show();
        mdiArea->setActiveSubWindow(qobject_cast<QMdiSubWindow *>(newWidget));
        setActiveView(qobject_cast<AbstractProjectItemView *>(newWidget));
      }
    }
  }
@@ -234,59 +245,71 @@ namespace Isis {
  void CNetSuiteMainWindow::updateMenuActions() {

    m_fileMenu->clear();
    // Get Directory FileMenu actions
    foreach ( QAction *action, m_directory->fileMenuActions() ) {
      m_fileMenu->addAction(action);
    }
    m_fileMenu->addSeparator();
    // Get FileMenu actions for the active view (eg. CubeDnView, Footprint2DView)
    if (m_activeView) {
      foreach ( QAction *action, m_activeView->fileMenuActions() ) {
        m_fileMenu->addAction(action);
      }
    }
    m_fileMenu->addSeparator();
    // Get FileMenu actions from the CNetsuiteMainWindow, Exit is the only action
    foreach ( QAction *action, m_fileMenuActions ) {
      m_fileMenu->addAction(action);
    }

    m_projectMenu->clear();
    //  Get Project menu actions from Directory
    foreach ( QAction *action, m_directory->projectMenuActions() ) {
      m_projectMenu->addAction(action);
    }
    m_projectMenu->addSeparator();
    //  Get Project menu actions from the active view
    if (m_activeView) {
      foreach ( QAction *action, m_activeView->projectMenuActions() ) {
        m_projectMenu->addAction(action);
      }
    }
    m_projectMenu->addSeparator();
    //  Get Project menu actions from CNetSuiteMainWindow
    foreach ( QAction *action, m_projectMenuActions ) {
      m_projectMenu->addAction(action);
    }

    m_editMenu->clear();
    // Get Edit menu actions from Directory
    foreach ( QAction *action, m_directory->editMenuActions() ) {
      m_editMenu->addAction(action);
    }
    m_editMenu->addSeparator();
    // Get Edit menu actions from active view
    if (m_activeView) {
      foreach ( QAction *action, m_activeView->editMenuActions() ) {
        m_editMenu->addAction(action);
      }
    }
    m_editMenu->addSeparator();
    // Get Edit menu actions from CNetSuiteMainWindow
    foreach ( QAction *action, m_editMenuActions ) {
      m_editMenu->addAction(action);
    }

    m_viewMenu->clear();
    // Get View menu actions from Directory
    foreach ( QAction *action, m_directory->viewMenuActions() ) {
      m_viewMenu->addAction(action);
    }
    m_viewMenu->addSeparator();
    // Get View menu actions from CNetSuiteMainWindow
    foreach ( QAction *action, m_viewMenuActions ) {
      m_viewMenu->addAction(action);
    }
    m_viewMenu->addSeparator();
    // Get View menu actions from active view
    if (m_activeView) {
      foreach ( QAction *action, m_activeView->viewMenuActions() ) {
        m_viewMenu->addAction(action);
@@ -294,31 +317,37 @@ namespace Isis {
    }

    m_settingsMenu->clear();
    // Get Settings menu actions from Directory
    foreach ( QAction *action, m_directory->settingsMenuActions() ) {
      m_settingsMenu->addAction(action);
    }
    m_settingsMenu->addSeparator();
    // Get Settings menu actions from active view
    if (m_activeView) {
      foreach ( QAction *action, m_activeView->settingsMenuActions() ) {
        m_settingsMenu->addAction(action);
      }
    }
    m_settingsMenu->addSeparator();
    // Get Settings menu actions from CNetSuiteMainWindow
    foreach ( QAction *action, m_settingsMenuActions ) {
      m_settingsMenu->addAction(action);
    }

    m_helpMenu->clear();
    // Get Help menu actions from Directory
    foreach ( QAction *action, m_directory->helpMenuActions() ) {
      m_helpMenu->addAction(action);
    }
    m_helpMenu->addSeparator();
    // Get Help menu actions from active view
    if (m_activeView) {
      foreach ( QAction *action, m_activeView->helpMenuActions() ) {
        m_helpMenu->addAction(action);
      }
    }
    m_helpMenu->addSeparator();
    // Get Help menu actions from CNetSuiteMainWindow
    foreach ( QAction *action, m_helpMenuActions ) {
      m_helpMenu->addAction(action);
    }
+3 −0
Original line number Diff line number Diff line
@@ -79,6 +79,9 @@ namespace Isis {
   *                           The m_permToolBar, m_activeToolBar, and m_toolPad now have object
   *                           names set, so the saveState() call within writeSettings() now works.
   *                           Fixes #4358.
   *   @history 2016-12-09 Tracie Sucharski - One of the previous 2 changes caused a problem with
   *                           view toolbars not to be restored.  Added setActiveSubWindow and
   *                           show to the ::addView method.  Fixes #4546.
   */
  class CNetSuiteMainWindow : public QMainWindow {
      Q_OBJECT
+45 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include <QtWidgets>
#include <QMessageBox>
#include <QMouseEvent>

#include "Application.h"
#include "Camera.h"
@@ -57,6 +58,8 @@ namespace Isis {

    createChipViewports(parent);

    installEventFilter(this);

//  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
//          m_measureEditor, SIGNAL(newControlNetwork(ControlNet *)));
  }
@@ -190,7 +193,7 @@ namespace Isis {

//  m_cubeMeasureEditMap.clear();
//    qDebug()<<"ChipViewportsWidget::setEditPoint  pt = "<<controlPoint->GetId();
    qDebug()<<"  Control Net = "<<m_controlNet;
//  qDebug()<<"  Control Net = "<<m_controlNet;
    //  Find reference measure first,  the measure editor needs the reference measure to load the
    //  chip viewport properly (needs to geom to Reference measure).
    if (m_controlPoint->IsReferenceExplicit()) {
@@ -330,5 +333,46 @@ namespace Isis {
    }
//  m_controlPoint = NULL;
  }


  bool ChipViewportsWidget::eventFilter(QObject *object, QEvent *event) {

    bool blockEvent = false;

    switch (event->type()) {
      case QEvent::MouseButtonPress: {
        mousePressEvent(object, (QMouseEvent *)event);
        blockEvent = true;
        break;
      }

      default:
        break;
    }
    return blockEvent;
  }


  void ChipViewportsWidget::mousePressEvent(QObject *object, QMouseEvent *event) {

    if (event->button() == Qt::RightButton) {
      qDebug()<<"ChipViewportsWidget::mousePressEvent  right mouse";
      //  Find child widget (ChipViewport) under the mouse
      ChipViewport *chipViewport = qobject_cast<ChipViewport *>(focusWidget());

      QMenu contextMenu;

      QAction *setReferenceMeasureAction = new QAction(tr("Set as Reference Measure"), this);
      contextMenu.addAction(setReferenceMeasureAction);

      QAction *chosenAction =
          contextMenu.exec(qobject_cast<QWidget *>(object)->mapToGlobal(event->pos()));

      if (chosenAction == setReferenceMeasureAction) {
        qDebug()<<"ChipViewportsWidget::mousePressEvent setRefMeasureAction chipViewport = "<<chipViewport;
        //setNewReferenceMeasure(chipViewport);
      }
    }
  }
}
+4 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
class QAction;
class QGridLayout;
class QLabel;
class QMouseEvent;

namespace Isis {
  class ChipViewport;
@@ -38,6 +39,7 @@ namespace Isis {
      ChipViewportsWidget(QWidget *parent);
      virtual ~ChipViewportsWidget();

      bool eventFilter(QObject *object, QEvent *event);

    signals:
      void controlPointChanged(QString pointId);
@@ -73,6 +75,8 @@ namespace Isis {

      void loadPoint();

      void mousePressEvent(QObject *object, QMouseEvent *event);

    private:

      QPointer<QWidget> m_parent;
+143 −66
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <QCheckBox>
#include <QComboBox>
#include <QFileDialog>
#include <QFileInfo>
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
@@ -42,6 +43,7 @@
#include "MainWindow.h"
#include "MdiCubeViewport.h"
#include "NewControlPointDialog.h"
#include "NewGroundSourceLocationDialog.h"
#include "Project.h"
#include "Pvl.h"
#include "PvlEditDialog.h"
@@ -74,6 +76,9 @@ namespace Isis {
    m_templateModified = false;
    m_serialNumberList = NULL;

    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;
@@ -552,17 +557,21 @@ namespace Isis {
   */
  ControlMeasure *ControlPointEditWidget::createTemporaryGroundMeasure() {

    //  If a ground serial number has already been added to the serial number list, clear out
    //  the old before adding the new.
    if (!m_groundSN.isEmpty()) {
      if (m_serialNumberList->hasSerialNumber(m_groundSN)) {
        m_serialNumberList->Delete(m_groundSN);
        m_groundSN.clear();
      }
    }

    ControlMeasure *groundMeasure = NULL;
    FileName groundFile(m_editPoint->GetAprioriSurfacePointSourceFile());

    FileName groundFile = findGroundFile();
    if (!groundFile.fileExists()) {
      //  simply print error for now, need to prompt
      //  for new location or new source, either a Shape in the project, or import a new shape,
      //  or simplay choose file?
      QString message = "Ground Source file " + groundFile.expanded();
      message += " doesn't exist";
      QMessageBox::critical(this, "Warning", message);
      return groundMeasure;
    }
    else {

    //  If ground file exists, open, create cube and ground map.  If doesn't exist, prompt
    //  for new location or new source, either a Shape in the project, or import a new shape,
@@ -600,22 +609,92 @@ namespace Isis {
      QMessageBox::warning(this, "Warning", message);
    }
    else {
        // This measure will be deleted when the ControlPoint is saved to the
        // ControlNet.
      //  Create new serial number for ground source and add to serial number list
      m_groundSN = SerialNumber::Compose(groundFile.expanded(), true);
      m_serialNumberList->add(groundFile.expanded(), true);

      groundMeasure = new ControlMeasure;
        QString groundSN = SerialNumber::Compose(*groundCube);
        groundMeasure->SetCubeSerialNumber(groundSN);
      groundMeasure->SetCubeSerialNumber(m_groundSN);
      groundMeasure->SetType(ControlMeasure::Candidate);
      groundMeasure->SetCoordinate(groundMap->Sample(), groundMap->Line());
      groundMeasure->SetChooserName("GroundMeasureTemporary");
        //  Add serial number to serial number list if  not already there
        if (!m_serialNumberList->hasSerialNumber(groundSN)) {
          m_serialNumberList->add(groundFile.expanded(), true);
    }

    return groundMeasure;

  }


  FileName ControlPointEditWidget::findGroundFile() {

    FileName groundFile(m_editPoint->GetAprioriSurfacePointSourceFile());

    if (m_changeAllGroundLocation) {
      QFileInfo oldFile(groundFile.expanded());
      QFileInfo newFile(m_newGroundDir, oldFile.fileName());

      groundFile = newFile.absoluteFilePath();
    }

    return groundMeasure;
    if (!groundFile.fileExists()) {

      //  simply print error for now, need to prompt
      //  for new location or new source, either a Shape in the project, or import a new shape,
      //  or simplay choose file?
      QString message = "Ground Source file " + groundFile.expanded();
      message += " doesn't exist.  Has the file moved?  Would you like to enter a new location for"
                 " this ground source?";
      int ret = QMessageBox::question(this, "Ground Source not found", message);
      if (ret == QMessageBox::Yes) {
        QString dir = m_directory->project()->shapeDataRoot();
        NewGroundSourceLocationDialog *dialog = new NewGroundSourceLocationDialog(
            "New Ground Source Location", dir);
        if (dialog->exec() == QDialog::Accepted) {
          m_newGroundDir = dialog->selectedFiles().value(0);
          m_changeAllGroundLocation = dialog->changeAllGroundSourceLocation();
          m_changeGroundLocationInNet = dialog->changeControlNet();
          //  Change all ground source locations to reflect new directory
          if (m_changeGroundLocationInNet) {
            changeGroundLocationsInNet();
            //groundFile = NULL;
          }
          //  Don't change control net, but look for ground source in new directory
          else  {
            QFileInfo oldFile(groundFile.expanded());
            QFileInfo newFile(m_newGroundDir, oldFile.fileName());
            
            groundFile = newFile.absoluteFilePath();
          }
        }
        else {
          //  Either user does not want to change location of ground source or the new location
          //  Dialog was cancelled. Load point without the ground source.
          groundFile = NULL;
        }
      }
      else {
        //  Either user does not want to change location of ground source or the new location
        //  Dialog was cancelled. Load point without the ground source.
        groundFile = NULL;
      }
    }
    return groundFile;
  }


  void ControlPointEditWidget::changeGroundLocationsInNet() {

    for (int i = 0; i < m_controlNet->GetNumPoints(); i++ ) {
      FileName groundFile(m_editPoint->GetAprioriSurfacePointSourceFile());

      QFileInfo oldFile(groundFile.expanded());
      QFileInfo newFile(m_newGroundDir, oldFile.fileName());

      groundFile = newFile.absoluteFilePath();
      m_controlNet->GetPoint(i)->SetAprioriSurfacePointSourceFile(groundFile.expanded());
    }
    //  TODO:  Temporary until autosave is implemented Save control net to Backup file
    emit saveControlNet();
  }


@@ -661,7 +740,7 @@ namespace Isis {
   *                          ground measure-use AprioriSurface point, not lat,lon
   *                          of reference measure unless there is no apriori
   *                          surface point.
   *   @history 2012-05-08 Tracie Sucharski - m_leftFile changed from QString to QString.
   *   @history 2012-05-08 Tracie Sucharski - m_leftFile changed from IString to QString.
   *   @history 2012-10-02 Tracie Sucharski - When creating a new point, load the cube the user
   *                          clicked on first on the left side, use m_leftFile.
   */
@@ -674,10 +753,6 @@ namespace Isis {
    m_ptIdValue->setText(ptId);

    m_pointType->setCurrentIndex((int) m_editPoint->GetType());
    QString groundFile;
    if (m_editPoint->GetType() != ControlPoint::Free) {
      groundFile = m_editPoint->GetAprioriSurfacePointSourceFile();
    }

    //  Write number of measures
    QString ptsize = "Number of Measures:  " +
@@ -704,15 +779,14 @@ namespace Isis {
      // Create a temporary measure to hold the ground point info for ground source
      // This measure will be deleted when the ControlPoint is saved to the
      // ControlNet.
      // TODO:  Does open ground source match point ground source
      ControlMeasure *groundMeasure = createTemporaryGroundMeasure();
      if (groundMeasure) {
        m_editPoint->Add(groundMeasure);
      }
      else {
        QString message = "Cannot create ground measure on ground source file ";
        message += groundFile;
        QMessageBox::warning(this, "Warning", message);
//      QString message = "Cannot create ground measure on ground source file ";
//      message += m_groundSN;
//      QMessageBox::warning(this, "Warning", message);
      }
    }

@@ -720,15 +794,18 @@ namespace Isis {
    for (int i=0; i<m_editPoint->GetNumMeasures(); i++) {
      ControlMeasure &m = *(*m_editPoint)[i];
      QString file;
      if (m.GetChooserName() == "GroundMeasureTemporary") {
        file = groundFile;
      }
      else {
//    if (m.GetChooserName() == "GroundMeasureTemporary") {
//      qDebug()<<"::loadPoint before setting file to groundFile = "<<groundFile;
//      file = groundFile;
//    }
//    else {
        file = m_serialNumberList->fileName(m.GetCubeSerialNumber());
      }
//    }
      m_pointFiles<<file;
      QString tempFileName = FileName(file).name();

      // This actually fills the right combo box for selecting measures.  A model was used to enable
      // drag & drop for ordering measures which will also set the blink order.
      QStandardItem *item = new QStandardItem(tempFileName);
//    qDebug()<<"before item flags = "<<item->flags();
      item->setFlags(item->flags() & ~Qt::ItemIsDropEnabled);
Loading