Skip to content
Snippets Groups Projects
Commit ae0f9b6b authored by Federico Montesino Pouzols's avatar Federico Montesino Pouzols
Browse files

add button: reset views state, re #11708

parent df0e169e
No related branches found
No related tags found
No related merge requests found
......@@ -5,5 +5,6 @@
<file>parallel_projection.png</file>
<file>pvIcon.png</file>
<file>pqEditColor24.png</file>
<file>resetViewToAll24.png</file>
</qresource>
</RCC>
Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/icons/resetViewToAll24.png

362 B

......@@ -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;
......
......@@ -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>
......
......@@ -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.)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment