]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Fix reload icon in medreader property panel. cbr/fix_reload_icon_in_medreader_property_panel 10/head
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Fri, 26 Apr 2024 15:15:17 +0000 (17:15 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Fri, 26 Apr 2024 15:15:17 +0000 (17:15 +0200)
It was not working since FileSeries development.

src/Plugins/MEDReader/plugin/ParaViewPlugin/pqMEDReaderReloadWidget.cxx

index 480a9bc80f70b9166521d9157c37f5d12bf7613e..e19a460386bb0ff015cb346ef1cf082fe6ff38ce 100644 (file)
@@ -23,8 +23,8 @@
 #include "vtkSMProxy.h"
 #include "vtkSMSourceProxy.h"
 #include "vtkSMProperty.h"
-
-#include "pqPropertiesPanel.h"
+#include "pqUndoStack.h"
+#include "vtkSMReaderReloadHelper.h"
 
 #include <QPushButton>
 #include <QGridLayout>
@@ -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<pqPropertiesPanel*>(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<vtkSMReaderReloadHelper> 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();
 }