From e75bb74e14399cbb2df4aa8ef040ac811464a31d Mon Sep 17 00:00:00 2001 From: Michael Reuter <reuterma@ornl.gov> Date: Mon, 7 Nov 2011 10:31:17 -0500 Subject: [PATCH] Finishing move of time handling to view base class. This refs #3959. All of the time step handling for the animation controls is now in the view base class. I added a mode for updating the number of time steps in the pipeline object when the rebinner is called. --- .../MdViewerWidget.h | 7 ---- .../ViewBase.h | 4 +- .../ViewWidgets/src/MdViewerWidget.cpp | 38 ++----------------- .../ViewWidgets/src/ViewBase.cpp | 20 +++++++--- 4 files changed, 20 insertions(+), 49 deletions(-) diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h index 009a3e5135b..0f5f0f7c84e 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h @@ -133,13 +133,6 @@ private: ViewBase *setMainViewWidget(QWidget *container, ModeControlWidget::Views v); /// Helper function to swap current and hidden view pointers. void swapViews(); - /** - * Function to update animation controls when the rebinner is used. - * @param dvp the array containing the new timestep information - */ - void updateAnimationControls(vtkSMDoubleVectorProperty *dvp); - /// Update the timesteps in the animation control. - void updateTimesteps(); }; } diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h index 4d9a113c851..f13c513d618 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/ViewBase.h @@ -135,7 +135,7 @@ public slots: */ void onLogScale(int state); /// Setup the animation controls. - void setTimeSteps(); + void setTimeSteps(bool withUpdate = false); signals: /** @@ -172,7 +172,7 @@ private: /// Find the number of true sources in the pipeline. unsigned int getNumSources(); /// Collect time information for animation controls. - void handleTimeInfo(vtkSMDoubleVectorProperty *dvp); + void handleTimeInfo(vtkSMDoubleVectorProperty *dvp, bool doUpdate); ColorUpdater colorUpdater; ///< Handle to the color updating delegator }; diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp index 8b7bbb7f6e3..a1c377db557 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp @@ -304,9 +304,9 @@ void MdViewerWidget::setParaViewComponentsForView() this->ui.timeControlWidget, SLOT(enableAnimationControls(bool))); QObject::connect(this->currentView, - SIGNAL(setAnimationControlInfo(double,double,int)), + SIGNAL(setAnimationControlInfo(double, double, int)), this->ui.timeControlWidget, - SLOT(updateAnimationControls(double,double,int))); + SLOT(updateAnimationControls(double, double, int))); } void MdViewerWidget::onDataLoaded(pqPipelineSource* source) @@ -346,7 +346,7 @@ void MdViewerWidget::checkForUpdates() this->currentView->resetDisplay(); //this->currentView->getView()->resetCamera(); this->currentView->onAutoScale(); - this->updateTimesteps(); + this->currentView->setTimeSteps(true); } if (QString(proxy->GetXMLName()).contains("Threshold")) { @@ -358,38 +358,6 @@ void MdViewerWidget::checkForUpdates() } } -void MdViewerWidget::updateAnimationControls(vtkSMDoubleVectorProperty *dvp) -{ - const int numTimesteps = static_cast<int>(dvp->GetNumberOfElements()); - if (0 != numTimesteps) - { - double tStart = dvp->GetElement(0); - double tEnd = dvp->GetElement(dvp->GetNumberOfElements() - 1); - pqAnimationScene *scene = pqPVApplicationCore::instance()->animationManager()->getActiveScene(); - vtkSMPropertyHelper(scene->getProxy(), "StartTime").Set(tStart); - vtkSMPropertyHelper(scene->getProxy(), "EndTime").Set(tEnd); - vtkSMPropertyHelper(scene->getProxy(), "NumberOfFrames").Set(numTimesteps); - this->ui.timeControlWidget->setEnabled(true); - } - else - { - this->ui.timeControlWidget->setEnabled(false); - } -} - -void MdViewerWidget::updateTimesteps() -{ - vtkSMSourceProxy *rbcProxy = vtkSMSourceProxy::SafeDownCast(pqActiveObjects::instance().activeSource()->getProxy()); - rbcProxy->Modified(); - rbcProxy->UpdatePipelineInformation(); - vtkSMDoubleVectorProperty *tsv = vtkSMDoubleVectorProperty::SafeDownCast(rbcProxy->GetProperty("TimestepValues")); - const int numTimesteps = static_cast<int>(tsv->GetNumberOfElements()); - vtkSMSourceProxy *srcProxy = vtkSMSourceProxy::SafeDownCast(this->currentView->origSrc->getProxy()); - vtkSMPropertyHelper(srcProxy, "TimestepValues").Set(tsv->GetElements(), - numTimesteps); - this->updateAnimationControls(tsv); -} - void MdViewerWidget::switchViews(ModeControlWidget::Views v) { this->removeProxyTabWidgetConnections(); diff --git a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/ViewBase.cpp b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/ViewBase.cpp index 54951d913fa..68cd0d7f52c 100644 --- a/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/ViewBase.cpp +++ b/Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/ViewBase.cpp @@ -161,13 +161,15 @@ void ViewBase::checkView() * step information. If not, it will disable the animation controls. If the * pipeline source has time step information, the animation controls will be * enabled and the start, stop and number of time steps updated for the - * animation scene. + * animation scene. If the withUpdate flag is used (default off), then the + * original pipeline source is updated with the number of "time" steps. + * @param withUpdate update the original source with "time" step info */ -void ViewBase::setTimeSteps() +void ViewBase::setTimeSteps(bool withUpdate) { pqPipelineSource *src = this->getPvActiveSrc(); unsigned int numSrcs = this->getNumSources(); - if (this->isPeaksWorkspace(src)) + if (!withUpdate && this->isPeaksWorkspace(src)) { if (1 == numSrcs) { @@ -184,7 +186,7 @@ void ViewBase::setTimeSteps() srcProxy1->UpdatePipelineInformation(); vtkSMDoubleVectorProperty *tsv = vtkSMDoubleVectorProperty::SafeDownCast(\ srcProxy1->GetProperty("TimestepValues")); - this->handleTimeInfo(tsv); + this->handleTimeInfo(tsv, withUpdate); } /** @@ -217,12 +219,20 @@ unsigned int ViewBase::getNumSources() * end "time" and the number of "time" steps. It also enables/disables the * animation controls widget based on the number of "time" steps. * @param dvp the vector property containing the "time" information + * @param doUpdate flag to update original source with "time" step info */ -void ViewBase::handleTimeInfo(vtkSMDoubleVectorProperty *dvp) +void ViewBase::handleTimeInfo(vtkSMDoubleVectorProperty *dvp, bool doUpdate) { const int numTimesteps = static_cast<int>(dvp->GetNumberOfElements()); if (0 != numTimesteps) { + if (doUpdate) + { + vtkSMSourceProxy *srcProxy = vtkSMSourceProxy::SafeDownCast(\ + this->origSrc->getProxy()); + vtkSMPropertyHelper(srcProxy, "TimestepValues").Set(dvp->GetElements(), + numTimesteps); + } double tStart = dvp->GetElement(0); double tEnd = dvp->GetElement(dvp->GetNumberOfElements() - 1); pqAnimationScene *scene = pqPVApplicationCore::instance()->animationManager()->getActiveScene(); -- GitLab