diff --git a/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/CMakeLists.txt b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/CMakeLists.txt index df8c97093ef22ed2dc198101c6b771b943592233..59ea51e7b8a26db95370c87b376714b5de508831 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/CMakeLists.txt +++ b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/CMakeLists.txt @@ -5,6 +5,7 @@ set( INCLUDE_FILES inc/MantidVatesSimpleGuiQtWidgets/AxisInformation.h inc/MantidVatesSimpleGuiQtWidgets/GeometryParser.h inc/MantidVatesSimpleGuiQtWidgets/ModeControlWidget.h + inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.h inc/MantidVatesSimpleGuiQtWidgets/RotationPointDialog.h inc/MantidVatesSimpleGuiQtWidgets/WidgetDllOption.h ) @@ -13,12 +14,14 @@ set( SOURCE_FILES src/AxisInformation.cpp src/GeometryParser.cpp src/ModeControlWidget.cpp + src/RebinDialog.cpp src/RotationPointDialog.cpp ) # These are the headers to be preprocessed using Qt's moc preprocessor. qt4_wrap_cpp( MOC_SOURCES inc/MantidVatesSimpleGuiQtWidgets/ModeControlWidget.h + inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.h inc/MantidVatesSimpleGuiQtWidgets/RotationPointDialog.h ) @@ -29,6 +32,7 @@ qt4_add_resources( RES_FILES icons/QtWidgetsIcons.qrc ) # Qt's ui file processor. qt4_wrap_ui( UI_BUILT_SOURCES inc/MantidVatesSimpleGuiQtWidgets/ModeControlWidget.ui + inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.ui inc/MantidVatesSimpleGuiQtWidgets/RotationPointDialog.ui ) diff --git a/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.h b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..0dce583811ac8ff069d90906e87c1cbf6d8b9bb5 --- /dev/null +++ b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.h @@ -0,0 +1,78 @@ +#ifndef REBINDIALOG_H_ +#define REBINDIALOG_H_ + +#include "ui_RebinDialog.h" +#include <QDialog> +#include "MantidVatesSimpleGuiQtWidgets/WidgetDllOption.h" +#include <QLabel> +#include <QSpinBox> + +namespace Mantid +{ + namespace Vates + { + namespace SimpleGui + { + /** + * + This class provides a dialog to perform rebinning. + + @date 15/01/2015 + + Copyright © 2011 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 EXPORT_OPT_MANTIDVATES_SIMPLEGUI_QTWIDGETS RebinDialog : public QDialog + { + Q_OBJECT + + public: + RebinDialog(QWidget *parent = 0); + + ~RebinDialog(); + + + public slots: + void onUpdateDialog(QStringList algorithms, std::vector<QString> binNames, std::vector<int> bins); + + signals: + void performRebinning(QString algorithm, std::vector<QString> binNames, std::vector<int> bins); + + private slots: + void onAccept(); + + private: + Ui::RebinDialog ui; + + void setBins(std::vector<QString> binNames, std::vector<int> bins); + void setAlgorithms(QStringList algorithms); + + bool m_validBins; + + QLabel *lblBin1, *lblBin2, *lblBin3; + QSpinBox *boxBin1, *boxBin2, *boxBin3; + + }; + } + } +} + +#endif // MULTISLICEVIEW_H_ diff --git a/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.ui b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..88bd6b67f2fd3d668549875bd6126e3ff017f938 --- /dev/null +++ b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/inc/MantidVatesSimpleGuiQtWidgets/RebinDialog.ui @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>RebinDialog</class> + <widget class="QDialog" name="RebinDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>327</width> + <height>271</height> + </rect> + </property> + <property name="windowTitle"> + <string>Rebin the workspace</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,2"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Algorithm</string> + </property> + <widget class="QWidget" name="horizontalLayoutWidget"> + <property name="geometry"> + <rect> + <x>9</x> + <y>9</y> + <width>291</width> + <height>51</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,2"> + <item> + <widget class="QLabel" name="lblAlgorithms"> + <property name="text"> + <string>Choose an algorithm:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBoxAlgorithms"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Bins</string> + </property> + <widget class="QWidget" name="gridLayoutWidget"> + <property name="geometry"> + <rect> + <x>9</x> + <y>9</y> + <width>291</width> + <height>131</height> + </rect> + </property> + <layout class="QGridLayout" name="layoutBins" columnstretch="0"/> + </widget> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>RebinDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>163</x> + <y>250</y> + </hint> + <hint type="destinationlabel"> + <x>163</x> + <y>135</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>RebinDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>163</x> + <y>250</y> + </hint> + <hint type="destinationlabel"> + <x>163</x> + <y>135</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/src/RebinDialog.cpp b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/src/RebinDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..81c838cf6b2b140d55cc253adef0018526c8db42 --- /dev/null +++ b/Code/Mantid/Vates/VatesSimpleGui/QtWidgets/src/RebinDialog.cpp @@ -0,0 +1,147 @@ +#include "MantidVatesSimpleGuiQtWidgets/RebinDialog.h" +#include <QDialog> +#include <QLayoutItem> +#include <vector> +#include <QStringList> +#include <QSpinBox> +#include <QLabel> + + + +namespace Mantid +{ + namespace Vates + { + namespace SimpleGui + { + RebinDialog::RebinDialog(QWidget* parent) : QDialog(parent), m_validBins(false) + { + this->ui.setupUi(this); + + QObject::connect(this->ui.buttonBox, SIGNAL(accepted()), + this, SLOT(onAccept())); + } + + RebinDialog::~RebinDialog() + { + } + /** + * Sets the list of algorithms for the user to select + * @param algorithms The list of algorithms + */ + void RebinDialog::setAlgorithms(QStringList algorithms) + { + this->ui.comboBoxAlgorithms->clear(); + + this->ui.comboBoxAlgorithms->addItems(algorithms); + } + + void RebinDialog::setBins(std::vector<QString> binNames, std::vector<int> bins) + { + // Remove existing bins from Layout + QLayoutItem* child; + while ((child = this->ui.layoutBins->takeAt(0)) != 0) + { + child->widget()->deleteLater(); + delete child; + } + + // Set the bins + int minimum = 1; + int maximum = 1000; + + // Add bin 1 + lblBin1 = new QLabel(); + + boxBin1 = new QSpinBox(); + boxBin1->setMaximum(maximum); + boxBin1->setMinimum(minimum); + boxBin1->setButtonSymbols(QAbstractSpinBox::ButtonSymbols::NoButtons); + + ui.layoutBins->addWidget(lblBin1, 0, 0); + ui.layoutBins->addWidget(boxBin1, 0, 1); + + // Add bin 2 + lblBin2 = new QLabel(); + + boxBin2 = new QSpinBox(); + boxBin2->setMaximum(maximum); + boxBin2->setMinimum(minimum); + boxBin2->setButtonSymbols(QAbstractSpinBox::ButtonSymbols::NoButtons); + + ui.layoutBins->addWidget(lblBin2, 1, 0); + ui.layoutBins->addWidget(boxBin2, 1, 1); + + // Add bin 3 + lblBin3 = new QLabel(); + + boxBin3 = new QSpinBox(); + boxBin3->setMaximum(maximum); + boxBin3->setMinimum(minimum); + boxBin3->setButtonSymbols(QAbstractSpinBox::ButtonSymbols::NoButtons); + + ui.layoutBins->addWidget(lblBin3, 2, 0); + ui.layoutBins->addWidget(boxBin3, 2, 1); + + // Set the value + if((bins.size() == binNames.size()) && bins.size() == 3) + { + boxBin1->setVisible(true); + boxBin2->setVisible(true); + boxBin3->setVisible(true); + + + lblBin1->setText(binNames[0]); + boxBin1->setValue(bins[0]); + + lblBin2->setText(binNames[1]); + boxBin2->setValue(bins[1]); + + lblBin3->setText(binNames[2]); + boxBin3->setValue(bins[2]); + + m_validBins = true; + } + else + { + boxBin1->setVisible(false); + boxBin2->setVisible(false); + boxBin3->setVisible(false); + + m_validBins = false; + } + } + + void RebinDialog::onUpdateDialog(QStringList algorithms,std::vector<QString> binNames, std::vector<int> bins) + { + this->setAlgorithms(algorithms); + this->setBins(binNames, bins); + } + + void RebinDialog::onAccept() + { + // Get the selected algorithm + QString algorithm = this->ui.comboBoxAlgorithms->currentText(); + + // Get the bin information + std::vector<int> bins; + bins.push_back(boxBin1->value()); + bins.push_back(boxBin2->value()); + bins.push_back(boxBin3->value()); + + std::vector<QString> binNames; + binNames.push_back(lblBin1->text()); + binNames.push_back(lblBin2->text()); + binNames.push_back(lblBin3->text()); + + + // Send the request for rebinning only if all options are availble. + if (m_validBins) + { + emit performRebinning(algorithm, binNames, bins); + } + } + + } // SimpleGui + } // Vates +} // Mantid diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt index 8a8ec6d7f638285e5d1cf8738a4cb96eadad6152..581b60cd17742d65b8df8b3b2ea5550a5cc3ca34 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt @@ -7,6 +7,7 @@ set( INCLUDE_FILES inc/MantidVatesSimpleGuiViewWidgets/LibHelper.h inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h inc/MantidVatesSimpleGuiViewWidgets/MultisliceView.h + inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h inc/MantidVatesSimpleGuiViewWidgets/SaveScreenshotReaction.h inc/MantidVatesSimpleGuiViewWidgets/StandardView.h inc/MantidVatesSimpleGuiViewWidgets/SplatterPlotView.h @@ -21,6 +22,7 @@ set( SOURCE_FILES src/ColorUpdater.cpp src/MdViewerWidget.cpp src/MultisliceView.cpp + src/RebinManager.cpp src/SaveScreenshotReaction.cpp src/StandardView.cpp src/SplatterPlotView.cpp @@ -35,6 +37,7 @@ qt4_wrap_cpp( MOC_SOURCES inc/MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.h inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h inc/MantidVatesSimpleGuiViewWidgets/MultisliceView.h + inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h inc/MantidVatesSimpleGuiViewWidgets/SaveScreenshotReaction.h inc/MantidVatesSimpleGuiViewWidgets/StandardView.h inc/MantidVatesSimpleGuiViewWidgets/SplatterPlotView.h diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h index c103e51734302a967e07d3cb2f70eb4d795c3d44..a3bc4212929806deb2198a4f2e8527a28359a902 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h @@ -3,6 +3,7 @@ #include "ui_MdViewerWidget.h" #include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h" +#include "MantidVatesSimpleGuiViewWidgets/RebinManager.h" #include "MantidQtAPI/VatesViewerInterface.h" #include "MantidQtAPI/WorkspaceObserver.h" @@ -31,7 +32,7 @@ namespace SimpleGui class RotationPointDialog; class SaveScreenshotReaction; class ViewBase; - +class RebinDialog; /** * This class represents the central widget for handling VATES visualization @@ -101,6 +102,8 @@ protected slots: void renderingDone(); /// Execute view switch. void switchViews(ModeControlWidget::Views v); + /// On rebin + void onRebin(RebinDialog* rebinDialog); protected: /// Handle workspace preDeletion tasks. @@ -127,7 +130,7 @@ private: pqViewSettingsReaction *viewSettings; ///< Holder for the view settings reaction bool viewSwitched; ModeControlWidget::Views initialView; ///< Holds the initial view - + RebinManager m_rebinManager; ///<Holds the rebin manager /// Check the environmental variables. void checkEnvSetup(); diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h new file mode 100644 index 0000000000000000000000000000000000000000..9e08a6d0e37621fce5e5592fe1b2ffee9ccd4fbb --- /dev/null +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/RebinManager.h @@ -0,0 +1,70 @@ +#ifndef REBINMANAGER_H_ +#define REBINMANAGER_H_ + +#include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h" +#include <QObject> +#include <vector> +#include <QStringList> + +namespace Mantid +{ + namespace Vates + { + namespace SimpleGui + { + class RebinDialog; + + /** + * + This class coordinates the rebinning of a workspace and updates the pipeline and view to make the changes of the + underlying workspace visible. + + @date 15/01/2015 + + Copyright © 2011 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 EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS RebinManager :public QObject + { + Q_OBJECT + public: + RebinManager(QObject* parent = 0); + + ~RebinManager(); + + void sendUpdate(); + + void connectDialog(RebinDialog* rebinDialog); + + signals: + void udpateDialog(QStringList algorithms,std::vector<QString> binNames, std::vector<int> bins); + + public slots: + void onPerformRebinning(QString algorithm,std::vector<QString> binNames, std::vector<int> bins); + + private: + RebinDialog* m_rebinDialog; + }; + + } // SimpleGui + } // Vates +} // Mantid + +#endif diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.h index 8c4df7ae10ea62225983a54ee31eecf8d729165c..e3507ad51bb15ca6408764521fbc393fb45d1253 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.h @@ -11,12 +11,14 @@ class pqPipelineSource; class pqRenderView; + namespace Mantid { namespace Vates { namespace SimpleGui { +class RebinDialog; /** * This class represents the initial view for the main program. It is meant to @@ -70,6 +72,8 @@ public: void updateUI(); /// @see ViewBase::updateView() void updateView(); + /// @see ViewBase::closeSubWindows + void closeSubWindows(); protected slots: /// Add a slice to the current dataset. @@ -78,6 +82,8 @@ protected slots: void onRenderDone(); /// Invoke the ScaleWorkspace on the current dataset. void onScaleButtonClicked(); + /// Invoke the rebin dialog + void onRebinButtonClicked(); private: Q_DISABLE_COPY(StandardView) @@ -86,6 +92,7 @@ private: QPointer<pqPipelineSource> scaler; ///< Holder for the ScaleWorkspace Ui::StandardView ui; ///< The standard view's UI form QPointer<pqRenderView> view; ///< The main view + RebinDialog* m_rebinDialog; ///< Handle to the rebin dialog. }; } // SimpleGui diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.ui b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.ui index 4d7063a6f17b9672a38e1ff61b887ee1c907ecdb..49d62acfdab029cc18b7e4627ca9ed08df3a551a 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.ui +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/StandardView.ui @@ -29,6 +29,16 @@ </property> </spacer> </item> + <item> + <widget class="QPushButton" name="rebinButton"> + <property name="toolTip"> + <string>Invoke plugin to rebin the current dataset.</string> + </property> + <property name="text"> + <string>Rebin</string> + </property> + </widget> + </item> <item> <widget class="QPushButton" name="scaleButton"> <property name="toolTip"> diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h index 401dd2de5efcf26e37260b15bb5d54eb35ff7170..ff66c20d0262c7b3b001b46f4ef26a6442422f64 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h @@ -3,7 +3,7 @@ #include "MantidVatesSimpleGuiViewWidgets/ColorUpdater.h" #include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h" - +#include "MantidVatesSimpleGuiQtWidgets/RebinDialog.h" #include "MantidVatesSimpleGuiQtWidgets/ModeControlWidget.h" #include <QPointer> @@ -185,6 +185,11 @@ signals: * @param state Whether or not to enable to view mode buttons. */ void setViewsStatus(ModeControlWidget::Views view, bool state); + /** + * Signal to perform a possible rebin. + * @param rebinDialog Pointer to a rebin dialog + */ + void rebin(RebinDialog* rebinDialog); private: Q_DISABLE_COPY(ViewBase) diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp index 3c7dcdf465c59c6846c0e96948e350ae5af0e370..f1bcc70af656b4f140cd8d0a14632cf27228e7e7 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp @@ -448,6 +448,20 @@ void MdViewerWidget::setParaViewComponentsForView() SIGNAL(toggled(bool)), this->currentView, SLOT(onParallelProjection(bool))); + + // Start listening to a rebinning event + QObject::connect(this->currentView, SIGNAL(rebin(RebinDialog*)), + this, SLOT(onRebin(RebinDialog*)), Qt::UniqueConnection); +} + +/** + * Reaction for a rebin event + */ +void MdViewerWidget::onRebin(RebinDialog* rebinDialog) +{ + m_rebinManager.connectDialog(rebinDialog); + + m_rebinManager.sendUpdate(); } /** diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinManager.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinManager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..70152210af7cc11b044bec018248f8b4e3978558 --- /dev/null +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/RebinManager.cpp @@ -0,0 +1,71 @@ +#include "MantidVatesSimpleGuiViewWidgets/RebinManager.h" +#include "MantidVatesSimpleGuiQtWidgets/RebinDialog.h" +#include "MantidVatesAPI/ADSWorkspaceProvider.h" +#include <QStringList> +#include <vector> + +#include <pqActiveObjects.h> +#include <pqPipelineSource.h> +#include <vtkSMPropertyHelper.h> + +// Have to deal with ParaView warnings and Intel compiler the hard way. +#if defined(__INTEL_COMPILER) + #pragma warning disable 1170 +#endif + +namespace Mantid +{ + namespace Vates + { + namespace SimpleGui + { + RebinManager::RebinManager(QObject* parent) : QObject(parent) + { + } + + RebinManager::~RebinManager() + { + } + + void RebinManager::sendUpdate() + { + // Get the workspace information for the active source + pqPipelineSource* activeSource = pqActiveObjects::instance().activeSource(); + + std::string workspaceName(vtkSMPropertyHelper((activeSource)->getProxy(), + "WorkspaceName", true).GetAsString()); + + std::vector<int> bins; + bins.push_back(50); + bins.push_back(50); + bins.push_back(50); + + std::vector<QString> binNames; + binNames.push_back(QString("Bin1")); + binNames.push_back(QString("Bin2")); + binNames.push_back(QString("Bin3")); + + QStringList list; + list.append("Alg1"); + list.append("Alg2"); + + emit this->udpateDialog(list, binNames, bins); + } + + void RebinManager::onPerformRebinning(QString algorithm,std::vector<QString> binNames, std::vector<int> bins) + { + int a = 1; + } + + void RebinManager::connectDialog(RebinDialog* rebinDialog) + { + // Establish connection between Rebinmanager and RebinDialog + QObject::connect(this, SIGNAL(udpateDialog(QStringList, std::vector<QString>, std::vector<int>)), + rebinDialog, SLOT(onUpdateDialog(QStringList,std::vector<QString>, std::vector<int>)), Qt::UniqueConnection); + + QObject::connect(rebinDialog, SIGNAL(performRebinning(QString, std::vector<QString>, std::vector<int>)), + this, SLOT(onPerformRebinning(QString, std::vector<QString> , std::vector<int>)), Qt::UniqueConnection); + } + } // SimpleGui + } // Vates +} // Mantid diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/StandardView.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/StandardView.cpp index 7be7c9f2847e8b121decf6eae901ff8415eff119..bc6af39f75e3d219f4e0d44521020f55f10e3632 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/StandardView.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/StandardView.cpp @@ -1,5 +1,5 @@ #include "MantidVatesSimpleGuiViewWidgets/StandardView.h" - +#include "MantidVatesSimpleGuiQtWidgets/RebinDialog.h" // Have to deal with ParaView warnings and Intel compiler the hard way. #if defined(__INTEL_COMPILER) #pragma warning disable 1170 @@ -36,11 +36,15 @@ namespace SimpleGui * buttons and creates the rendering view. * @param parent the parent widget for the standard view */ -StandardView::StandardView(QWidget *parent) : ViewBase(parent) + StandardView::StandardView(QWidget *parent) : ViewBase(parent), m_rebinDialog(NULL) { this->ui.setupUi(this); this->cameraReset = false; + // Set the rebin button to open a rebin dialog + QObject::connect(this->ui.rebinButton, SIGNAL(clicked()), + this, SLOT(onRebinButtonClicked())); + // Set the cut button to create a slice on the data QObject::connect(this->ui.cutButton, SIGNAL(clicked()), this, SLOT(onCutButtonClicked())); @@ -117,6 +121,18 @@ void StandardView::onScaleButtonClicked() this->getPvActiveSrc()); } +void StandardView::onRebinButtonClicked() +{ + // Open the Rebin dialog + if (NULL == this->m_rebinDialog) + { + this->m_rebinDialog = new RebinDialog(this); + } + + emit rebin(m_rebinDialog); + this->m_rebinDialog->show(); +} + /** * This function is responsible for calling resetCamera if the internal * variable cameraReset has been set to true. @@ -158,6 +174,11 @@ void StandardView::updateView() this->cameraReset = true; } +void StandardView::closeSubWindows() +{ + +} + } // SimpleGui } // Vates } // Mantid