From fcf0e5ac4ab5c6288e360f2c949961accad557cb Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Tue, 1 Sep 2015 09:57:17 +0100 Subject: [PATCH] refs #13517. Remove obsolete. All of this is associated with the old mechanism for rebinning and remapping of dimensions. This is obsolete now (and has been for some time). --- .../ParaViewWidgets/QtWidgets/CMakeLists.txt | 8 - .../QtWidgets/DimensionWidget.cpp | 328 ------------ .../QtWidgets/DimensionWidget.h | 147 ------ .../QtWidgets/DimensionWidgetFactory.cpp | 21 - .../QtWidgets/DimensionWidgetFactory.h | 24 - .../QtWidgets/GeometryWidget.cpp | 96 ---- .../QtWidgets/GeometryWidget.h | 139 ----- Code/Mantid/Vates/VatesAPI/CMakeLists.txt | 8 - .../inc/MantidVatesAPI/DimensionPresenter.h | 83 --- .../inc/MantidVatesAPI/DimensionView.h | 41 -- .../inc/MantidVatesAPI/GeometryPresenter.h | 63 --- .../SynchronisingGeometryPresenter.h | 135 ----- .../Vates/VatesAPI/src/DimensionPresenter.cpp | 224 -------- .../src/SynchronisingGeometryPresenter.cpp | 498 ------------------ .../VatesAPI/test/DimensionPresenterTest.h | 297 ----------- .../test/SynchronisingGeometryPresenterTest.h | 345 ------------ 16 files changed, 2457 deletions(-) delete mode 100644 Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.cpp delete mode 100644 Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.h delete mode 100644 Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.cpp delete mode 100644 Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.h delete mode 100644 Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.cpp delete mode 100644 Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.h delete mode 100644 Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionPresenter.h delete mode 100644 Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionView.h delete mode 100644 Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GeometryPresenter.h delete mode 100644 Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/SynchronisingGeometryPresenter.h delete mode 100644 Code/Mantid/Vates/VatesAPI/src/DimensionPresenter.cpp delete mode 100644 Code/Mantid/Vates/VatesAPI/src/SynchronisingGeometryPresenter.cpp delete mode 100644 Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h delete mode 100644 Code/Mantid/Vates/VatesAPI/test/SynchronisingGeometryPresenterTest.h diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/CMakeLists.txt b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/CMakeLists.txt index 3e0774ec72b..3ad9523a000 100644 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/CMakeLists.txt +++ b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/CMakeLists.txt @@ -2,9 +2,6 @@ set( INC_FILES BinInputWidget.h WidgetDllOption.h - GeometryWidget.h - DimensionWidget.h - DimensionWidgetFactory.h LowHighStepInputWidget.h SimpleBinInputWidget.h ThresholdRangeWidget.h @@ -13,8 +10,6 @@ set( INC_FILES # header files that are mocced set( HDR_FILES BinInputWidget.h - GeometryWidget.h - DimensionWidget.h LowHighStepInputWidget.h SimpleBinInputWidget.h ThresholdRangeWidget.h @@ -22,9 +17,6 @@ set( HDR_FILES # source files set( SRC_FILES - GeometryWidget.cpp - DimensionWidget.cpp - DimensionWidgetFactory.cpp LowHighStepInputWidget.cpp SimpleBinInputWidget.cpp ThresholdRangeWidget.cpp diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.cpp b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.cpp deleted file mode 100644 index 66f4fafd4cf..00000000000 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.cpp +++ /dev/null @@ -1,328 +0,0 @@ -#include <QLabel> -#include <QLayout> -#include <QLineEdit> -#include <QComboBox> -#include <QPushButton> -#include <QCheckBox> -#include <QSpacerItem> -#include <QStackedWidget> -#include <qmessagebox.h> -#include <stdio.h> -#include <string> -#include <vector> -#include <iostream> -#include "DimensionWidget.h" -#include "LowHighStepInputWidget.h" -#include "SimpleBinInputWidget.h" -#include <boost/algorithm/string.hpp> -#include <boost/format.hpp> -#include <boost/scoped_ptr.hpp> - -using namespace Mantid::VATES; - -/** -Constructor -*/ -DimensionWidget::DimensionWidget() : - m_layout(NULL), m_binLayout(NULL), m_axisLayout(NULL), m_currentDimensionIndex(0), - m_currentBinWidgetIndex(0), m_pDimensionPresenter(NULL), m_initialBinDisplay(BinDisplay::Simple) -{ - m_binStackedWidget = new QStackedWidget; - BinInputWidget* simple = new SimpleBinInputWidget; - BinInputWidget* lowstephigh = new LowHighStepInputWidget; - m_binStackedWidget->addWidget(simple); - m_binStackedWidget->addWidget(lowstephigh); - m_binStackedWidget->addWidget(new QLabel("")); - m_binStackedWidget->setCurrentIndex(m_currentBinWidgetIndex); - - using namespace Mantid::Geometry; - QVBoxLayout* m_layout = new QVBoxLayout(); - m_layout->setSpacing(2); - - m_dimensionLabel = new QLabel(); - m_layout->addWidget(m_dimensionLabel, Qt::AlignLeft); - - QHBoxLayout* m_binLayout = new QHBoxLayout(); - - m_ckIntegrated = new QCheckBox(); - m_ckIntegrated->setText("Integrate"); - m_ckIntegrated->setToolTip("Collapse/Expand dimension"); - connect(m_ckIntegrated, SIGNAL(clicked(bool)), this, SLOT(integratedChanged(bool))); - m_binLayout->addWidget(m_ckIntegrated); - - QSpacerItem* spacer = new QSpacerItem(40, 20, - QSizePolicy::Maximum, - QSizePolicy::Minimum); - m_binLayout->addSpacerItem(spacer); - - m_binLayout->addWidget(m_binStackedWidget, Qt::AlignLeft); - connect(simple, SIGNAL(valueChanged()), this, SLOT(nBinsListener())); - connect(lowstephigh, SIGNAL(valueChanged()), this, SLOT(nBinsListener())); - - m_layout->addLayout(m_binLayout); - - QHBoxLayout* m_axisLayout = new QHBoxLayout(); - - m_dimensionCombo = new QComboBox(); - QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); - m_dimensionCombo->setSizePolicy(sizePolicy); - m_dimensionCombo->setMinimumSize(QSize(80, 0)); - connect(m_dimensionCombo,SIGNAL(activated(int)),this ,SLOT(dimensionSelectedListener())); - m_axisLayout->addWidget(m_dimensionCombo, Qt::AlignLeft); - - m_axisLayout->addWidget(new QLabel("Min")); - - m_minBox = new QLineEdit(); - m_minBox->setValidator(new QDoubleValidator(this)); - QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Minimum); - m_minBox->setSizePolicy(sizePolicy1); - m_minBox->setMinimumSize(QSize(50, 0)); - connect(m_minBox, SIGNAL(editingFinished()), this, SLOT(minBoxListener())); - m_axisLayout->addWidget(m_minBox, Qt::AlignLeft); - - m_axisLayout->addWidget(new QLabel("Max")); - - m_maxBox = new QLineEdit(); - m_maxBox->setValidator(new QDoubleValidator(this)); - QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Minimum); - m_maxBox->setSizePolicy(sizePolicy2); - m_maxBox->setMinimumSize(QSize(50, 0)); - connect(m_maxBox, SIGNAL(editingFinished()), this, SLOT(maxBoxListener())); - m_axisLayout->addWidget(m_maxBox, Qt::AlignLeft); - - m_layout->addLayout(m_axisLayout); - - this->setLayout(m_layout); -} - -void DimensionWidget::initalizeViewMode(BinDisplay binDisplay) -{ - m_initialBinDisplay = binDisplay; -} - - -BinInputWidget* DimensionWidget::getCurrentBinInputWidget() const -{ - QWidget *w; - if (m_binStackedWidget->currentIndex() > 1) - { - w = m_binStackedWidget->widget(m_currentBinWidgetIndex); - } - else - { - w = m_binStackedWidget->currentWidget(); - } - return dynamic_cast<BinInputWidget*>(w); -} - -Mantid::coord_t DimensionWidget::getMinimum() const -{ - return m_minBox->text().toFloat(); -} - -Mantid::coord_t DimensionWidget::getMaximum() const -{ - return m_maxBox->text().toFloat(); -} - -unsigned int DimensionWidget::getNBins() const -{ - int nbins = static_cast<int>(m_pDimensionPresenter->getModel()->getNBins()); - double max = m_pDimensionPresenter->getModel()->getMaximum(); - double min = m_pDimensionPresenter->getModel()->getMinimum(); - BinInputWidget* binInputWidget = getCurrentBinInputWidget(); - int entry = binInputWidget->getEntry(min, max); - if(entry == nbins || entry <= 1) - { - binInputWidget->setEntry(nbins, min, max); - } - return binInputWidget->getEntry(min, max); -} - -void DimensionWidget::displayError(std::string message) const -{ - QMessageBox msgBox; - msgBox.setText(message.c_str()); - msgBox.exec(); -} - -unsigned int DimensionWidget::getSelectedIndex() const -{ - return m_dimensionCombo->currentIndex(); -} - - -void DimensionWidget::showAsNotIntegrated(Mantid::Geometry::VecIMDDimension_sptr) -{ - setDimensionName(m_pDimensionPresenter->getLabel()); - double max = m_pDimensionPresenter->getModel()->getMaximum(); - double min = m_pDimensionPresenter->getModel()->getMinimum(); - m_binStackedWidget->setCurrentIndex(m_currentBinWidgetIndex); - m_ckIntegrated->setChecked(false); - BinInputWidget* binInputWidget = getCurrentBinInputWidget(); - if(binInputWidget->getEntry(min, max) <= 1) - { - size_t modelBins = m_pDimensionPresenter->getModel()->getNBins(); - if( modelBins > 1) - { - binInputWidget->setEntry(int(modelBins), min, max); - } - else - { - binInputWidget->setEntry(10, min, max); - } - - } -} - -/* -Helper method to set dimension names whereever required. -@param name : name of the dimension to display -*/ -void DimensionWidget::setDimensionName(const std::string& name) -{ - m_dimensionLabel->setText(name.c_str()); - this->setToolTip(name.c_str()); -} - - -void DimensionWidget::showAsIntegrated() -{ - setDimensionName(m_pDimensionPresenter->getModel()->getDimensionId()); - m_binStackedWidget->setCurrentIndex(2); - m_ckIntegrated->setChecked(true); -} - -/** Configure the DimensionView to override only selection choice controls. Otherwise leave nbins, max, min in their current state. -*/ -void DimensionWidget::configureWeakly() -{ - using Mantid::Geometry::VecIMDDimension_sptr; - m_dimensionCombo->clear(); - - GeometryPresenter::MappingType mappings = m_pDimensionPresenter->getMappings(); //Should be sv collection? - GeometryPresenter::MappingType::iterator it = mappings.begin(); - unsigned int count = 0; - for(; it != mappings.end(); ++it) - { - m_dimensionCombo->addItem(it->first.c_str()); - if(it->first == m_pDimensionPresenter->getMapping()) - { - m_dimensionCombo->setCurrentItem(count); - } - count++; - - } -} - -/** Configure the DimensionView to override any controls with the values obtained from the model. -*/ -void DimensionWidget::configureStrongly() -{ - configureWeakly(); - double max = m_pDimensionPresenter->getModel()->getMaximum(); - double min = m_pDimensionPresenter->getModel()->getMinimum(); - BinInputWidget* binInputWidget = getCurrentBinInputWidget(); - binInputWidget->setEntry(int(m_pDimensionPresenter->getModel()->getNBins()),min,max); - - std::string maxValueString = boost::str(boost::format("%i") % m_pDimensionPresenter->getModel()->getMaximum()); - m_maxBox->setText(maxValueString.c_str()); - - std::string minValueString = boost::str(boost::format("%i") % m_pDimensionPresenter->getModel()->getMinimum()); - m_minBox->setText(minValueString.c_str()); - setViewMode(m_initialBinDisplay); -} - -void DimensionWidget::accept(Mantid::VATES::DimensionPresenter* pDimensionPresenter) -{ - m_pDimensionPresenter = pDimensionPresenter; -} - -bool DimensionWidget::getIsIntegrated() const -{ - return m_ckIntegrated->isChecked(); -} - -void DimensionWidget::dimensionSelectedListener() -{ - m_pDimensionPresenter->updateModel(); -} - - -void DimensionWidget::nBinsListener() -{ - m_pDimensionPresenter->updateModel(); -} - -void DimensionWidget::minBoxListener() -{ - m_pDimensionPresenter->updateModel(); -} - -void DimensionWidget::maxBoxListener() -{ - m_pDimensionPresenter->updateModel(); -} - -void DimensionWidget::integratedChanged(bool) -{ - try - { - m_pDimensionPresenter->updateModel(); - } - catch(std::invalid_argument& ex) - { - m_ckIntegrated->setChecked(false); - QMessageBox msgBox; - msgBox.setText(ex.what()); - msgBox.exec(); - } -} - -DimensionWidget::~DimensionWidget() -{ -} - -std::string DimensionWidget::getVisDimensionName() const -{ - if(m_dimensionCombo->isHidden()) - { - return m_pDimensionPresenter->getMapping(); - } - else - { - return m_dimensionCombo->currentText().toStdString(); - } -} - -void DimensionWidget::setViewMode(Mantid::VATES::BinDisplay mode) -{ - double max = m_pDimensionPresenter->getModel()->getMaximum(); - double min = m_pDimensionPresenter->getModel()->getMinimum(); - BinInputWidget* binInputWidget = getCurrentBinInputWidget(); - int nBins = binInputWidget->getEntry(min, max); - - if(mode == Simple) - { - m_currentBinWidgetIndex = 0; - if (!m_ckIntegrated->isChecked()) - { - m_binStackedWidget->setCurrentIndex(m_currentBinWidgetIndex); - } - } - else if(mode == LowHighStep) - { - m_currentBinWidgetIndex = 1; - if (!m_ckIntegrated->isChecked()) - { - m_binStackedWidget->setCurrentIndex(m_currentBinWidgetIndex); - } - } - else - { - throw std::invalid_argument("Unknown bin display mode."); - } - BinInputWidget* binWidget = getCurrentBinInputWidget(); - binWidget->setEntry(nBins, min, max); -} - diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.h b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.h deleted file mode 100644 index 9d707e0873c..00000000000 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidget.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef DIMENSION_WIDGET_H -#define DIMENSION_WIDGET_H - -#include <qgridlayout.h> -#include <qwidget.h> -#include <memory> -#include <boost/shared_ptr.hpp> -#include <vector> -#include "WidgetDllOption.h" -#include "GeometryWidget.h" -#include "MantidVatesAPI/DimensionPresenter.h" - -//Foward decs -class QLabel; -class QComboBox; -class QLineEdit; -class QCheckBox; -class QStackedWidget; -class BinInputWidget; - -namespace Mantid -{ - namespace Geometry - { - /// Forward decs - class IMDDimension; - } -} - -/** -class is a Qt (QWidget) concrete version of a DimensionView. - -Displays dimension information as commanded by a DimensionPresenter. - -- DimensionWidgets are passed a DimensionPresenter, as part of the accept call, but DimensionWidgets do not own it! -- Controlled by a DimensionPresenter -- Has public methods to allow the DimensionPresenter to command changes - -*/ -// cppcheck-suppress class_X_Y -class EXPORT_OPT_MANTIDPARVIEW DimensionWidget: public QWidget, public Mantid::VATES::DimensionView -{ -Q_OBJECT -public: - - /// Constructor. - DimensionWidget(); - - /// Destructor - ~DimensionWidget(); - - /// Get minimum - Mantid::coord_t getMinimum() const; - - /// Get maximum - Mantid::coord_t getMaximum() const; - - -signals: - void maxSet(); - void minSet(); - void nBinsSet(); -private: - QVBoxLayout* m_layout; - QHBoxLayout* m_binLayout; - QHBoxLayout* m_axisLayout; - - //QLineEdit* m_nBinsBox; - - QLineEdit* m_minBox; - - QLineEdit* m_maxBox; - - QCheckBox* m_ckIntegrated; - - QComboBox* m_dimensionCombo; - - //QLabel* m_nBinsLabel; - - QLabel* m_dimensionLabel; - - int m_currentDimensionIndex; - - int m_currentBinWidgetIndex; - - std::string m_name; - - Mantid::VATES::DimensionPresenter* m_pDimensionPresenter; - - //Stacked widget to contain the bins input widget types. - QStackedWidget* m_binStackedWidget; - - Mantid::VATES::BinDisplay m_initialBinDisplay; - - /// Helper method to set names in all places required. - void setDimensionName(const std::string& name); - - BinInputWidget* getCurrentBinInputWidget() const; - - private slots: - - /// Handles dimension change events. - void dimensionSelectedListener(); - - void nBinsListener(); - - void maxBoxListener(); - - void minBoxListener(); - - void integratedChanged(bool checkedState); - -public: - - //--------------------------------------------------------- - // DimensionView implementations - //--------------------------------------------------------- - virtual void showAsNotIntegrated(Mantid::Geometry::VecIMDDimension_sptr nonIntegratedDims); - - virtual void showAsIntegrated(); - - virtual void displayError(std::string message) const; - - virtual void accept(Mantid::VATES::DimensionPresenter* pDimensionPresenter); - - virtual void configureStrongly(); - - virtual void configureWeakly(); - - virtual std::string getVisDimensionName() const; - - virtual unsigned int getNBins() const; - - virtual unsigned int getSelectedIndex() const; - - virtual bool getIsIntegrated() const; - - virtual void setViewMode(Mantid::VATES::BinDisplay mode); - - //--------------------------------------------------------- - // End DimensionView implementations - //--------------------------------------------------------- - - void initalizeViewMode(Mantid::VATES::BinDisplay binDisplay); -}; - -#endif diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.cpp b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.cpp deleted file mode 100644 index 0582eb1c006..00000000000 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "DimensionWidgetFactory.h" -#include "DimensionWidget.h" - -/** -Constructor -@param binDisplay : Enum indicating what type of bin display should be used. -*/ -DimensionWidgetFactory::DimensionWidgetFactory(Mantid::VATES::BinDisplay binDisplay) : m_binDisplay(binDisplay) -{ -} - -/** -Factory Method. -@return a new DimensionWidget -*/ -Mantid::VATES::DimensionView* DimensionWidgetFactory::create() const -{ - DimensionWidget* widget = new DimensionWidget; - widget->initalizeViewMode(m_binDisplay); - return widget; -} \ No newline at end of file diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.h b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.h deleted file mode 100644 index df68ccbf6fd..00000000000 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/DimensionWidgetFactory.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _DIMENSION_WIDGET_FACTORY_H -#define _DIMENSION_WIDGET_FACTORY_H - -#include "WidgetDllOption.h" -#include "MantidVatesAPI/DimensionViewFactory.h" - -/** -class DimensionWidgetFactory -concrete DimensionViewFactory. Creational type, fabricating dimension widgets on request. -*/ -// cppcheck-suppress class_X_Y -class EXPORT_OPT_MANTIDPARVIEW DimensionWidgetFactory : public Mantid::VATES::DimensionViewFactory -{ -public: - /// Constructor - DimensionWidgetFactory(Mantid::VATES::BinDisplay binDisplay); - /// Construction method. - Mantid::VATES::DimensionView* create() const; -private: - /// Bin display configuration. - const Mantid::VATES::BinDisplay m_binDisplay; -}; - -#endif diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.cpp b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.cpp deleted file mode 100644 index f0475707531..00000000000 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "GeometryWidget.h" -#include "DimensionWidget.h" -#include "MantidVatesAPI/GeometryPresenter.h" -#include <QLabel> -#include <QGridLayout> -#include <QCheckBox> - -using namespace Mantid::VATES; - -/** -Constructor -@param pPresenter : pointer to MVP presenter -@param binDisplay : Enum describing how the bins should be displayed -*/ -GeometryWidget::GeometryWidget(Mantid::VATES::GeometryPresenter* pPresenter, BinDisplay binDisplay) : m_widgetFactory(binDisplay), m_pPresenter(pPresenter), m_ckBinDisplay(new QCheckBox) -{ - m_ckBinDisplay->setText("By Number of Bins"); - m_ckBinDisplay->setToolTip("Specify the exact number of bins or a step in a low, high step schenario"); - m_ckBinDisplay->setChecked(binDisplay == Simple); - connect(m_ckBinDisplay, SIGNAL(clicked(bool)), this, SLOT(binModeChanged(bool))); - - QGridLayout* headerLayout = new QGridLayout(); - QVBoxLayout* bodyLayout = new QVBoxLayout(); - - headerLayout->addWidget(new QLabel("Geometry"), 0, 0, 1, 2, Qt::AlignCenter); - - bodyLayout->addWidget(m_ckBinDisplay); - bodyLayout->addLayout(headerLayout); - - this->setLayout(bodyLayout); - m_pPresenter->acceptView(this); -} - -/// Destructor -GeometryWidget::~GeometryWidget() -{ - delete m_pPresenter; -} - -/** -Add a new dimension view. -@param dimView : dimensionview (widget) to add to overall geometry widget. -*/ -void GeometryWidget::addDimensionView(DimensionView* dimView) -{ - DimensionWidget* dimWidget = dynamic_cast<DimensionWidget*>(dimView); //TODO. design should not need capability queries! - if(dimWidget != NULL) - { - QLayout* layout = this->layout(); - layout->addWidget(dimWidget); - } -} - -/** -Getter for the resultant/current xml string. -@return xml as a string. -*/ -std::string GeometryWidget::getGeometryXMLString() const -{ - return m_pPresenter->getGeometryXML(); -} - -/* -Gets a ref to the dimension view factory -Allows new dimensions of a type compatible with this GeometryWidget to be fabricated. -*/ -const Mantid::VATES::DimensionViewFactory& GeometryWidget::getDimensionViewFactory() -{ - return m_widgetFactory; -} - -/** -Indicate that the geometry widget has been modified by emitting an event. -*/ -void GeometryWidget::raiseModified() -{ - emit valueChanged(); -} - -/** -Handle changes in the binning mode. -*/ -void GeometryWidget::binModeChanged(bool) -{ - this->m_pPresenter->setDimensionModeChanged(); -} - -/** -Getter to indicate whether the number of bins should be used -@return BinDisplayMode to use. -*/ -BinDisplay GeometryWidget::getBinDisplayMode() const -{ - bool useNumberOfBins = this->m_ckBinDisplay->checkState(); - return useNumberOfBins ? Simple : LowHighStep; -} diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.h b/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.h deleted file mode 100644 index 05aac8b5a4f..00000000000 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewWidgets/QtWidgets/GeometryWidget.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef GEOMETRY_WIDGET_H -#define GEOMETRY_WIDGET_H - -/** This is the GUI implementation of the geometry layout for the Rebinning operations. -* Inpects input geometry to determine possibilities for shaping the geometry via the user interface. -* Manages DimensionWidget and IntegratedDimensionWidget types. - -@author Owen Arnold Tessella/ISIS -@date January 10/2011 - -Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid>. -Code Documentation is available at: <http://doxygen.mantidproject.org> -*/ - -#include <memory> -#include <boost/shared_ptr.hpp> -#include "WidgetDllOption.h" -#include "MantidGeometry/MDGeometry/MDGeometryXMLParser.h" -#include "MantidVatesAPI/GeometryView.h" -#include "MantidVatesAPI/DimensionView.h" -#include "DimensionWidgetFactory.h" -#include "DimensionWidget.h" - -/// Foward decs -class QLabel; -class QComboBox; -class QLayout; -class QCheckBox; - -namespace Mantid -{ - namespace Geometry - { - /// Forward decs - class IMDDimension; - } - namespace VATES - { - /// Forward decs - class GeometryPresenter; - } -} - -/** -GeometryWidget is a QWidget and a GeometryView. - -View of an MVP pattern. Controlled by an Presenter, which this View owns. - -- Internally, this type generates a layout onto which the presenter can command the placement of Dimensions. -- This type also owns a factory for creating DimensionViews, which the presenter will utilise. -- The view may be commanded by the presenter to raise events, so that owners of this widget may subscribe to and observe changes. - -*/ -// cppcheck-suppress class_X_Y -class EXPORT_OPT_MANTIDPARVIEW GeometryWidget: public QWidget, public Mantid::VATES::GeometryView -{ - -private: - - /// Dimension generating factory. - DimensionWidgetFactory m_widgetFactory; - - /// MVP presenter. - Mantid::VATES::GeometryPresenter* m_pPresenter; - - /// Checkbox for changing the bin display mode. - QCheckBox* m_ckBinDisplay; - - Q_OBJECT -public: - Q_PROPERTY(QString GeometryXML READ getGeometryXML WRITE setGeometryXML NOTIFY valueChanged) - - /// Constructor - GeometryWidget(Mantid::VATES::GeometryPresenter* pPresenter, Mantid::VATES::BinDisplay binDisplay); - - /// Raise geometry modified event. - virtual void raiseModified(); - - /// Destructor - ~GeometryWidget(); - - /// Gets the chosen geometry configuration. - QString getGeometryXML() const - { - return getGeometryXMLString().c_str(); - } - - /* - Sets the geometry xml. - @param value: xml string. - */ - void setGeometryXML(QString value) - { - //Do nothing. - UNUSED_ARG(value); - } - - /// Add a dimension view. - virtual void addDimensionView(Mantid::VATES::DimensionView*); - - /// Get the new geometry xml. - virtual std::string getGeometryXMLString() const; - - /// Get the dimension generating factory. - virtual const Mantid::VATES::DimensionViewFactory& getDimensionViewFactory(); - - /// Getter to indicate whether the number of bins should be used, or low - virtual Mantid::VATES::BinDisplay getBinDisplayMode() const; - - /// Single signal gets raised if anything changes -Q_SIGNALS: - void valueChanged(); - void ignoreBinChanges(); - -private slots: - - // Handler for the bin mode changing. - void binModeChanged(bool); - -}; - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/CMakeLists.txt b/Code/Mantid/Vates/VatesAPI/CMakeLists.txt index 1b7c641a25d..fa6b78519d0 100644 --- a/Code/Mantid/Vates/VatesAPI/CMakeLists.txt +++ b/Code/Mantid/Vates/VatesAPI/CMakeLists.txt @@ -9,7 +9,6 @@ src/BoxInfo.cpp src/Common.cpp src/CompositePeaksPresenterVsi.cpp src/ConcretePeaksPresenterVsi.cpp -src/DimensionPresenter.cpp src/EventNexusLoadingPresenter.cpp src/FieldDataToMetadata.cpp src/IgnoreZerosThresholdRange.cpp @@ -29,7 +28,6 @@ src/MetadataJsonManager.cpp src/Normalization.cpp src/NoThresholdRange.cpp src/ProgressAction.cpp -src/SynchronisingGeometryPresenter.cpp src/TimeStepToTimeStep.cpp src/TimeToTimeStep.cpp src/UserDefinedThresholdRange.cpp @@ -68,13 +66,10 @@ inc/MantidVatesAPI/BoxInfo.h inc/MantidVatesAPI/Common.h inc/MantidVatesAPI/CompositePeaksPresenterVsi.h inc/MantidVatesAPI/ConcretePeaksPresenterVsi.h -inc/MantidVatesAPI/DimensionPresenter.h -inc/MantidVatesAPI/DimensionView.h inc/MantidVatesAPI/DimensionViewFactory.h inc/MantidVatesAPI/EventNexusLoadingPresenter.h inc/MantidVatesAPI/FieldDataToMetadata.h inc/MantidVatesAPI/FilteringUpdateProgressAction.h -inc/MantidVatesAPI/GeometryPresenter.h inc/MantidVatesAPI/GeometryView.h inc/MantidVatesAPI/LoadVTK.h inc/MantidVatesAPI/MDEWEventNexusLoadingPresenter.h @@ -98,7 +93,6 @@ inc/MantidVatesAPI/NullPeaksPresenterVsi.h inc/MantidVatesAPI/PeaksPresenterVsi.h inc/MantidVatesAPI/ProgressAction.h inc/MantidVatesAPI/SQWLoadingPresenter.h -inc/MantidVatesAPI/SynchronisingGeometryPresenter.h inc/MantidVatesAPI/ThresholdRange.h inc/MantidVatesAPI/TimeStepToTimeStep.h inc/MantidVatesAPI/TimeToTimeStep.h @@ -139,7 +133,6 @@ test/vtkDataSetToWsNameTest.h test/vtkDataSetToWsLocationTest.h test/ADSWorkspaceProviderTest.h test/BoxInfoTest.h -test/DimensionPresenterTest.h test/EventNexusLoadingPresenterTest.h test/vtkDataSetFactoryTest.h test/vtkDataSetToGeometryTest.h @@ -168,7 +161,6 @@ test/MetadataJsonManagerTest.h test/MetadataToFieldDataTest.h test/NormalizationTest.h test/SQWLoadingPresenterTest.h -test/SynchronisingGeometryPresenterTest.h test/TimeStepToTimeStepTest.h test/TimeToTimeStepTest.h test/UserDefinedThresholdRangeTest.h diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionPresenter.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionPresenter.h deleted file mode 100644 index 2943a50a9d4..00000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionPresenter.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef DIMENSION_PRESENTER_H_ -#define DIMENSION_PRESENTER_H_ -#include "MantidKernel/System.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" -#include "MantidVatesAPI/GeometryPresenter.h" -#include "MantidVatesAPI/DimensionView.h" - -namespace Mantid -{ - namespace VATES - { - - /** @class DimensionPresenter - - MVP presenter for a IMDDimension model. - - @author Owen Arnold, Tessella Support Services plc - @date 24/05/2011 - - Copyright © 2007-11 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid>. - Code Documentation is available at: <http://doxygen.mantidproject.org> - */ - class DimensionView; - class DLLExport DimensionPresenter - { - public: - DimensionPresenter(DimensionView* view, GeometryPresenter * geometryPresenter); - void acceptModelStrongly(Mantid::Geometry::IMDDimension_sptr model); - void acceptModelWeakly(Mantid::Geometry::IMDDimension_sptr model); - void acceptAppliedModel(); - void updateModel(); - Mantid::Geometry::IMDDimension_sptr getAppliedModel() const; - Mantid::Geometry::IMDDimension_sptr getModel() const; - Mantid::Geometry::VecIMDDimension_sptr getNonIntegratedDimensions() const; - std::string getVisDimensionName() const; - std::string getLabel() const; - void updateIfNotIntegrated(); - virtual ~DimensionPresenter(); - GeometryPresenter::MappingType getMappings() const; - void setMapping(std::string mapping); - std::string getMapping() const; - void setViewMode(BinDisplay mode); - private: - void commonSetup(); - DimensionPresenter(const DimensionPresenter&); - DimensionPresenter& operator=(const DimensionPresenter&); - void validate() const; - - /// Core model of MVP - Mantid::Geometry::IMDDimension_sptr m_model; - - /// Core parent geometry presenter in MVP. - GeometryPresenter * m_geometryPresenter; - - /// Core MVP view. - DimensionView* m_view; - - /// Flag capturing the last state of the isIntegrated flag. Used for comparisons. - bool m_lastIsIntegrated; - - /// Mapping name. - std::string m_mapping; - }; - } -} -#endif diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionView.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionView.h deleted file mode 100644 index e068c5472a6..00000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/DimensionView.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef DIMENSION_VIEW_H_ -#define DIMENSION_VIEW_H_ -#include "MantidKernel/System.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" - -namespace Mantid -{ - namespace VATES - { - /// Enum describing the type of display to use - enum BinDisplay{LowHighStep, Simple}; - - /// Forward delaration - class DimensionPresenter; - - /** - class DimensionView - Abstract Dimension View. View in MVP pattern. - */ - class DLLExport DimensionView - { - public: - virtual void configureStrongly() = 0; - virtual void configureWeakly() = 0; - virtual void showAsNotIntegrated(Mantid::Geometry::VecIMDDimension_sptr nonIntegratedDims) = 0; - virtual void showAsIntegrated() = 0; - virtual void displayError(std::string message) const = 0; - virtual void accept(DimensionPresenter* pDimensionPresenter) = 0; //TODO should accept non-deleting unique pointer. - virtual std::string getVisDimensionName() const = 0; - virtual coord_t getMaximum() const = 0; - virtual coord_t getMinimum() const = 0; - virtual unsigned int getNBins() const = 0; - virtual unsigned int getSelectedIndex() const = 0; - virtual bool getIsIntegrated() const = 0; - virtual void setViewMode(BinDisplay mode) = 0; - virtual ~DimensionView() {}; - }; - } -} - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GeometryPresenter.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GeometryPresenter.h deleted file mode 100644 index 0bd5ebd3793..00000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GeometryPresenter.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef GEOMETRY_PRESENTER_H -#define GEOMETRY_PRESENTER_H - -#include "MantidKernel/System.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" -#include <map> - -namespace Mantid -{ - namespace VATES - { - class GeometryView; - class DimensionView; - class DimensionPresenter; - - /** @class GeometryPresenter - - Abstract type for MVP style presenter for a Multi-dimensional workspace geometry. - - @author Owen Arnold, Tessella Support Services plc - @date 24/05/2011 - - Copyright © 2007-11 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid>. - Code Documentation is available at: <http://doxygen.mantidproject.org> - */ - - - class DimensionPresenter; - class DLLExport GeometryPresenter - { - public: - typedef std::map<std::string, boost::shared_ptr<DimensionPresenter> > MappingType; - virtual void dimensionResized(DimensionPresenter* pDimensionPresenter) = 0; - virtual void dimensionRealigned(DimensionPresenter* pDimensionPresenter) = 0; - virtual Mantid::Geometry::VecIMDDimension_sptr getNonIntegratedDimensions() const = 0; - virtual MappingType getMappings() const = 0; - virtual std::string getGeometryXML() const = 0; - virtual ~GeometryPresenter() {} - virtual void acceptView(GeometryView*)=0; - virtual void setModified() = 0; - virtual void setDimensionModeChanged() = 0; - }; - } -} - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/SynchronisingGeometryPresenter.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/SynchronisingGeometryPresenter.h deleted file mode 100644 index 6ac4779145d..00000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/SynchronisingGeometryPresenter.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef SYNCHRONISING_GEOMETRY_PRESENTER_H_ -#define SYNCHRONISING_GEOMETRY_PRESENTER_H_ - -#include "MantidGeometry/MDGeometry/MDGeometryXMLParser.h" -#include "MantidVatesAPI/GeometryPresenter.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" -#include "MantidVatesAPI/DimensionView.h" - -namespace Mantid -{ - namespace VATES - { - //Forward dec - class DimensionPresenter; - - typedef boost::shared_ptr<DimensionPresenter> DimPresenter_sptr; - - typedef std::vector<DimPresenter_sptr> VecDimPresenter_sptr; - - /** @class SynchronisingGeometryPresenter - - Concrete type for MVP style presenter for a Multi-dimensional workspace geometry. This implementation synchronises changes between non-integrated and integrated dimensions. - contains knowledge on what should happen as non-integrated dimensions are collapsed and vica-versa. - - @author Owen Arnold, Tessella Support Services plc - @date 24/05/2011 - - Copyright © 2007-8 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid>. - Code Documentation is available at: <http://doxygen.mantidproject.org> - */ - class DLLExport SynchronisingGeometryPresenter : public GeometryPresenter - { - public: - - SynchronisingGeometryPresenter(Mantid::Geometry::MDGeometryXMLParser& source); - - void dimensionResized(DimensionPresenter* pDimensionPresenter); - - void dimensionRealigned(DimensionPresenter* pDimensionPresenter); - - Mantid::Geometry::VecIMDDimension_sptr getNonIntegratedDimensions() const; - - Mantid::Geometry::VecIMDDimension_sptr getIntegratedDimensions() const; - - MappingType getMappings() const; - - std::string getGeometryXML() const; - - ~SynchronisingGeometryPresenter(); - - void acceptView(GeometryView*); - - void setModified(); - - void setDimensionModeChanged(); - - //Constant reference name for an X-AXIS - const std::string X_AXIS; - //Constant reference name for an Y-AXIS - const std::string Y_AXIS; - //Constant reference name for an Z-AXIS - const std::string Z_AXIS; - //Constant reference name for an T-AXIS - const std::string T_AXIS; - - private: - - void swap(const GeometryPresenter::MappingType::key_type& keyA, const GeometryPresenter::MappingType::key_type& keyB); - - bool hasXDim() const; - - bool hasYDim() const; - - bool hasZDim() const; - - bool hasTDim() const; - - bool isXDimensionPresenter(DimPresenter_sptr dimensionPresenter) const; - - bool isYDimensionPresenter(DimPresenter_sptr dimensionPresenter) const; - - bool isZDimensionPresenter(DimPresenter_sptr dimensionPresenter) const; - - bool isTDimensionPresenter(DimPresenter_sptr dimensionPresenter) const; - - void shuffleMappedPresenters(); - - void eraseMappedPresenter(DimPresenter_sptr); - - void insertMappedPresenter(DimPresenter_sptr); - - void dimensionExpanded(DimensionPresenter* pDimensionPresenter); - - /// Disabled copy constructor - SynchronisingGeometryPresenter(const SynchronisingGeometryPresenter&); - /// Disabled assignement operator - SynchronisingGeometryPresenter& operator=(const SynchronisingGeometryPresenter&); - /// Collection of synchronised non-integrated dimensions. - mutable Mantid::Geometry::VecIMDDimension_sptr m_dimensions; - /// Original geometry model/source. - Mantid::Geometry::MDGeometryXMLParser m_source; - /// The View with which the presenter will be bound. - GeometryView* m_view; - /// Map containing pairs of visdimensionnames to dimension presenters. - MappingType m_mapping; - /// Current bin display mode - BinDisplay m_binDisplayMode; - protected: - - virtual void dimensionCollapsed(DimensionPresenter* pDimensionPresenter); - - /// Collection of individual dimension presenters owned by this geometry presenter. - VecDimPresenter_sptr m_dimPresenters; - }; - } -} - -#endif \ No newline at end of file diff --git a/Code/Mantid/Vates/VatesAPI/src/DimensionPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/DimensionPresenter.cpp deleted file mode 100644 index 25c10bb0f0f..00000000000 --- a/Code/Mantid/Vates/VatesAPI/src/DimensionPresenter.cpp +++ /dev/null @@ -1,224 +0,0 @@ -#include "MantidVatesAPI/DimensionPresenter.h" -#include "MantidGeometry/MDGeometry/IMDDimensionFactory.h" - -namespace Mantid -{ - namespace VATES - { - /** - Constructor - @param view : MVP view. - @param geometryPresenter : parent presenter wrapping all dimensions. - */ - DimensionPresenter::DimensionPresenter(DimensionView* view, GeometryPresenter * geometryPresenter) : m_geometryPresenter(geometryPresenter), m_view(view), m_lastIsIntegrated(false) - { - } - - /** - Accept a model. In this schenario the model overrules any settings on the view. - @param model : The model to manage/contain. - */ - void DimensionPresenter::acceptModelStrongly(Mantid::Geometry::IMDDimension_sptr model) - { - m_model = model; - m_view->configureStrongly(); - commonSetup(); - } - - /** - Accept a model. In this schenario the model does not overrule settings on the view relating to nbins/max/mins. - @param model : The model to manage/contain. - */ - void DimensionPresenter::acceptModelWeakly(Mantid::Geometry::IMDDimension_sptr model) - { - m_model = model; - m_view->configureWeakly(); - commonSetup(); - } - - void DimensionPresenter::commonSetup() - { - if(m_model->getIsIntegrated()) - { - m_view->showAsIntegrated(); - m_lastIsIntegrated = true; - } - else - { - m_view->showAsNotIntegrated(m_geometryPresenter->getNonIntegratedDimensions()); - m_lastIsIntegrated = false; - } - } - - /** - Accept the applied model. i.e. Model -> AppliedModel - */ - void DimensionPresenter::acceptAppliedModel() - { - m_model = this->getAppliedModel(); - } - - /** - Callable method from the view. Determines what to do after the view is updated in some manner. - */ - void DimensionPresenter::updateModel() - { - validate(); - bool isIntegrated = m_view->getIsIntegrated(); - std::string mapping = m_view->getVisDimensionName(); - if(isIntegrated != m_lastIsIntegrated) - { - //Dimension must have been collapsed/integrated. - m_geometryPresenter->dimensionResized(this); - m_lastIsIntegrated = isIntegrated; - } - else if(mapping != this->m_mapping) - { - //Dimensions must have been swapped. - m_geometryPresenter->dimensionRealigned(this); - } - if(isIntegrated) - { - m_view->showAsIntegrated(); - } - else - { - m_view->showAsNotIntegrated(m_geometryPresenter->getNonIntegratedDimensions()); - } - m_geometryPresenter->setModified(); - } - - /** - Update the view only if it is displaying for non-integrated. - */ - void DimensionPresenter::updateIfNotIntegrated() - { - if(!m_view->getIsIntegrated()) - { - m_view->configureWeakly(); - m_view->showAsNotIntegrated(m_geometryPresenter->getNonIntegratedDimensions()); - m_lastIsIntegrated = false; - } - } - - /** - Getter for the applied model. This is the base model + any changes taken from the view. - @return applied model. - */ - Mantid::Geometry::IMDDimension_sptr DimensionPresenter::getAppliedModel() const - { - validate(); - bool isIntegrated = m_view->getIsIntegrated(); - unsigned int nbins; - if(!isIntegrated) //TODO. Needs cleaning up! - { - if(m_view->getNBins() > 1) - { - nbins = m_view->getNBins(); - } - else - { - nbins = 10; - } - } - else - { - nbins = 1; - } - - auto min = m_view->getMinimum(); - auto max = m_view->getMaximum(); - try - { - return Mantid::Geometry::createDimension(m_model->toXMLString(), nbins, min, max); - } - catch(std::invalid_argument&) - { - m_view->configureStrongly(); - m_view->displayError("Check the ranges just entered. Must have min < max."); - return m_model; - } - } - - /** - Getter for the MVP model. - @return read-only model to visualise. - */ - Mantid::Geometry::IMDDimension_sptr DimensionPresenter::getModel() const - { - validate(); - return m_model; - } - - /// Destructor - DimensionPresenter::~DimensionPresenter() - { - } - - /** - Validate the usage of the presenter. - */ - void DimensionPresenter::validate() const - { - if(m_model.get() == NULL) - { - throw std::runtime_error("Trying to use DimensionPresenter without calling ::acceptModel first"); - } - } - - /** - Getter for the label to use for this presenter. - @return applied label. - */ - std::string DimensionPresenter::getLabel() const - { - return this->m_model->getDimensionId(); - } - - /** - Getter for the name of the visualisation dimension. - @return name of the visualisation dimension this presenter is using (if any) - */ - std::string DimensionPresenter::getVisDimensionName() const - { - return m_view->getVisDimensionName(); - } - - /** - Pass through method. Gets all mapping-presenter pairs. - @return mapping pairs. - */ - GeometryPresenter::MappingType DimensionPresenter::getMappings() const - { - return m_geometryPresenter->getMappings(); - } - - /** - Setter for the mapping to use. - @param mapping to use. - */ - void DimensionPresenter::setMapping(std::string mapping) - { - this->m_mapping = mapping; - } - - /** - Getter for the mapping to use. - @return mapping used. - */ - std::string DimensionPresenter::getMapping() const - { - return m_mapping; - } - - /** - Setter for the bin display mode. - @param mode : Bin display mode. - */ - void DimensionPresenter::setViewMode(BinDisplay mode) - { - this->m_view->setViewMode(mode); - } - - } -} diff --git a/Code/Mantid/Vates/VatesAPI/src/SynchronisingGeometryPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/SynchronisingGeometryPresenter.cpp deleted file mode 100644 index cbc920dca15..00000000000 --- a/Code/Mantid/Vates/VatesAPI/src/SynchronisingGeometryPresenter.cpp +++ /dev/null @@ -1,498 +0,0 @@ -#include "MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h" -#include "MantidVatesAPI/SynchronisingGeometryPresenter.h" -#include "MantidVatesAPI/DimensionPresenter.h" -#include "MantidVatesAPI/DimensionView.h" -#include "MantidVatesAPI/GeometryView.h" -#include <algorithm> - - -using Mantid::Geometry::IMDDimension_sptr; -using Mantid::Geometry::VecIMDDimension_sptr; -typedef Mantid::VATES::GeometryPresenter::MappingType MappingType; - -namespace Mantid -{ - namespace VATES - { - - /// Comparitor to find integrated dimensions. - struct FindIntegrated : public std::unary_function <IMDDimension_sptr, bool> - { - bool operator ()(const IMDDimension_sptr obj) const - { - return obj->getIsIntegrated(); - } - }; - - /// Comparitor to find DimensionPresenter shared pointers via a dimension id. - struct FindId : public std::unary_function <DimPresenter_sptr, bool> - { - const std::string m_id; - FindId(const std::string &id) : m_id(id){ } - - bool operator ()(const DimPresenter_sptr obj) const - { - return m_id == obj->getModel()->getDimensionId(); - } - FindId& operator=(const FindId&); - }; - - /// Comparitor to find IMDDimension shared pointers via a dimension id. - struct FindModelId : public std::unary_function <IMDDimension_sptr, bool> - { - const std::string m_id; - FindModelId(const std::string &id) : m_id(id){ } - - bool operator ()(const IMDDimension_sptr obj) const - { - return m_id == obj->getDimensionId(); - } - FindModelId& operator=(const FindModelId&); - }; - - /** - Constructor - */ - SynchronisingGeometryPresenter::SynchronisingGeometryPresenter(Mantid::Geometry::MDGeometryXMLParser& source) : - X_AXIS("X-AXIS"), - Y_AXIS("Y-AXIS"), - Z_AXIS("Z-AXIS"), - T_AXIS("T-AXIS"), - m_dimensions(source.getAllDimensions()), - m_source(source), - m_view(NULL), - m_binDisplayMode(Simple) - { - - } - - /** - Destructor - */ - SynchronisingGeometryPresenter::~SynchronisingGeometryPresenter() - { - } - - void SynchronisingGeometryPresenter::swap(const GeometryPresenter::MappingType::key_type& keyA, const GeometryPresenter::MappingType::key_type& keyB) - { - DimPresenter_sptr temp = m_mapping[keyA]; - - //Swap items in mapping list. - m_mapping[keyA] = m_mapping[keyB]; - m_mapping[keyB] = temp; - - //Set mapping name of presenter and then force view to update. - if(NULL != m_mapping[keyA]) - { - m_mapping[keyA]->setMapping(keyA); - m_mapping[keyA]->acceptModelWeakly(m_mapping[keyA]->getModel()); - } - //Set mapping name of presenter and then force view to update. - if(NULL != m_mapping[keyB]) - { - m_mapping[keyB]->setMapping(keyB); - m_mapping[keyB]->acceptModelWeakly(m_mapping[keyB]->getModel()); - } - } - - /** - Handles dimension realignment. When a dimension presenter is handling a realignment, its is necessary for this to be synchronsied with other non-integrated dimensions. - @param pDimensionPresenter : dimension presenter on which realignement has been requested. - */ - void SynchronisingGeometryPresenter::dimensionRealigned(DimensionPresenter* pDimensionPresenter) - { - swap(pDimensionPresenter->getMapping(), pDimensionPresenter->getVisDimensionName()); - } - - /** - Ensure that for non-integrated dimensions, mappings are always occupied in the priority x before y before z before t. - */ - void SynchronisingGeometryPresenter::shuffleMappedPresenters() - { - DimPresenter_sptr temp; - if(hasYDim() && !hasXDim()) - { - swap(X_AXIS, Y_AXIS); - eraseMappedPresenter(m_mapping[Y_AXIS]); - } - if(hasZDim() && !hasYDim()) - { - swap(Y_AXIS, Z_AXIS); - eraseMappedPresenter(m_mapping[Z_AXIS]); - } - if(hasTDim() && !hasZDim()) - { - swap(T_AXIS, Z_AXIS); - eraseMappedPresenter(m_mapping[T_AXIS]); - } - } - - /** - Ensure that for the collaped mapeed dimension, it's mapped placeholder is erased (marked as empty). - @param expiredMappedDimension : mapped dimension presenter which has been collapsed, and may currently occupy a x, y, z, t mapping. - */ - void SynchronisingGeometryPresenter::eraseMappedPresenter(DimPresenter_sptr expiredMappedDimension) - { - if(NULL != expiredMappedDimension) - { - m_mapping.erase(expiredMappedDimension->getMapping()); - } - } - - /** - With the priority mapping of x before y, y before z, and z before t. Ensure that a candidate mapped dimension presenter is set to occupy a vacent mapping. - @param candidateMappedDimension : Dimension presenter to which a mapping is requested. - */ - void SynchronisingGeometryPresenter::insertMappedPresenter(DimPresenter_sptr candidateMappedDimension) - { - /* - Check to see whether there is already a mapping for this presenter. If there is, don't create another one! - */ - bool bAlreadyMapped = false; - for (MappingType::iterator it = m_mapping.begin(); it != m_mapping.end(); ++it) - { - if (it->second == candidateMappedDimension) - { - bAlreadyMapped = true; - break; - } - } - if(!bAlreadyMapped) - { - if(!this->hasXDim()) - { - m_mapping.insert(std::make_pair(X_AXIS, candidateMappedDimension)); - candidateMappedDimension->setMapping(X_AXIS); - } - else if(!this->hasYDim()) - { - m_mapping.insert(std::make_pair(Y_AXIS, candidateMappedDimension)); - candidateMappedDimension->setMapping(Y_AXIS); - } - else if(!hasZDim()) - { - m_mapping.insert(std::make_pair(Z_AXIS, candidateMappedDimension)); - candidateMappedDimension->setMapping(Z_AXIS); - } - else if(!hasTDim()) - { - m_mapping.insert(std::make_pair(T_AXIS, candidateMappedDimension)); - candidateMappedDimension->setMapping(T_AXIS); - } - } - } - - /** - Handles the change of a managed dimension presenter to be expanded (from collapsed). - @param pDimensionPresenter : dimension which is now expanded. - */ - void SynchronisingGeometryPresenter::dimensionExpanded(DimensionPresenter* pDimensionPresenter) - { - //Replace the old dimension with the new/modified one. - std::replace_if(m_dimensions.begin(), m_dimensions.end(), FindModelId(pDimensionPresenter->getAppliedModel()->getDimensionId()), pDimensionPresenter->getAppliedModel()); - //Insert an axis-mapping for this expanded dimension. - VecDimPresenter_sptr::iterator location = std::find_if(m_dimPresenters.begin(), m_dimPresenters.end(), FindId(pDimensionPresenter->getAppliedModel()->getDimensionId())); - if (location != m_dimPresenters.end()) - { - insertMappedPresenter((*location)); - } - shuffleMappedPresenters(); - - } - - /** - Handles the change of a managed dimension presenter to be collapsed (from expanded). - @param pDimensionPresenter : dimension which is now collapsed. - */ - void SynchronisingGeometryPresenter::dimensionCollapsed(DimensionPresenter* pDimensionPresenter) - { - //Effectively end the transaction if it will result in zero non-integrated dimensions - if(1 == getNonIntegratedDimensions().size()) - { - throw std::invalid_argument("Cannot have all dimensions integrated!"); - } - //Replace the old dimension with the new/modified one. - std::replace_if(m_dimensions.begin(), m_dimensions.end(), FindModelId(pDimensionPresenter->getAppliedModel()->getDimensionId()), pDimensionPresenter->getAppliedModel()); - //DONOT ERRASE THE MAPPING. - shuffleMappedPresenters(); - - } - - /** - Handles dimension resize request. Can either be collapsed or expanded. This is worked out internally. - @param pDimensionPresenter : dimension which is now collapsed/expanded. - */ - void SynchronisingGeometryPresenter::dimensionResized(DimensionPresenter* pDimensionPresenter) - { - bool nowIntegrated = pDimensionPresenter->getAppliedModel()->getNBins() == 1; - if(nowIntegrated) - { - dimensionCollapsed(pDimensionPresenter); - } - else - { - dimensionExpanded(pDimensionPresenter); - } - - //For non integrated dimension presenter. Lists of possible non-interated dimensions to switch to must be updated. - for(unsigned int i = 0; i < m_dimPresenters.size(); i++) - { - m_dimPresenters[i]->updateIfNotIntegrated(); - } - pDimensionPresenter->acceptAppliedModel(); - } - - /** - Getter for non-integrated dimensions. - @return collection of non-integrated dimensions. - */ - Mantid::Geometry::VecIMDDimension_sptr SynchronisingGeometryPresenter::getNonIntegratedDimensions() const - { - VecIMDDimension_sptr matches; - VecIMDDimension_sptr::iterator i = m_dimensions.begin(); - FindIntegrated findIntegrated; - std::unary_negate<FindIntegrated> findNotIntegrated(findIntegrated); - while(true) - { - i = std::find_if(i, m_dimensions.end(), findNotIntegrated); - if (i == m_dimensions.end()) - break; - matches.push_back(*i); - ++i; - } - return matches; - } - - /** - Getter for integrated dimensions. - @return collection of non-integrated dimensions. - */ - Mantid::Geometry::VecIMDDimension_sptr SynchronisingGeometryPresenter::getIntegratedDimensions() const - { - VecIMDDimension_sptr matches; - VecIMDDimension_sptr::iterator i = m_dimensions.begin(); - FindIntegrated findIntegrated; - while(true) - { - i = std::find_if(i, m_dimensions.end(), findIntegrated); - if (i == m_dimensions.end()) - break; - matches.push_back(*i); - ++i; - } - return matches; - } - - /** - Getter for the geometry xml. - @return GeometryXML in string format. - */ - std::string SynchronisingGeometryPresenter::getGeometryXML() const - { - //Get the selected alignment for the xdimension. - using namespace Mantid::Geometry; - MDGeometryBuilderXML<NoDimensionPolicy> xmlBuilder; - - VecIMDDimension_sptr vecIntegrated = getIntegratedDimensions(); - VecDimPresenter_sptr::const_iterator its = m_dimPresenters.begin(); - for(;its != m_dimPresenters.end(); ++its) - { - if((*its)->getAppliedModel()->getIsIntegrated()) - { - xmlBuilder.addOrdinaryDimension((*its)->getAppliedModel()); - } - } - - if(hasXDim()) - { - xmlBuilder.addXDimension(m_mapping.at(X_AXIS)->getAppliedModel()); - } - if(hasYDim()) - { - xmlBuilder.addYDimension(m_mapping.at(Y_AXIS)->getAppliedModel()); - } - if(hasZDim()) - { - xmlBuilder.addZDimension(m_mapping.at(Z_AXIS)->getAppliedModel()); - } - if(hasTDim()) - { - xmlBuilder.addTDimension(m_mapping.at(T_AXIS)->getAppliedModel()); - } - return xmlBuilder.create().c_str(); - } - - /** - SynchronisingGeometryPresenter are constructed without first knowing the view they manage. They must be dispatched with the - view instance they both belong to (GeometryViews own GeometryPresenters) and can direct (GeometryPresenters direct GeometryViews MVP). - - i) Uses factory provided by GeometryView to generate DimensionViews. - ii) Creates a DimensionPresenter for each of those views and binds the pair together. (although DimensionPresenters are owned by this and DimensionViews are owned by GeometryViews) - iv) Replicates the mappings on the original source input. These are read/writable at a later point. - - @param view : the GeoemtryView to direct. - */ - void SynchronisingGeometryPresenter::acceptView(GeometryView* view) - { - m_view = view; - m_binDisplayMode = m_view->getBinDisplayMode(); - const DimensionViewFactory& factory = m_view->getDimensionViewFactory(); - Mantid::Geometry::VecIMDDimension_sptr vecAllDimensions = m_source.getAllDimensions(); - - for(size_t i =0; i < vecAllDimensions.size(); i++) - { - DimensionView* dimView = factory.create(); - DimPresenter_sptr dimPresenter(new DimensionPresenter(dimView, this)); - - Mantid::Geometry::IMDDimension_sptr model = vecAllDimensions[i]; - - if(m_source.isXDimension(model)) - { - dimPresenter->setMapping(X_AXIS); - m_mapping.insert(std::make_pair(X_AXIS, dimPresenter)); - } - else if(m_source.isYDimension(model)) - { - dimPresenter->setMapping(Y_AXIS); - m_mapping.insert(std::make_pair(Y_AXIS, dimPresenter)); - } - else if(m_source.isZDimension(model)) - { - dimPresenter->setMapping(Z_AXIS); - m_mapping.insert(std::make_pair(Z_AXIS, dimPresenter)); - } - else if(m_source.isTDimension(model)) - { - dimPresenter->setMapping(T_AXIS); - m_mapping.insert(std::make_pair(T_AXIS, dimPresenter)); - } - - // Dimension View must have reference to Dimension Presenter. - dimView->accept(dimPresenter.get()); - // Geometry View owns the Dimension View. - m_view->addDimensionView(dimView); - // Presenters are mainatined internally. - m_dimPresenters.push_back(dimPresenter); - } - for(size_t i = 0; i < m_dimPresenters.size(); i++) - { - //Now that all presenters have views, models can be provided to complete the M-V-P chain. - m_dimPresenters[i]->acceptModelStrongly(m_source.getAllDimensions()[i]); - } - } - - /** - Determine whether x dimension mapping is available. - @return true if target mapping is available. - */ - bool SynchronisingGeometryPresenter::hasXDim() const - { - return m_mapping.find(X_AXIS) != m_mapping.end() && NULL != m_mapping.find(X_AXIS)->second; - } - - /** - Determine whether y dimension mapping is available. - @return true if target mapping is available. - */ - bool SynchronisingGeometryPresenter::hasYDim() const - { - return m_mapping.find(Y_AXIS) != m_mapping.end() && NULL != m_mapping.find(Y_AXIS)->second; - } - - /** - Determine whether z dimension mapping is available. - @return true if target mapping is available. - */ - bool SynchronisingGeometryPresenter::hasZDim() const - { - return m_mapping.find(Z_AXIS) != m_mapping.end() && NULL != m_mapping.find(Z_AXIS)->second; - } - - /** - Determine whether t dimension mapping is available. - @return true if target mapping is available. - */ - bool SynchronisingGeometryPresenter::hasTDim() const - { - return m_mapping.find(T_AXIS) != m_mapping.end() && NULL != m_mapping.find(T_AXIS)->second; - } - - /** - Pass though method indicating to the view that modifications have occured. - */ - void SynchronisingGeometryPresenter::setModified() - { - m_view->raiseModified(); - } - - /** - Setter to indicate changes to the display mode. - */ - void SynchronisingGeometryPresenter::setDimensionModeChanged() - { - //Get the actual requested display mode. - BinDisplay temp = m_view->getBinDisplayMode(); - if(temp != m_binDisplayMode) - { - m_binDisplayMode = temp; - VecDimPresenter_sptr::iterator it = m_dimPresenters.begin(); - while(it != m_dimPresenters.end()) - { - //Delegate the work of applying the changes to each DimensionPresenter. - (*it)->setViewMode(m_binDisplayMode); - ++it; - } - } - } - - /** - Determine if dimension presenter is mapped to x axis. - @param dimensionPresenter : The dimension presenter to which the comparison should be made. - @return true if dimesion presenter matches exising mapping. - */ - bool SynchronisingGeometryPresenter::isXDimensionPresenter(DimPresenter_sptr dimensionPresenter) const - { - return dimensionPresenter == m_mapping.at(X_AXIS); - } - - /** - Determine if dimension presenter is mapped to y axis. - @param dimensionPresenter : The dimension presenter to which the comparison should be made. - @return true if dimesion presenter matches exising mapping. - */ - bool SynchronisingGeometryPresenter::isYDimensionPresenter(DimPresenter_sptr dimensionPresenter) const - { - return dimensionPresenter == m_mapping.at(Y_AXIS); - } - - /** - Determine if dimension presenter is mapped to z axis. - @param dimensionPresenter : The dimension presenter to which the comparison should be made. - @return true if dimesion presenter matches exising mapping. - */ - bool SynchronisingGeometryPresenter::isZDimensionPresenter(DimPresenter_sptr dimensionPresenter) const - { - return dimensionPresenter == m_mapping.at(Z_AXIS); - } - - /** - Determine if dimension presenter is mapped to t axis. - @param dimensionPresenter : The dimension presenter to which the comparison should be made. - @return true if dimesion presenter matches exising mapping. - */ - bool SynchronisingGeometryPresenter::isTDimensionPresenter(DimPresenter_sptr dimensionPresenter) const - { - return dimensionPresenter == m_mapping.at(T_AXIS); - } - - /** - Get mappings of vis diension names to dimension presenters. - @return mapping. - */ - MappingType SynchronisingGeometryPresenter::getMappings() const - { - return m_mapping; - } - - } -} diff --git a/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h b/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h deleted file mode 100644 index 3285bebef6d..00000000000 --- a/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h +++ /dev/null @@ -1,297 +0,0 @@ -#ifndef DIMENSION_PRESENTER_TEST_H_ -#define DIMENSION_PRESENTER_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include "MantidVatesAPI/DimensionPresenter.h" -#include "MantidVatesAPI/GeometryPresenter.h" -#include "MantidVatesAPI/DimensionView.h" -#include "MantidGeometry/MDGeometry/MDTypes.h" -#include "MantidKernel/UnitLabel.h" -#include "gtest/gtest.h" -#include "gmock/gmock.h" - -using namespace Mantid; -using namespace Mantid::VATES; -using namespace Mantid::Geometry; -using namespace testing; - -class DimensionPresenterTest : public CxxTest::TestSuite { -private: - class MockDimensionView : public DimensionView { - public: - MOCK_METHOD0(configureStrongly, void()); - MOCK_METHOD0(configureWeakly, void()); - MOCK_METHOD1(showAsNotIntegrated, void(VecIMDDimension_sptr)); - MOCK_METHOD0(showAsIntegrated, void()); - MOCK_METHOD1(accept, void(DimensionPresenter *)); - MOCK_CONST_METHOD0(getMinimum, float()); - MOCK_CONST_METHOD0(getMaximum, float()); - MOCK_CONST_METHOD0(getNBins, unsigned int()); - MOCK_CONST_METHOD0(getSelectedIndex, unsigned int()); - MOCK_CONST_METHOD0(getIsIntegrated, bool()); - MOCK_CONST_METHOD0(getVisDimensionName, std::string()); - MOCK_CONST_METHOD1(displayError, void(std::string)); - MOCK_METHOD1(setViewMode, void(Mantid::VATES::BinDisplay)); - ~MockDimensionView(){}; - }; - - class MockGeometryPresenter : public GeometryPresenter { - public: - MOCK_METHOD1(dimensionRealigned, void(DimensionPresenter *)); - MOCK_METHOD1(dimensionResized, void(DimensionPresenter *)); - MOCK_CONST_METHOD0(getNonIntegratedDimensions, VecIMDDimension_sptr()); - MOCK_CONST_METHOD0(getGeometryXML, std::string()); - MOCK_METHOD1(acceptView, void(GeometryView *)); - MOCK_METHOD0(setModified, void()); - MOCK_METHOD0(setDimensionModeChanged, void()); - MOCK_CONST_METHOD0(getMappings, GeometryPresenter::MappingType()); - ~MockGeometryPresenter() {} - }; - - /// Mock IMDDimension allows tests to specify exact expected behavior of - /// dependency. - class MockIMDDimension : public IMDDimension { - public: - MOCK_CONST_METHOD0(getName, std::string()); - MOCK_CONST_METHOD0(getUnits, const Mantid::Kernel::UnitLabel()); - MOCK_CONST_METHOD0(getMDFrame, const Mantid::Geometry::MDFrame &()); - MOCK_CONST_METHOD0(getMDUnits, const Mantid::Kernel::MDUnit &()); - MOCK_CONST_METHOD0(getDimensionId, std::string()); - MOCK_CONST_METHOD0(getMaximum, coord_t()); - MOCK_CONST_METHOD0(getMinimum, coord_t()); - MOCK_CONST_METHOD0(getNBins, size_t()); - MOCK_CONST_METHOD0(toXMLString, std::string()); - MOCK_CONST_METHOD0(getIsIntegrated, bool()); - MOCK_CONST_METHOD1(getX, coord_t(size_t ind)); - MOCK_METHOD3(setRange, void(size_t, coord_t, coord_t)); - }; - -public: - void testSetMapping() { - IMDDimension_sptr model(new MockIMDDimension()); - MockDimensionView view; - MockGeometryPresenter gPresenter; - DimensionPresenter presenter(&view, &gPresenter); - - TSM_ASSERT("Should have no mapping", presenter.getMapping().empty()); - - presenter.setMapping("Z-AXIS"); - TSM_ASSERT_EQUALS("Should now have mapping set", "Z-AXIS", - presenter.getMapping()); - } - - void testWithoutProperConstructionThrows() { - IMDDimension_sptr model(new MockIMDDimension()); - MockDimensionView view; - MockGeometryPresenter gPresenter; - DimensionPresenter presenter(&view, &gPresenter); - - TSM_ASSERT_THROWS("::acceptModel not called first, so should have thrown", - presenter.updateModel(), std::runtime_error); - } - - void testAcceptModelStrongly() { - MockIMDDimension *pMockDimension = new MockIMDDimension(); - EXPECT_CALL(*pMockDimension, getDimensionId()) - .Times(2) - .WillRepeatedly(Return("1")); - EXPECT_CALL(*pMockDimension, getIsIntegrated()).Times(1); - IMDDimension_sptr model(pMockDimension); - - MockDimensionView view; - EXPECT_CALL(view, configureStrongly()).Times(1); - EXPECT_CALL(view, showAsNotIntegrated(_)).Times(1); - - MockGeometryPresenter gPresenter; - EXPECT_CALL(gPresenter, getNonIntegratedDimensions()) - .Times(1) - .WillOnce(Return(VecIMDDimension_sptr())); - - DimensionPresenter presenter(&view, &gPresenter); - presenter.acceptModelStrongly(model); - - TSM_ASSERT_EQUALS("Applied model should be the same as the one provided", - model->getDimensionId(), - presenter.getModel()->getDimensionId()); - TS_ASSERT(Mock::VerifyAndClearExpectations(pMockDimension)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&view)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gPresenter)); - } - - void testAcceptModelWeakly() { - MockIMDDimension *pMockDimension = new MockIMDDimension(); - EXPECT_CALL(*pMockDimension, getDimensionId()) - .Times(2) - .WillRepeatedly(Return("1")); - EXPECT_CALL(*pMockDimension, getIsIntegrated()).Times(1); - IMDDimension_sptr model(pMockDimension); - - MockDimensionView view; - EXPECT_CALL(view, configureWeakly()).Times(1); - EXPECT_CALL(view, showAsNotIntegrated(_)).Times(1); - - MockGeometryPresenter gPresenter; - EXPECT_CALL(gPresenter, getNonIntegratedDimensions()) - .Times(1) - .WillOnce(Return(VecIMDDimension_sptr())); - - DimensionPresenter presenter(&view, &gPresenter); - presenter.acceptModelWeakly(model); - - TSM_ASSERT_EQUALS("Applied model should be the same as the one provided", - model->getDimensionId(), - presenter.getModel()->getDimensionId()); - TS_ASSERT(Mock::VerifyAndClearExpectations(pMockDimension)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&view)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gPresenter)); - } - - void testDriveViewToBeIntegrated() { - MockDimensionView view; - EXPECT_CALL(view, configureStrongly()).Times(1); - EXPECT_CALL(view, showAsIntegrated()).Times(2); - EXPECT_CALL(view, showAsNotIntegrated(_)) - .Times(0); // Explicitly should never use this. - EXPECT_CALL(view, getIsIntegrated()).WillOnce(Return(true)); - EXPECT_CALL(view, getVisDimensionName()).Times(1); - - MockIMDDimension *pMockDimension = new MockIMDDimension(); - EXPECT_CALL(*pMockDimension, getIsIntegrated()) - .Times(1) - .WillRepeatedly(Return(true)); // Model says it's integrated - Mantid::Geometry::IMDDimension_sptr model(pMockDimension); - - MockGeometryPresenter gPresenter; - EXPECT_CALL(gPresenter, setModified()).Times(1); - - DimensionPresenter presenter(&view, &gPresenter); - presenter.acceptModelStrongly(model); - TSM_ASSERT_THROWS_NOTHING("A model exists on the presenter, updating " - "should it should operate without exception.", - presenter.updateModel()); - - TS_ASSERT(Mock::VerifyAndClearExpectations(pMockDimension)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&view)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gPresenter)); - } - - void testDriveViewToBeNotIntegrated() { - MockDimensionView view; - EXPECT_CALL(view, configureStrongly()).Times(1); - EXPECT_CALL(view, showAsNotIntegrated(_)).Times(2); - EXPECT_CALL(view, showAsIntegrated()) - .Times(0); // Explicitly should never use this - EXPECT_CALL(view, getIsIntegrated()) - .Times(AnyNumber()) - .WillRepeatedly(Return(false)); // View is not integrated. - EXPECT_CALL(view, getVisDimensionName()).Times(1); - - MockIMDDimension *pMockDimension = new MockIMDDimension(); - EXPECT_CALL(*pMockDimension, getIsIntegrated()) - .Times(AnyNumber()) - .WillRepeatedly(Return(false)); - Mantid::Geometry::IMDDimension_sptr model(pMockDimension); - - MockGeometryPresenter gPresenter; - EXPECT_CALL(gPresenter, getNonIntegratedDimensions()) - .Times(2) - .WillRepeatedly(Return(VecIMDDimension_sptr())); // Will ask the - // GeometryPresenter - // for non-integrated - // dimensions - EXPECT_CALL(gPresenter, setModified()).Times(1); - DimensionPresenter presenter(&view, &gPresenter); - presenter.acceptModelStrongly(model); - - TSM_ASSERT_THROWS_NOTHING("A model exists on the presenter, updating " - "should it should operate without exception.", - presenter.updateModel()); - TS_ASSERT(Mock::VerifyAndClearExpectations(pMockDimension)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&view)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gPresenter)); - } - - void testGetAppliedModelWhenViewIntegrated() { - MockDimensionView view; - EXPECT_CALL(view, configureStrongly()).Times(1); - EXPECT_CALL(view, showAsIntegrated()).Times(1); - EXPECT_CALL(view, getIsIntegrated()) - .Times(1) - .WillRepeatedly(Return(true)); // view says it's integrated - EXPECT_CALL(view, getMinimum()).Times(1).WillOnce(Return(0.0f)); - EXPECT_CALL(view, getMaximum()).Times(1).WillOnce(Return(2.0f)); - EXPECT_CALL(view, getNBins()).Times(0); // Should never need number of bins - // because view says it's - // integrated. - - MockIMDDimension *pMockDimension = new MockIMDDimension(); - EXPECT_CALL(*pMockDimension, getIsIntegrated()) - .Times(1) - .WillRepeatedly(Return(true)); // Model says it's integrated - EXPECT_CALL(*pMockDimension, toXMLString()) - .WillOnce( - Return("<Dimension " - "ID=\"en\"><Name>Energy</Name><UpperBounds>150</" - "UpperBounds><LowerBounds>0</LowerBounds><NumberOfBins>1</" - "NumberOfBins></Dimension>")); - Mantid::Geometry::IMDDimension_sptr model(pMockDimension); - - MockGeometryPresenter gPresenter; - - DimensionPresenter presenter(&view, &gPresenter); - presenter.acceptModelStrongly(model); - Mantid::Geometry::IMDDimension_sptr product = presenter.getAppliedModel(); - - TSM_ASSERT_EQUALS("Wrong number of bins for an integrated dimension", 1, - product->getNBins()); - TSM_ASSERT_EQUALS("Range max not set properly", 2, product->getMaximum()); - TSM_ASSERT_EQUALS("Range min not set properly", 0, product->getMinimum()); - - TS_ASSERT(Mock::VerifyAndClearExpectations(pMockDimension)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&view)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gPresenter)); - } - - void testHandleArgumentErrors() { - MockDimensionView view; - EXPECT_CALL(view, configureStrongly()).Times(AnyNumber()); - EXPECT_CALL(view, showAsIntegrated()).Times(AnyNumber()); - EXPECT_CALL(view, getIsIntegrated()) - .Times(AtLeast(1)) - .WillRepeatedly(Return(false)); // view says it's integrated - EXPECT_CALL(view, getMinimum()) - .Times(AnyNumber()) - .WillRepeatedly( - Return(10.0f)); // Ooops, min > max, this should be handled! - EXPECT_CALL(view, getMaximum()) - .Times(AnyNumber()) - .WillRepeatedly(Return(2.0f)); - EXPECT_CALL(view, getNBins()).Times(AnyNumber()); - EXPECT_CALL(view, displayError(_)).Times(1); - - MockIMDDimension *pMockDimension = new MockIMDDimension(); - EXPECT_CALL(*pMockDimension, getIsIntegrated()) - .Times(AnyNumber()) - .WillRepeatedly(Return(true)); // Model says it's integrated - EXPECT_CALL(*pMockDimension, toXMLString()) - .Times(AnyNumber()) - .WillRepeatedly( - Return("<Dimension " - "ID=\"en\"><Name>Energy</Name><UpperBounds>150</" - "UpperBounds><LowerBounds>0</LowerBounds><NumberOfBins>1</" - "NumberOfBins></Dimension>")); - Mantid::Geometry::IMDDimension_sptr model(pMockDimension); - - MockGeometryPresenter gPresenter; - - DimensionPresenter presenter(&view, &gPresenter); - presenter.acceptModelStrongly(model); - presenter.getAppliedModel(); - - TS_ASSERT(Mock::VerifyAndClearExpectations(pMockDimension)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&view)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gPresenter)); - } -}; - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/test/SynchronisingGeometryPresenterTest.h b/Code/Mantid/Vates/VatesAPI/test/SynchronisingGeometryPresenterTest.h deleted file mode 100644 index 407be0a2676..00000000000 --- a/Code/Mantid/Vates/VatesAPI/test/SynchronisingGeometryPresenterTest.h +++ /dev/null @@ -1,345 +0,0 @@ -#ifndef SYNCHRONISING_GEOMETRY_PRESENTER_TEST_H_ -#define SYNCHRONISING_GEOMETRY_PRESENTER_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include "MantidVatesAPI/SynchronisingGeometryPresenter.h" -#include "MantidVatesAPI/GeometryView.h" -#include "MantidVatesAPI/DimensionView.h" -#include "MantidGeometry/MDGeometry/MDGeometryXMLParser.h" -#include "MantidVatesAPI/DimensionPresenter.h" - -#include "gtest/gtest.h" -#include "gmock/gmock.h" - -using namespace testing; -using namespace Mantid::VATES; -using namespace Mantid::Geometry; - -class SynchronisingGeometryPresenterTest: public CxxTest::TestSuite -{ - - -private: - -static std::string constructXML(std::string nbinsA, std::string nbinsB, std::string nbinsC, std::string nbinsD, std::string nbinsE) -{ - return std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>") + - "<DimensionSet>" + - "<Dimension ID=\"en\">" + - "<Name>Energy</Name>" + - "<UpperBounds>150</UpperBounds>" + - "<LowerBounds>0</LowerBounds>" + - "<NumberOfBins>" + nbinsA + "</NumberOfBins>" + - "</Dimension>" + - "<Dimension ID=\"qx\">" + - "<Name>Qx</Name>" + - "<UpperBounds>5</UpperBounds>" + - "<LowerBounds>-1.5</LowerBounds>" + - "<NumberOfBins>" + nbinsB + "</NumberOfBins>" + - "</Dimension>" + - "<Dimension ID=\"qy\">" + - "<Name>Qy</Name>" + - "<UpperBounds>6.6</UpperBounds>" + - "<LowerBounds>-6.6</LowerBounds>" + - "<NumberOfBins>" + nbinsC + "</NumberOfBins>" + - "</Dimension>" + - "<Dimension ID=\"qz\">" + - "<Name>Qz</Name>" + - "<UpperBounds>6.6</UpperBounds>" + - "<LowerBounds>-6.6</LowerBounds>" + - "<NumberOfBins>" + nbinsD + "</NumberOfBins>" + - "</Dimension>" + - "<Dimension ID=\"other\">" + - "<Name>Other</Name>" + - "<UpperBounds>6.6</UpperBounds>" + - "<LowerBounds>-6.6</LowerBounds>" + - "<NumberOfBins>" + nbinsE + "</NumberOfBins>" + - "</Dimension>" + - "<XDimension>" + - "<RefDimensionId>qx</RefDimensionId>" + - "</XDimension>" + - "<YDimension>" + - "<RefDimensionId>qy</RefDimensionId>" + - "</YDimension>" + - "<ZDimension>" + - "<RefDimensionId>qz</RefDimensionId>" + - "</ZDimension>" + - "<TDimension>" + - "<RefDimensionId>en</RefDimensionId>" + - "</TDimension>" + - "</DimensionSet>"; - } - - static std::string constructXML() - { - return constructXML("1", "5", "5", "5", "3"); - } - - class MockGeometryView : public GeometryView - { - public: - MOCK_METHOD1(addDimensionView, void(DimensionView*)); - MOCK_CONST_METHOD0(getGeometryXMLString, std::string()); - MOCK_METHOD0(getDimensionViewFactory, const DimensionViewFactory&()); - MOCK_METHOD0(raiseModified, void()); - MOCK_METHOD0(raiseNoClipping, void()); - MOCK_CONST_METHOD0(getBinDisplayMode, BinDisplay()); - ~MockGeometryView(){} - }; - - class MockDimensionViewFactory : public DimensionViewFactory - { - public: - MOCK_CONST_METHOD0( create, DimensionView*()); - ~MockDimensionViewFactory(){} - }; - - class MockDimensionView : public DimensionView - { - public: - MOCK_METHOD0(configureStrongly, void()); - MOCK_METHOD0(configureWeakly, void()); - MOCK_METHOD1(showAsNotIntegrated, void(VecIMDDimension_sptr)); - MOCK_METHOD0(showAsIntegrated, void()); - MOCK_METHOD1(accept, void(DimensionPresenter*)); - MOCK_CONST_METHOD0(getVisDimensionName, std::string()); - MOCK_CONST_METHOD0(getMinimum, float()); - MOCK_CONST_METHOD0(getMaximum, float()); - MOCK_CONST_METHOD0(getNBins, unsigned int()); - MOCK_CONST_METHOD0(getSelectedIndex, unsigned int()); - MOCK_CONST_METHOD0(getIsIntegrated, bool()); - MOCK_CONST_METHOD1(displayError, void(std::string)); - MOCK_METHOD1(setViewMode, void(Mantid::VATES::BinDisplay)); - ~MockDimensionView(){}; - }; - - class ExposedSynchronisingGeometryPresenter : public Mantid::VATES::SynchronisingGeometryPresenter - { - public: - ExposedSynchronisingGeometryPresenter(Mantid::Geometry::MDGeometryXMLParser& source) : Mantid::VATES::SynchronisingGeometryPresenter(source) {} - Mantid::VATES::DimPresenter_sptr getDimensionPresenter(unsigned int index) - { - return m_dimPresenters[index]; - } - - void dimensionCollapsed(DimensionPresenter* pDimensionPresenter) - { - return Mantid::VATES::SynchronisingGeometryPresenter::dimensionCollapsed(pDimensionPresenter); - } - }; - -public: - - void testConstruct() - { - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - SynchronisingGeometryPresenter* pPresenter = NULL; - TS_ASSERT_THROWS_NOTHING(pPresenter = new SynchronisingGeometryPresenter(parser)); - delete pPresenter; - } - - void testAcceptView() - { - MockDimensionView dView; - EXPECT_CALL(dView, accept(_)).Times(5); - EXPECT_CALL(dView, configureStrongly()).Times(5); - EXPECT_CALL(dView, showAsNotIntegrated(_)).Times(4); - EXPECT_CALL(dView, showAsIntegrated()).Times(1); - - MockDimensionViewFactory factory; - EXPECT_CALL(factory, create()).Times(5).WillRepeatedly(Return(&dView)); - - MockGeometryView gView; - EXPECT_CALL(gView, getDimensionViewFactory()).WillOnce(ReturnRef(factory)); - EXPECT_CALL(gView, addDimensionView(_)).Times(5); - EXPECT_CALL(gView, getBinDisplayMode()).Times(1).WillOnce(Return(Simple)); - - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - - SynchronisingGeometryPresenter presenter(parser); - presenter.acceptView(&gView); - GeometryPresenter::MappingType axisMappings = presenter.getMappings(); - - TSM_ASSERT_EQUALS("Wrong number of axis-mappings", 4, axisMappings.size()); - TSM_ASSERT("Doesn't contain x-axis mapping", axisMappings.find(presenter.X_AXIS) != axisMappings.end()); - TSM_ASSERT("Doesn't contain y-axis mapping", axisMappings.find(presenter.Y_AXIS) != axisMappings.end()); - TSM_ASSERT("Doesn't contain z-axis mapping", axisMappings.find(presenter.Z_AXIS) != axisMappings.end()); - TSM_ASSERT("Doesn't contain t-axis mapping", axisMappings.find(presenter.T_AXIS) != axisMappings.end()); - - TS_ASSERT(Mock::VerifyAndClearExpectations(&gView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&dView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&factory)); - - } - - void testDimensionPartitioning() - { - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - SynchronisingGeometryPresenter presenter(parser); - - VecIMDDimension_sptr nonIntegratedDimensions = presenter.getNonIntegratedDimensions(); - VecIMDDimension_sptr integratedDimensions = presenter.getIntegratedDimensions(); - - TSM_ASSERT_EQUALS("Sum of partitions doesn't compute to total", 5, nonIntegratedDimensions.size() + integratedDimensions.size()); - TSM_ASSERT_EQUALS("Wrong number of non-integrated dimensions", 4, nonIntegratedDimensions.size()); - TSM_ASSERT_EQUALS("Wrong number of integrated dimensions", 1, integratedDimensions.size()); - TSM_ASSERT_EQUALS("Wrong integrated dimension", "en", integratedDimensions[0]->getDimensionId()); - } - - void testCollapsingThrows() - { - //In this test schenario there is a only one non-integrated dimension. - MDGeometryXMLParser parser(constructXML("2", "1", "1", "1", "1")); - parser.execute(); - ExposedSynchronisingGeometryPresenter geometryPresenter(parser); - - MockDimensionView dView; - DimensionPresenter dimensionPresenter(&dView, &geometryPresenter); - - //Should not be able to make a collapse request to the geometry presenter, when there is only one non-collapsed dimension. - TSM_ASSERT_THROWS("Should not be able to collapse the only-exising non-collapsed dimension.", geometryPresenter.dimensionCollapsed(&dimensionPresenter), std::invalid_argument); - } - - void testGetGeometryXML() - { - NiceMock<MockDimensionView> dView; - - NiceMock<MockDimensionViewFactory> factory; - EXPECT_CALL(factory, create()).WillRepeatedly(Return(&dView)); - - NiceMock<MockGeometryView> gView; - EXPECT_CALL(gView, getDimensionViewFactory()).WillRepeatedly(ReturnRef(factory)); - EXPECT_CALL(gView, getBinDisplayMode()).Times(1).WillOnce(Return(Simple)); - - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - - SynchronisingGeometryPresenter presenter(parser); - presenter.acceptView(&gView); - - TSM_ASSERT("Geometry XML has not been constructed", !presenter.getGeometryXML().empty()); - TS_ASSERT(Mock::VerifyAndClearExpectations(&gView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&dView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&factory)); - } - - void testDimensionRealign() - { - NiceMock<MockDimensionView> dView; - EXPECT_CALL(dView, getVisDimensionName()).WillRepeatedly(Return("T-AXIS")); - - NiceMock<MockDimensionViewFactory> factory; - EXPECT_CALL(factory, create()).WillRepeatedly(Return(&dView)); - - NiceMock<MockGeometryView> gView; - EXPECT_CALL(gView, getDimensionViewFactory()).WillRepeatedly(ReturnRef(factory)); - EXPECT_CALL(gView, getBinDisplayMode()).Times(1).WillOnce(Return(Simple)); - - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - - ExposedSynchronisingGeometryPresenter presenter(parser); - presenter.acceptView(&gView); - - //find out what presenter X_DIMENSION maps to. - DimPresenter_sptr presenterA = presenter.getMappings().at(presenter.X_AXIS); - DimPresenter_sptr presenterB = presenter.getMappings().at(presenter.T_AXIS); - - TSM_ASSERT_EQUALS("Swapping has not occured as expected.", presenter.X_AXIS, presenterA->getMapping()); - TSM_ASSERT_EQUALS("Swapping has not occured as expected.", presenter.T_AXIS, presenterB->getMapping()); - - presenter.dimensionRealigned(presenterA.get()); //Now swap these two dimensions - - TSM_ASSERT_EQUALS("Swapping has not occured as expected.", presenter.T_AXIS, presenterA->getMapping()); - TSM_ASSERT_EQUALS("Swapping has not occured as expected.", presenter.X_AXIS, presenterB->getMapping()); - - TS_ASSERT(Mock::VerifyAndClearExpectations(&gView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&dView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&factory)); - } - - void testNoDimensionModeChanged() - { - NiceMock<MockDimensionView> dView; - EXPECT_CALL(dView, setViewMode(_)).Times(0); // Call 0 times since nothing has changed. - - NiceMock<MockDimensionViewFactory> factory; - EXPECT_CALL(factory, create()).WillRepeatedly(Return(&dView)); - - NiceMock<MockGeometryView> gView; - EXPECT_CALL(gView, getDimensionViewFactory()).WillRepeatedly(ReturnRef(factory)); - EXPECT_CALL(gView, getBinDisplayMode()).Times(2).WillRepeatedly(Return(Simple)); //Will return (SIMPLE) the same Mode as the original, so nothing should happen. - - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - - SynchronisingGeometryPresenter presenter(parser); //Default initalizer sets the mode to SIMPLE - presenter.acceptView(&gView); - - //Some external indication that the mode has changed. - presenter.setDimensionModeChanged(); - - TS_ASSERT(Mock::VerifyAndClearExpectations(&gView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&dView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&factory)); - } - - void testDimensionModeChangedOnce() - { - NiceMock<MockDimensionView> dView; - EXPECT_CALL(dView, setViewMode(_)).Times(5); // Call 5 times since 5 dimensions are in the xml. - - NiceMock<MockDimensionViewFactory> factory; - EXPECT_CALL(factory, create()).WillRepeatedly(Return(&dView)); - - NiceMock<MockGeometryView> gView; - EXPECT_CALL(gView, getDimensionViewFactory()).WillRepeatedly(ReturnRef(factory)); - EXPECT_CALL(gView, getBinDisplayMode()).Times(2).WillOnce(Return(Simple)).WillOnce(Return(LowHighStep)); //Will return (LowHighStep) a different Mode to the original. - - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - - SynchronisingGeometryPresenter presenter(parser); //Default initalizer sets the mode to SIMPLE - presenter.acceptView(&gView); - - //Some external indication that the mode has changed. - presenter.setDimensionModeChanged(); - - TS_ASSERT(Mock::VerifyAndClearExpectations(&gView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&dView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&factory)); - } - - void testDimensionModeChangedDuplicated() - { - NiceMock<MockDimensionView> dView; - EXPECT_CALL(dView, setViewMode(_)).Times(5); // Call 5 times since 5 dimensions are in the xml. - - NiceMock<MockDimensionViewFactory> factory; - EXPECT_CALL(factory, create()).WillRepeatedly(Return(&dView)); - - NiceMock<MockGeometryView> gView; - EXPECT_CALL(gView, getDimensionViewFactory()).WillRepeatedly(ReturnRef(factory)); - EXPECT_CALL(gView, getBinDisplayMode()).Times(3).WillOnce(Return(Simple)).WillRepeatedly(Return(LowHighStep)); //Will return (LowHighStep) a different Mode to the original. - - MDGeometryXMLParser parser(constructXML()); - parser.execute(); - - SynchronisingGeometryPresenter presenter(parser); //Default initalizer sets the mode to SIMPLE - presenter.acceptView(&gView); - - //Some external indication that the mode has changed. - presenter.setDimensionModeChanged(); - presenter.setDimensionModeChanged(); //Calling it again should do nothing because the last result should be cached. - - TS_ASSERT(Mock::VerifyAndClearExpectations(&gView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&dView)); - TS_ASSERT(Mock::VerifyAndClearExpectations(&factory)); - } - -}; - -#endif -- GitLab