Unverified Commit 10e0860c authored by Summer Stapleton's avatar Summer Stapleton Committed by GitHub
Browse files

Merge pull request #349 from USGS-Astrogeology/ipceDocks

Ipce docks
parents ea37f472 904be249
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -68,6 +68,10 @@ namespace Isis {
   * @param cube The Pvl label from the cube is used to create the Camera object.
   */
  Camera::Camera(Cube &cube) : Sensor(cube) {
    
    m_instrumentId = cube.label()->findGroup("Instrument", 
                        PvlObject::FindOptions::Traverse).findKeyword("InstrumentId")[0];
    
    m_instrumentNameLong = "Unknown";
    m_instrumentNameShort = "Unknown";
    m_spacecraftNameLong = "Unknown";
@@ -2876,6 +2880,16 @@ namespace Isis {
  }
  
  
  /**
   * This method returns the InstrumentId as it appears in the cube.
   *
   * @return QString Returns m_instrumentId
   */
  QString Camera::instrumentId() {
    return m_instrumentId;
  }


  /**
   * This method returns the full instrument name.
   *
+7 −0
Original line number Diff line number Diff line
@@ -241,6 +241,9 @@ namespace Isis {
   *   @history 2017-08-30 Summer Stapleton - Updated documentation. References #4807.
   *   @history 2017-01-11 Christopher Combs - Added bool deleteExisting to SetDistortionMap to 
   *                           prevent a segfault when the distortion map is incomplete. Fixes $5163.
   *   @hitsory 2018-07-12 Summer Stapleton - Added m_instrumentId and instrumentId() in order to 
   *                           collect the InstrumentId from the original cube label for 
   *                           comparisons related to image imports in ipce. References #5460.
   */

  class Camera : public Sensor {
@@ -329,6 +332,8 @@ namespace Isis {
      CameraGroundMap *GroundMap();
      CameraSkyMap *SkyMap();
      
      QString instrumentId();

      QString instrumentNameLong() const;
      QString instrumentNameShort() const;
      QString spacecraftNameLong() const;
@@ -497,6 +502,8 @@ namespace Isis {
      friend class RadarGroundMap;      //!< A friend class to calculate focal length
      friend class RadarSlantRangeMap;  //!< A friend class to calculate focal length
      
      QString m_instrumentId;        //!< The InstrumentId as it appears on the cube.

      QString m_instrumentNameLong;  //!< Full instrument name
      QString m_instrumentNameShort; //!< Shortened instrument name
      QString m_spacecraftNameLong;  //!< Full spacecraft name
+84 −12
Original line number Diff line number Diff line
@@ -25,11 +25,13 @@
#include <QApplication>
#include <QColor>
#include <QDebug>
#include <QDesktopWidget>
#include <QDockWidget>
#include <QMap>
#include <QMapIterator>
#include <QMdiArea>
#include <QObject>
#include <QRect>
#include <QRegExp>
#include <QStringList>
#include <QtWidgets>
@@ -81,18 +83,27 @@ namespace Isis {

    QWidget *centralWidget = new QWidget;
    setCentralWidget(centralWidget);
    setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);

    setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::South);

    // This was causing some buggy behavior, but this is what we would ultimately like.
    // Allows a user to undock a group of tabs.
    //setDockOptions(GroupedDragging | AllowTabbedDocks);
    //centralWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    //centralWidget->hide();
    setDockNestingEnabled(true);

    //  Set the splitter frames to a reasonable color/size for resizing the docks.
    setStyleSheet("QMainWindow::separator {background: black; width: 3; height: 3px;}");

    try {
      m_directory = new Directory(this);
      connect(m_directory, SIGNAL( newWidgetAvailable(QWidget *) ),
              this, SLOT( addView(QWidget *) ) );
      connect(m_directory, SIGNAL(viewClosed(QWidget *)),

      connect(m_directory, SIGNAL(closeView(QWidget *)),
              this, SLOT(removeView(QWidget *)));

      connect(m_directory, SIGNAL( directoryCleaned() ),
              this, SLOT( removeAllViews() ) );
      connect(m_directory->project(), SIGNAL(projectLoaded(Project *)),
@@ -117,9 +128,9 @@ namespace Isis {
    projectTreeView->setInternalModel( m_directory->model() );
    projectTreeView->treeView()->expandAll();
    projectTreeView->installEventFilter(this);
    m_projectDock->setWidget(projectTreeView);
    m_projectDock->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    //projectTreeView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    m_projectDock->setWidget(projectTreeView);
    addDockWidget(Qt::LeftDockWidgetArea, m_projectDock, Qt::Horizontal);

    m_warningsDock = new QDockWidget("Warnings", this, Qt::SubWindow);
@@ -193,7 +204,7 @@ namespace Isis {

    QDockWidget *dock = new QDockWidget(newWidget->windowTitle(), this);
    dock->setWidget(newWidget);
    dock->setObjectName(newWidget->windowTitle());
    dock->setObjectName(newWidget->objectName());
    dock->setAttribute(Qt::WA_DeleteOnClose);
    dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |
                      QDockWidget::DockWidgetFloatable);
@@ -204,7 +215,18 @@ namespace Isis {
      splitDockWidget(m_projectDock, dock, Qt::Vertical);
    }
    else {
      addDockWidget(area, dock, orientation);
      if (m_viewDocks.count() == 0) {
        splitDockWidget(m_projectDock, dock, Qt::Horizontal);
      }
      else {
        tabifyDockWidget(m_viewDocks.last(), dock);
        dock->show();
        dock->raise();
        //  Keeps expanding IpceMainWindow to fit new dock
        //  Below causes problems if the last dock has been tabbed, then a new view is created. All
        // views except for first disappear.
        //splitDockWidget(m_viewDocks.last(), dock, Qt::Horizontal);
      }
    }

    // When dock widget is destroyed, make sure the view it holds is also destroyed
@@ -218,6 +240,7 @@ namespace Isis {


  void IpceMainWindow::cleanupViewDockList(QObject *obj) {

    QDockWidget *dock = static_cast<QDockWidget *>(obj);
    if (dock) {
      m_viewDocks.removeAll(dock);
@@ -226,14 +249,16 @@ namespace Isis {


  /**
   * This slot is connected from Directory::viewClosed(QWidget *) signal.  It will
   * close the given view and delete the view. This was written to handle
   * This slot is connected from Directory::closeView(QWidget *) signal.  It will close the given 
   * view and delete the view. 
   *
   * @param view QWidget* The view to close.
   */
  void IpceMainWindow::removeView(QWidget *view) {
    view->close();
    delete view;

    QDockWidget *parentDock = qobject_cast<QDockWidget *>(view->parent());
    removeDockWidget(parentDock);
    delete parentDock;
  }


@@ -360,6 +385,10 @@ namespace Isis {
    connect( tabViewsAction, SIGNAL(triggered()), this, SLOT(tabViews()) );
    m_viewMenuActions.append(tabViewsAction);

    QAction *tileViewsAction = new QAction("Tile Views", this);
    connect( tileViewsAction, SIGNAL(triggered()), this, SLOT(tileViews()) );
    m_viewMenuActions.append(tileViewsAction);

    QAction *undoAction = m_directory->undoAction();
    undoAction->setShortcut(Qt::Key_Z | Qt::CTRL);

@@ -497,7 +526,12 @@ namespace Isis {
    QSettings globalSettings(FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(),
        QSettings::NativeFormat);

    if (project->isTemporaryProject()) {
    // If no config file exists and a user immediately opens a project,
    // the project's geometry will be saved as a default for when ipce is
    // opened again. Previously, the ipce's default size was small,
    // until a user opened ipce (but not a project) and resized to how they
    // wanted it to be sized, then closed ipce.
    if (project->isTemporaryProject() || !globalSettings.contains("geometry")) {
      globalSettings.setValue("geometry", QVariant(geometry()));
    }

@@ -590,6 +624,9 @@ namespace Isis {
   *                           References #4358.
   *   @history 2017-10-17 Tyler Wilson Added a [recent projects] group for the saving and
   *                           restoring of recently opened projects.  References #4492.
   *   @history Kaitlyn Lee 2018-07-09 - Added the value "maximized" in the project settings
   *                           so that a project remembers if it was in fullscreen when saved.
   *                           Fixes #5175.
   */
  void IpceMainWindow::writeSettings(Project *project) {

@@ -603,6 +640,7 @@ namespace Isis {

    projectSettings.setValue("geometry", QVariant(geometry()));
    projectSettings.setValue("windowState", saveState());
    projectSettings.setValue("maximized", isMaximized());
    projectSettings.sync();
  }

@@ -625,6 +663,10 @@ namespace Isis {
   *                Fixes #5075.
   *   @history Makayla Shepherd 2018-06-10 - Settings are read from the project root ipce.config.
   *                If that does not exist then we read from .Isis/ipce/ipce.config.
   *   @history Kaitlyn Lee 2018-07-09 - Added the call showNormal() so when a project is
   *                not saved in fullscreen, the window will resize to the project's
   *                window size. This also fixes the history/warning tabs being misplaced
   *                when opening a project. Fixes #5175.
   */
  void IpceMainWindow::readSettings(Project *project) {
    // Ensure that the Project pointer is not NULL
@@ -658,7 +700,12 @@ namespace Isis {
    QSettings projectSettings(FileName(filePath).expanded(), QSettings::NativeFormat);

    if (!isFullScreen) {
      // If a project was not in fullscreen when saved, restore the project's window size.
      if (!projectSettings.value("maximized").toBool()) {
        showNormal();
      }
      setGeometry(projectSettings.value("geometry").value<QRect>());

      if (!project->isTemporaryProject()) {
        restoreState(projectSettings.value("windowState").toByteArray());
      }
@@ -727,6 +774,9 @@ namespace Isis {
   */
  void IpceMainWindow::closeEvent(QCloseEvent *event) {

    foreach(TemplateEditorWidget *templateEditor, m_directory->templateEditorViews()) {
      templateEditor->saveOption();
    }
    // The active control is checked here for modification because this was the simplest solution
    // vs changing the project clean state every time the control is modified or saved.
    if (!m_directory->project()->isClean() || (m_directory->project()->activeControl() &&
@@ -820,6 +870,28 @@ namespace Isis {
  }


  /**
   * Tile all open attached/detached views
   */
  void IpceMainWindow::tileViews() {
    // splitDockWidget() takes two widgets and tiles them, so an easy way to do
    // this is to grab the first view and tile the rest with the first.
    QDockWidget *firstView = m_viewDocks.first();

    foreach (QDockWidget *currentView, m_viewDocks) {
      // We have to reattach a view before it can be tiled. If it is attached,
      // this will have no affect. We have to call addDockWidget() to untab any views.
      currentView->setFloating(false);
      addDockWidget(Qt::LeftDockWidgetArea, currentView, Qt::Horizontal);

      if (currentView == firstView) {
        continue;
      }
      splitDockWidget(firstView, currentView, Qt::Horizontal);
    }
  }


/**
 * Raises the warningWidget to the front of the tabs. Connected to warning signal from directory.
 */
+41 −9
Original line number Diff line number Diff line
@@ -143,8 +143,9 @@ namespace Isis {
   *   @history 2018-06-13 Tracie Sucharski - Fixed cleanup of views and QDockWidgets.
   *   @history 2018-06-13 Kaitlyn Lee - Since views now inherit from QMainWindow, each individual
   *                           view has its own toolbar, so having an active toolbar and tool pad is
   *                           not needed. Removed code adding the save active control net button and
   *                           the toolpad, since control nets can be saved with the project save button.
   *                           not needed. Removed code adding the save active control net button
   *                           and the toolpad, since control nets can be saved with the project
   *                           save button.
   *   @history 2018-06-14 Christopher Combs - Changed addView method to take in JigsawRunWidget as
   *                           a QDockWidget object instead of wrapping it in one.
   *   @history 2018-06-15 Tracie Sucharski - Fixed break to recent projects.  The readSettings
@@ -153,18 +154,47 @@ namespace Isis {
   *   @history 2018-06-18 Makayla Shepherd - Set the QApplication name so that BundleAdjust does
   *                           not output text to the command line for ipce. Fixes #4171.
   *   @history 2018-06-19 Kaitlyn Lee - Added tabViews() and the menu option under the View menu to
   *                           tab the views. Currently, this can tab all attached/detached views. I
   *                           left the line setting dock options to allow grouped dragging, but tabbing
   *                           views does not always work with this enabled. With this option enabled, the
   *                           type of a view will randomly change and setting its type has no effect.
   *                           Use windowType() to get the type. Also added the toolbar title in the
   *                           permanent toolbar constructor. 
   *                           tab the views. Currently, this can tab all attached/detached views.
   *                           I left the line setting dock options to allow grouped dragging, but
   *                           tabbing views does not always work with this enabled. With this
   *                           option enabled, the type of a view will randomly change and setting
   *                           its type has no effect. Use windowType() to get the type. Also added
   *                           the toolbar title in the permanent toolbar constructor.
   *   @history 2018-06-22 Tracie Sucharski - Cleanup destruction of dock widgets and the views they
   *                           hold.  Extra destroy slots were causing double deletion of memory.
   *   @history 2018-06-22 Tracie Sucharski - Added a showEvent handler so that the project clean
   *                           state can be reset after the IpceMainWindow::show() causes resize and
   *                           move events which in turn cause the project clean flag to be false
   *                           even though the project has just opened.
   *   @history 2018-07-07 Summer Stapleton - Added check in the closeEvent() for changes to any
   *                           TemplateEditorWidget currently open to create a pop-up warning/
   *                           option to save.
   *   @history 2018-07-09 Kaitlyn Lee - Added tileViews() and the menu option to tile all
   *                           docked/undocked and tabbed/untabbed views. Changed removeView() to
   *                           delete the parent dock widget. If we do not delete the dock widget,
   *                           an empty dock widget will remain where the view used to be.
   *   @history 2018-07-10 Tracie Sucharski - Change initial interface of views to tabbed view.
   *                           Changed the QMainWindow separator to a different color and wider size
   *                           for ease of use.  Create the QMainWindow initial size to prevent the
   *                           Viewports in CubeDnView from being created as a small size.
   *   @history 2018-07-11 Kaitlyn Lee - Added a value in the project settings that stores whether a
   *                           project was in fullscreen or not when saved. If not, we call showNormal()
   *                           to restore the poject's window size. This also fixes the warning/history tabs
   *                           being misplaced when opening a project. Fixes #5175. References #5436.
   *   @history 2018-07-12 Tracie Sucharski - Renamed the signal Directory::viewClosed to
   *                           Directory::closeView since Directory does not close the view but
   *                           indicate that the view needs closing.  This signal is now used by
   *                           more than the cnetEditorView, so updated documentation.  Did a little
   *                           cleanup on the removeView  method by removing some code that
   *                           automatically happens due to connection made on destroyed signal.
   *   @history 2018-07-12 Kaitlyn Lee - Removed code that makes the window fullscreen in memory,
   *                           since this was causing a project's window size to not be restored
   *                           when opening from the command line. Decreased the size and changed
   *                           the color of the splitter. In writeGlobalSettings(), check to see if
   *                           the geometry value does not exist in the config file. This allows the
   *                           geometry to be saved if the config file does not exist and a user
   *                           opens a project. Before, it would not save the geometry because the
   *                           opened project was not temporary. References #5433
   */
  class IpceMainWindow : public QMainWindow {
      Q_OBJECT
@@ -192,8 +222,10 @@ namespace Isis {
      void enterWhatsThisMode();

      void tabViews();
      void tileViews();

      void raiseWarningTab();

      void cleanupViewDockList(QObject *obj);

    private:
+24 −0
Original line number Diff line number Diff line
@@ -24,11 +24,14 @@

#include <QAction>
#include <QDebug>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
#include <QList>
#include <QMainWindow>
#include <QRect>
#include <QSizePolicy>
#include <QWidget>

#include "ProjectItem.h"
@@ -45,11 +48,32 @@ namespace Isis {
  AbstractProjectItemView::AbstractProjectItemView(QWidget *parent) : QMainWindow(parent) {

    setWindowFlags(Qt::Widget);

    QSizePolicy policy = sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    setSizePolicy(policy);

    m_internalModel = new ProjectItemProxyModel(this);
    setAcceptDrops(true);
  }


  /**
   * Returns the suggested size
   *
   * @return @b QSize The size hint
   */
  QSize AbstractProjectItemView::sizeHint() const {

    //  Size hint is made ridiculously large as a hack to have the views fill the available dock
    //  space. SizePolicy alone did not work.
    QDesktopWidget deskTop;
    QRect availableSpace = deskTop.availableGeometry(deskTop.primaryScreen());
    return QSize( .89 * availableSpace.width(), .5 * availableSpace.height() );
  }


  /**
   * Sets the model used by the view. If the internal model is a proxy
   * model, it sets the source model.
Loading