Commit 9dfecff7 authored by Marjorie Hahn's avatar Marjorie Hahn
Browse files

Finished new tile scheme implementation, will affect qview and CubeDnView in IPCE. Fixes #4962.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7862 41f8697f-d340-4b68-9986-7bafba869bb8
parent 0d1c7726
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -291,6 +291,7 @@ namespace Isis {
    if(completed) {
      realProgress = 100;
      p_progressTimer->stop();
      emit progressComplete();
      emit screenPixelsChanged();
    }
    else if(realProgress == 100) {
@@ -1937,7 +1938,6 @@ namespace Isis {
      }
    }


    if(p_camera) {
      p_camera->SetBand(band);
    }
@@ -1945,6 +1945,7 @@ namespace Isis {
    viewport()->repaint();
  }

  
  void CubeViewport::forgetStretches() {
    for(int stretch = 0; stretch < p_knownStretches->size(); stretch++) {
      if((*p_knownStretches)[stretch]) {
+1 −0
Original line number Diff line number Diff line
@@ -421,6 +421,7 @@ namespace Isis {
       * Emitted with current progress (0 to 100) when working
       */
      void progressChanged(int);
      void progressComplete();

      /**
       * Emitted when a brick is no longer needed, should only be sent
+76 −10
Original line number Diff line number Diff line
@@ -3,8 +3,13 @@
#include <iostream>

#include <QAction>
#include <QList>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QMenu>
#include <QMenuBar>
#include <QPoint>
#include <QRect>
#include <QToolBar>

#include "MdiCubeViewport.h"
@@ -115,9 +120,10 @@ namespace Isis {
   * @param ws
   */
  void WindowTool::addTo(Workspace *ws) {
    p_mdiArea = ws->mdiArea();
    Tool::addTo(ws);
    connect(p_cascadeWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(cascadeSubWindows()));
    connect(p_tileWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(tileSubWindows()));
    connect(p_tileWindows, SIGNAL(triggered()), this, SLOT(tileViewports()));
    connect(p_prevWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(activatePreviousSubWindow()));
    connect(p_nextWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(activateNextSubWindow()));
    connect(p_closeWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(closeActiveSubWindow()));
@@ -127,6 +133,68 @@ namespace Isis {
  }


  /**
   * Helper function for determining the size of the viewports.
   *
   * @return Returns the size that the viewports should be.
   * @internal
   *  @history 2017-07-19 Tracie Sucharski - Original version.
   */
  int WindowTool::viewportSize() {
    int numViewports = p_mdiArea->subWindowList().size();

    double mdiWidth = p_mdiArea->width();
    double mdiHeight = p_mdiArea->height();

    double px = ceil(sqrt(numViewports*mdiWidth/mdiHeight));
    double sx, sy;
    if (floor(px*mdiHeight/mdiWidth)*px < numViewports) {
      sx = mdiHeight/ceil(px*mdiHeight/mdiWidth);
    }
    else {
      sx = mdiWidth/px;
    }

    double py = ceil(sqrt(numViewports * mdiHeight / mdiWidth));
    if (floor(py*mdiWidth/mdiHeight)*py < numViewports) {
      sy = mdiWidth/ceil(mdiWidth*py/mdiHeight);
    }
    else {
      sy = mdiHeight/py;
    }
    
    return std::max(sx,sy); 
  }

  
  /**
   * Tiles the cube viewports over the Cube DN View.
   *
   * @internal
   *  @history 2017-07-19 Marjorie Hahn and Tracie Sucharski - Original version.
   */
  void WindowTool::tileViewports() {
    int vpSize = viewportSize();

    QPoint position(0, 0);
    
    QList<QMdiSubWindow *> windowList = p_mdiArea->subWindowList();
    
    for (int i = windowList.size() - 1; i >= 0; i--) {
      QMdiSubWindow *window = windowList[i];
      QRect rect(0, 0, vpSize, vpSize);
      window->setGeometry(rect);
      window->move(position);
     
      position.setX(position.x() + window->width());
      if (position.x() + window->width() > p_mdiArea->width()) {
        position.setX(0);
        position.setY(position.y() + window->height());
      }
    }  
  }


  /**
   * Adds the link window action to the tool bar.
   *
@@ -193,11 +261,6 @@ namespace Isis {
  }


  void newViewportOpened(CubeViewport *cvp) {
    
  }


  /**
   * Links all viewport windows in the workspace.
   *
@@ -224,7 +287,7 @@ namespace Isis {
  }

  /**
   * toggles the cursor from an arrow to a crosshair.
   * Toggles the cursor from an arrow to a crosshair.
   *
   */
  void WindowTool::changeCursor() {
@@ -240,7 +303,10 @@ namespace Isis {
    }
  }


  /**
   * Updates the cursor over the viewport.
   *
   */
  void WindowTool::updateViewportCursor(MdiCubeViewport *cvp) {
    if (p_changeCursor->text() == "Change cursor to crosshair." &&
        cvp->viewport()->cursor().shape() != Qt::ArrowCursor) {
+7 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include "Tool.h"

class QAction;
class QMdiArea;

namespace Isis {
  class MdiCubeViewport;
@@ -26,7 +27,9 @@ namespace Isis {
      void addTo(Workspace *ws);
      void addToPermanent(QToolBar *toolbar);

      //! Returns the menu name.
      /** 
       * @return the menu name
       */
      QString menuName() const {
        return "&Window";
      }
@@ -42,10 +45,13 @@ namespace Isis {
      void unlinkWindows();
      void resizeWindows();
      void updateViewportCursor(MdiCubeViewport *);
      void tileViewports();

    private:
      int viewportSize();

    private:
      QMdiArea *p_mdiArea;         //!< area where viewports are displayed
      QAction *p_cascadeWindows;   //!< cascade windows action
      QAction *p_tileWindows;      //!< tile windows action
      QAction *p_resizeWindows;    //!< resize windows action
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ namespace Isis {

    connect(m_viewport, SIGNAL(progressChanged(int)),
            progressBar, SLOT(setValue(int)));
    connect(m_viewport, SIGNAL(progressComplete()), progressBar, SLOT(hide()));
    connect(this, SIGNAL(closeViewport(CubeViewport *)),
            m_viewport, SIGNAL(viewportClosed(CubeViewport *)));
    widget()->layout()->addWidget(progressBar);