From ae0f9b6bc9e2d5618d2451bc33ad103c9537c1a7 Mon Sep 17 00:00:00 2001 From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk> Date: Tue, 12 May 2015 10:27:23 +0100 Subject: [PATCH] add button: reset views state, re #11708 --- .../ViewWidgets/icons/ViewWidgetsIcons.qrc | 1 + .../ViewWidgets/icons/resetViewToAll24.png | Bin 0 -> 362 bytes .../MdViewerWidget.h | 4 ++ .../MdViewerWidget.ui | 35 +++++++++++- .../ViewWidgets/src/MdViewerWidget.cpp | 51 ++++++++++++++++-- 5 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/resetViewToAll24.png diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/ViewWidgetsIcons.qrc b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/ViewWidgetsIcons.qrc index 1c14c579d10..d6e22e59aef 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/ViewWidgetsIcons.qrc +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/ViewWidgetsIcons.qrc @@ -5,5 +5,6 @@ <file>parallel_projection.png</file> <file>pvIcon.png</file> <file>pqEditColor24.png</file> + <file>resetViewToAll24.png</file> </qresource> </RCC> diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/resetViewToAll24.png b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/resetViewToAll24.png new file mode 100644 index 0000000000000000000000000000000000000000..10eaed083e83b59b1cbf33e45ec1752eb8448bdc GIT binary patch literal 362 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQaMFBn`u0R?Ne*E~cbLY<e%*@A? zlun*Jb>_^ua}EyYot!RQxOC;pwd;wAH*VazT~Kfb1n%9x|KR@phYue<e)Q<clP6D~ z&6)G;*^B237Q9@({N>A6uV24;`}W<tcOSmrzyI^+&p)3(|NZ;--=9DK|Nk#)l;j0k z$ygHP7tG-B>_!@hljQC0!qCAg>jC6&7I;J!1KoWcgc+SQW>)|O*-JcqUD@xm@~~^_ zy9YHa1qu~<x;TbNT<$%8kgGvK!1ZF7{)R~<f{UbQe)(U&QCxy;@`czP7H14BeCN;A zdbCif>Uqs+L%Sost}&rURw?P3?N>eCD$#gpEyKsS`Mnd5ADQttZoQ{~9M6Ox_jWf4 utCqI-b|Zz_pa!2U4zFe~SpT|sUvDX=;yK~+1F=BM89ZJ6T-G@yGywo+6runC literal 0 HcmV?d00001 diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h index c45aef23edd..648c656625f 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h @@ -118,6 +118,9 @@ protected slots: void onUnbin(); /// On switching an MDEvent source to a temporary source. void onSwitchSources(std::string rebinnedWorkspaceName, std::string sourceType); + /// reset state of all the views + void onResetViewsStateToAllData(); + protected: /// Handle workspace preDeletion tasks. void preDeleteHandle(const std::string &wsName, @@ -162,6 +165,7 @@ private: struct AllVSIViewsState { AllVSIViewsState(); ~AllVSIViewsState(); + void initialize(); vtkSmartPointer<vtkPVXMLElement> stateStandard; vtkSmartPointer<vtkPVXMLElement> stateMulti; diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.ui b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.ui index c4e62505498..12244ce1ebe 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.ui +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.ui @@ -118,6 +118,39 @@ <item> <widget class="Mantid::Vates::SimpleGui::ColorSelectionWidget" name="colorSelectionWidget" native="true"/> </item> + <item> + <spacer name="horizontalSpacer_bw_color_reset"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Minimum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="resetViewsStateToAllData"> + <property name="toolTip"> + <string>Reset the state of all the views (to show all data)</string> + </property> + <property name="icon"> + <iconset resource="../../icons/ViewWidgetsIcons.qrc"> + <normaloff>:/VatesSimpleGuiViewWidgets/icons/resetViewToAll24.png</normaloff>:/VatesSimpleGuiViewWidgets/icons/resetViewToAll24.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + </item> <item> <spacer name="horizontalSpacer_5"> <property name="orientation"> @@ -125,7 +158,7 @@ </property> <property name="sizeHint" stdset="0"> <size> - <width>40</width> + <width>20</width> <height>20</height> </size> </property> diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp index 244748e05bc..2bb32126265 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp @@ -133,6 +133,15 @@ namespace REGISTER_VATESGUI(MdViewerWidget) MdViewerWidget::AllVSIViewsState::AllVSIViewsState(){ + initialize(); +} + +/** + * Initializes the views states with new empty values. This can be + * used to contruct or to re-initialize (forget) the states. + */ +void MdViewerWidget::AllVSIViewsState::initialize() +{ // these will be assigned from vtkSMProxy::SaveXMLState which // allocates a new tree with vtkPVXMLElement::New(); stateStandard = vtkSmartPointer<vtkPVXMLElement>::New(); @@ -141,7 +150,8 @@ MdViewerWidget::AllVSIViewsState::AllVSIViewsState(){ stateSplatter = vtkSmartPointer<vtkPVXMLElement>::New(); } -MdViewerWidget::AllVSIViewsState::~AllVSIViewsState() { +MdViewerWidget::AllVSIViewsState::~AllVSIViewsState() +{ } /** @@ -225,7 +235,7 @@ void MdViewerWidget::setupUiAndConnections() // Setup rotation point button - QObject::connect(this->ui.resetViewStateToAllData, + QObject::connect(this->ui.resetViewsStateToAllData, SIGNAL(released()), this, SLOT(onResetViewToAll())); @@ -253,7 +263,7 @@ void MdViewerWidget::setupUiAndConnections() //this->ui.pipelineBrowser->enableAnnotationFilter(m_widgetName); //this->ui.pipelineBrowser->hide(); g_log.warning("Annotation Name: " + m_widgetName.toStdString()); - + // Connect the rebinned sources manager QObject::connect(&m_rebinnedSourcesManager, SIGNAL(triggerAcceptForNewFilters()), @@ -406,8 +416,14 @@ void MdViewerWidget::setParaViewComponentsForView() QObject::connect(this->currentView, SIGNAL(setViewStatus(ModeControlWidget::Views, bool)), this->ui.modeControlWidget, SLOT(enableViewButton(ModeControlWidget::Views, bool))); + this->connectColorSelectionWidget(); + // Connect the reset view state button, which is between the color selection widget and the ParaQ toolbars + QObject::connect(this->ui.resetViewsStateToAllData, SIGNAL(released()), + this, SLOT(onResetViewsStateToAllData())); + + // Set animation (time) control widget <-> view signals/slots. QObject::connect(this->currentView, SIGNAL(setAnimationControlState(bool)), @@ -481,6 +497,33 @@ void MdViewerWidget::onSwitchSources(std::string rebinnedWorkspaceName, std::str } } +/** + * This gives the user a simple way to reset the state and forget all + * the interactions to start anew. Resets to all data and resets the + * center point and direction/rotation/angle. + */ +void MdViewerWidget::onResetViewsStateToAllData() +{ + // forget alll the view saved states + m_allViews.initialize(); + + if (!this->currentView) + return; + + // reset direction/rotation + pqRenderView* pqv = this->currentView->getView(); + if (!pqv) { + g_log.warning() << "Serious inconsistency found: could not retrieve a pqRenderView while " + "trying to reset the state of the views."; + return; + } + pqv->resetViewDirection(0, 0, -1, 0, 0, 0); + + // reset current view + this->currentView->resetDisplay(); // includes a resetCamera() or more + this->currentView->render(); +} + /** * Creates and renders a rebinned workspace source * @param rebinnedWorkspaceName The name of the rebinned workspace. @@ -1535,7 +1578,7 @@ void MdViewerWidget::saveViewState(ViewBase *view) { /** * Restores the state of a view (if there's a saved state for this * type of view, which should happen if the user has been in that view - * before and is switching back to it. + * before and is switching back to it. @see saveViewState(). * * @param view View where we want to restore the previous state * @param vtype Type of view (standard, multislice, etc.) -- GitLab