Unverified Commit 4c3b7b70 authored by kledmundson's avatar kledmundson Committed by GitHub
Browse files

Merge pull request #396 from TracieSucharski/dev

Fixed the model/view in ipce so that footprints will load quicker. Fi…
parents 2d76b7da 67b5958e
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -256,14 +256,13 @@ namespace Isis {

  /**
   * Adds an item to the view. The item must be part of the view's
   * model. This method can be overriden in a subclass to filter out
   * model. This method can be overridden in a subclass to filter out
   * unneeded items.
   *
   * @param[in] item (ProjectItem *) The item to add.
   */
  void AbstractProjectItemView::addItem(ProjectItem *item) {
        if (ProjectItemProxyModel *proxyModel =
        qobject_cast<ProjectItemProxyModel *>( internalModel() ) ) {
    if (ProjectItemProxyModel *proxyModel = qobject_cast<ProjectItemProxyModel *>( internalModel() )) {
      proxyModel->addItem(item);
    }
  }
@@ -271,13 +270,14 @@ namespace Isis {

  /**
   * Adds several items to the view. The items must be a part of the
   * view's model.
   * view's model. This method can be overridden in a subclass to filter out
   * unneeded items.
   *
   * @param[in] items (QList<ProjectItem *>) The items to add.
   */
  void AbstractProjectItemView::addItems(QList<ProjectItem *> items) {
    foreach (ProjectItem *item, items) {
      addItem(item);
    if (ProjectItemProxyModel *proxyModel = qobject_cast<ProjectItemProxyModel *>( internalModel() )) {
      proxyModel->addItems(items);
    }
  }

+5 −1
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ namespace Isis {
   *                           CubeDnViews to be opened at once, since CubeDnView has an internal
   *                           size policy. References #5433
   *   @history 2018-07-26 Tracie Sucharski - Cleaned up some documentation.
   *   @history 2018-08-10 Tracie Sucharski - Changed addItems method to call the
   *                           ProjectItemProxyModel::addItems rather than this classes addItem.
   *                           This speeds things up considerably loading items into the model.
   *                           References #5296.
   */
  class AbstractProjectItemView : public QMainWindow {

+35 −14
Original line number Diff line number Diff line
@@ -78,11 +78,13 @@ namespace Isis {

    connect( internalModel(), SIGNAL( itemAdded(ProjectItem *) ),
             this, SLOT( onItemAdded(ProjectItem *) ) );
    connect( internalModel(), SIGNAL( itemsAdded() ),
             this, SLOT( onItemsAdded() ) );
    connect( internalModel(), SIGNAL( itemRemoved(ProjectItem *) ),
             this, SLOT( onItemRemoved(ProjectItem *) ) );

    connect(m_sceneWidget, SIGNAL(queueSelectionChanged()),
            this, SLOT(onQueueSelectionChanged() ) );
            this, SLOT(onQueueSelectionChanged()), Qt::QueuedConnection);

    //  Pass on Signals emitted from ControlNetTool, through the MosaicSceneWidget
    //  TODO 2016-09-09 TLS Design:  Use a proxy model instead of signals?
@@ -99,7 +101,8 @@ namespace Isis {
            this, SLOT(onMosItemRemoved(Image *)));

    //  Pass on redrawMeasure signal from Directory, so the control measures are redrawn on all
    //  the footprints.
    //  the footprints. Connection made in Directory from directory's signal to this signal since
    //  Directory doesn't have access to the scene within the sceneWidget.
    connect(this, SIGNAL(redrawMeasures()), m_sceneWidget->getScene(), SLOT(update()));

    setStatusBar(statusBar);
@@ -170,6 +173,14 @@ namespace Isis {
  }


  /**
   * Accessor for the FileListWidget
   */
  ImageFileListWidget *Footprint2DView::fileListWidget() {
    return m_fileListWidget;
  }


  /**
   * Event filter to filter out drag and drop events.
   *
@@ -197,8 +208,10 @@ namespace Isis {


  /**
   * Slot to connect to the itemAdded signal from the model. If the
   * item is an image it adds it to the scene.
   * Slot to connect to the itemAdded signal from the model. If the item is an image or shape it is 
   * added to a list. When everything has been added, then the list is added to the scene through 
   * signal/slot connection from ProjectItemProxyModel signal, itemsAdded which is connected to 
   * this objects onItemsAdded slot. 
   *
   * @param[in] item (ProjectItem *) The item
   */
@@ -206,22 +219,16 @@ namespace Isis {
    if (!item || (!item->isImage() && !item->isShape())) {
      return;
    }
    //TODO 2016-09-09 TLS  Handle Shapes-Create image from shape since qmos only handles images?
    //                   Still don't know if shape should inherit from image or contain an image?
    //

    Image *image;
    ImageList images;
    if (item->isShape()) {
      //TEMPORARY UNTIL SHAPE IS FIXED TO HOLD IMAGE, once Shape holds image go back to old code
      // previous to 10-21-16
      image = new Image(item->shape()->cube());
    }
    else if (item->isImage()) {
      image = item->image();
    }
    images.append(image);
    m_sceneWidget->addImages(images);
    m_fileListWidget->addImages(&images);

    m_images.append(image);

    if (!m_imageItemMap.value(image)) {
      m_imageItemMap.insert(image, item);
@@ -229,6 +236,20 @@ namespace Isis {
  }


  /**
   * Slot called once all selected images have been added to the proxy model.  This is much faster 
   * than adding a single image at a time to the MosaicSceneWidget. This is connected from the 
   * ProjectItemProxyModel::itemsAdded signal. 
   *
   */
  void Footprint2DView::onItemsAdded() {
    //  This is called once all selected images have been added to proxy model (internalModel())
    //  This is much faster than adding a single image at a time to the scene widget
    m_sceneWidget->addImages(m_images);
    m_fileListWidget->addImages(&m_images);
  }


  /**
   * Slot at removes the mosaic item and corresponding image file list item when a cube is closed
   * using the Close Cube context menu.
+13 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

#include "AbstractProjectItemView.h"
#include "FileName.h"
#include "ImageList.h"
#include "XmlStackedHandler.h"

class QAction;
@@ -97,6 +98,15 @@ namespace Isis {
   *   @history 2018-07-12 Tracie Sucharski - Renamed m_controlNetTool to m_controlNetToolAction
   *                           to be clear it is not a pointer to the tool.  Add a call to
   *                           the MosaicControlNetTool::loadNetwork in enableControlNetTool.
   *   @history 2018-07-31 Tracie Sucharski - Add accessor method for ImageFileListWidget.
   *   @history 2018-08-10 Tracie Sucharski - Added new slot connected from ProjectItemProxyModel's
   *                           itemsAdded signal which is emitted after all selected items have
   *                           been added to the proxy model.  The images are added to a new private
   *                           member as each item is added to the model through the slot,
   *                           onItemAdded. This allows the FootprintView to put all selected items
   *                           into the scene widget at once rather than individually which speeds
   *                           the display of footprints. Fixes #5296.
   *  
   */
  class Footprint2DView : public AbstractProjectItemView {

@@ -107,6 +117,7 @@ namespace Isis {
      ~Footprint2DView();

      MosaicSceneWidget *mosaicSceneWidget();
      ImageFileListWidget *fileListWidget();

      void load(XmlStackedHandlerReader *xmlReader);
      void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const;
@@ -127,6 +138,7 @@ namespace Isis {

    private slots:
      void onItemAdded(ProjectItem *item);
      void onItemsAdded();
      void onItemRemoved(ProjectItem *item);
      void onQueueSelectionChanged();
      void onMosItemRemoved(Image *image);
@@ -159,6 +171,7 @@ namespace Isis {
      MosaicSceneWidget *m_sceneWidget; //!< The scene widget
      ImageFileListWidget *m_fileListWidget; //!< The file list widget
      QMainWindow *m_window; //!< Main window
      ImageList m_images;
      QMap<Image *, ProjectItem *> m_imageItemMap; //!< Maps images to their items
      Directory *m_directory; //!< The directory

+1 −2
Original line number Diff line number Diff line
@@ -179,7 +179,6 @@ namespace Isis {
   * @return @b ProjectItem* The item in the proxy model.
   */
  ProjectItem *ProjectItemProxyModel::addItem(ProjectItem *sourceItem) {
//  qDebug()<<"ProjectItemProxyModel::addItem";
    if (!sourceItem) {
      return 0;
    }
@@ -208,10 +207,10 @@ namespace Isis {
   *                                              source model.                                              
   */
  void ProjectItemProxyModel::addItems(QList<ProjectItem *> sourceItems) {
//  qDebug()<<"ProjectItemProxyModel::addItem";
    foreach (ProjectItem *item, sourceItems) {
      addItem(item);
    }
    emit itemsAdded();
  }

  
Loading