From f4fda842237638a72fce8b5e7bfc4198fd836068 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Fri, 26 Apr 2024 17:15:17 +0200 Subject: [PATCH] Fix reload icon in medreader property panel. It was not working since FileSeries development. --- .../pqMEDReaderReloadWidget.cxx | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/src/Plugins/MEDReader/plugin/ParaViewPlugin/pqMEDReaderReloadWidget.cxx b/src/Plugins/MEDReader/plugin/ParaViewPlugin/pqMEDReaderReloadWidget.cxx index 480a9bc8..e19a4603 100644 --- a/src/Plugins/MEDReader/plugin/ParaViewPlugin/pqMEDReaderReloadWidget.cxx +++ b/src/Plugins/MEDReader/plugin/ParaViewPlugin/pqMEDReaderReloadWidget.cxx @@ -23,8 +23,8 @@ #include "vtkSMProxy.h" #include "vtkSMSourceProxy.h" #include "vtkSMProperty.h" - -#include "pqPropertiesPanel.h" +#include "pqUndoStack.h" +#include "vtkSMReaderReloadHelper.h" #include #include @@ -57,40 +57,25 @@ pqMEDReaderReloadWidget::~pqMEDReaderReloadWidget() void pqMEDReaderReloadWidget::buttonClicked() { - // Recovering Property Panel - pqPropertiesPanel* panel = NULL; - QObject* tmp = this; - while (panel == NULL) - { - tmp = tmp->parent(); - if (!tmp) - { - break; - } - panel = qobject_cast(tmp); - } + // code adapted from ParaView/Qt/ApplicationComponents/pqReloadFilesReaction.cxx + // which corresponds to right-click reload files - if (!panel) - { - qDebug() << "Cannot find pqPropertiesPanel, reload may not work"; - } - else - { - // Restoring property to defaults, necessary when unchecked property are not applied - panel->propertiesRestoreDefaults(); - } + vtkNew helper; - // Reloading the data and associated properties - this->Property->Modified(); - this->proxy()->UpdateProperty(this->proxy()->GetPropertyName(this->Property)); - vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipelineInformation(); + vtkSMSourceProxy* sourceProxy = vtkSMSourceProxy::SafeDownCast(this->proxy()); - // Restting properties to dufault using domains and XML values - this->proxy()->ResetPropertiesToDefault(); + if (!helper->SupportsReload(sourceProxy)) + { + return; + } - if (panel) - { - // Disabled apply button inderectly - panel->propertiesRestoreDefaults(); - } + BEGIN_UNDO_EXCLUDE(); + // as MEDReader support FileSeries, we can either reload files or extend file series + // (the right-click reload files allows to choose it from a dialog box) + // as single med file is the main use case, we choose to reload it + // (instead of extending file series) + helper->ReloadFiles(sourceProxy); +// helper->ExtendFileSeries(sourceProxy); + pqApplicationCore::instance()->render(); + END_UNDO_EXCLUDE(); } -- 2.39.2