]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
First visu of GEOM objects
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 5 Apr 2023 12:49:17 +0000 (14:49 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 5 Apr 2023 12:49:17 +0000 (14:49 +0200)
src/PVViewer/PVViewer_Core.cxx
src/PVViewer/PVViewer_Core.h
src/SPV3D/SPV3D_ViewModel.cxx

index 352a67caface4629799d6197195913dc79616056..02a07a5e42c59dde6c8078aa5ef8c416439a915e 100644 (file)
 
 
 //---------- Static init -----------------
-pqPVApplicationCore* PVViewer_Core::MyCoreApp = 0;
+pqPVApplicationCore* PVViewer_Core::MyCoreApp = nullptr;
 bool PVViewer_Core::ConfigLoaded = false;
-PVViewer_Behaviors * PVViewer_Core::ParaviewBehaviors = NULL;
+PVViewer_Behaviors * PVViewer_Core::ParaviewBehaviors = nullptr;
 
 pqPVApplicationCore * PVViewer_Core::GetPVApplication()
 {
   return MyCoreApp;
 }
 
-/*!
-  \brief Static method, performs initialization of ParaView session.
-  \param fullSetup whether to instanciate all behaviors or just the minimal ones.
-  \return \c true if ParaView has been initialized successfully, otherwise false
-*/
-bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop)
+bool PVViewer_Core::ParaViewInitAppCore()
 {
-  DBG_FUNC();
   if ( ! MyCoreApp) {
       // Obtain command-line arguments
       int argc = 0;
@@ -107,23 +101,35 @@ bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop)
         }
       //
       MyCoreApp = new pqPVApplicationCore (argc, argv);
+      for (int i = 0; i < argc; i++)
+        free(argv[i]);
+      delete[] argv;
       if (MyCoreApp->getOptions()->GetHelpSelected() ||
           MyCoreApp->getOptions()->GetUnknownArgument() ||
           MyCoreApp->getOptions()->GetErrorMessage() ||
           MyCoreApp->getOptions()->GetTellVersion()) {
           return false;
       }
+  }
+  return true;
+}
 
-      // Direct VTK log messages to our SALOME window - TODO: review this
-      PVViewer_OutputWindow * w = PVViewer_OutputWindow::New();
-      vtkOutputWindow::SetInstance(w);
+/*!
+  \brief Static method, performs initialization of ParaView session.
+  \param fullSetup whether to instanciate all behaviors or just the minimal ones.
+  \return \c true if ParaView has been initialized successfully, otherwise false
+*/
+bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop)
+{
+  DBG_FUNC();
+  if( ! ParaViewInitAppCore() )
+    return false;
 
-      new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation
+  // Direct VTK log messages to our SALOME window - TODO: review this
+  PVViewer_OutputWindow * w = PVViewer_OutputWindow::New();
+  vtkOutputWindow::SetInstance(w);
 
-      for (int i = 0; i < argc; i++)
-        free(argv[i]);
-      delete[] argv;
-  }
+  new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation
   // Initialization of ParaView GUI widgets will be done when these widgets are
   // really needed.
   // PVViewer_GUIElements* inst = PVViewer_GUIElements::GetInstance(aDesktop);
index 9d56dfda96d3014b34b78b4d07f5dae64e6ec7d6..4c12e3930bb1c34f775e0da58bb98a86452246a4 100644 (file)
@@ -38,6 +38,8 @@ class PVVIEWER_EXPORT PVViewer_Core
 {
 public:
   static pqPVApplicationCore* GetPVApplication();
+  static bool ParaViewInitAppCore();
+  static pqPVApplicationCore *GetPVAppCore() { return MyCoreApp; }
 
   //! Initialize ParaView if not yet done (once per session)
   static bool ParaviewInitApp(QMainWindow*);
index e2ab71e3ebc639d81f12db4cb826122dac86b349..ccd03eadd6f56185007c396fc7d168e0d18af47e 100644 (file)
@@ -30,6 +30,7 @@
 #include "SPV3D_ViewModel.h"
 #include "SPV3D_ViewWindow.h"
 #include "SPV3D_Prs.h"
+#include "PVViewer_Core.h"
 
 #include <pqActiveObjects.h>
 #include <pqApplicationCore.h>
@@ -42,6 +43,7 @@
 #include <vtkSMRenderViewProxy.h>
 #include <vtkSMRepresentationProxy.h>
 #include <vtkSMSourceProxy.h>
+#include <vtkSMPVRepresentationProxy.h>
 
 #include "SUIT_ViewModel.h"
 #include "SUIT_ViewManager.h"
@@ -103,15 +105,15 @@ SUIT_ViewWindow* SPV3D_ViewModel::createView( SUIT_Desktop* theDesktop )
   SPV3D_ViewWindow* aViewWindow = new SPV3D_ViewWindow(theDesktop, this);
 
   aViewWindow->SetSelectionEnabled( isSelectionEnabled() );
-
-  QStringList args = QCoreApplication::arguments();
+  PVViewer_Core::ParaViewInitAppCore();
+  /*QStringList args = QCoreApplication::arguments();
   int argc = args.length();
   char **argv = new char *[argc+1];
   for(auto i = 0 ; i < argc ; ++i)
     argv[i] = strdup(args[i].toStdString().c_str());
   argv[argc] = nullptr;
-  pqPVApplicationCore *appPV = new pqPVApplicationCore(argc,argv);
-  QApplication::instance()->installEventFilter(appPV);
+  pqPVApplicationCore *appPV = new pqPVApplicationCore(argc,argv);*/
+  QApplication::instance()->installEventFilter( PVViewer_Core::GetPVAppCore() );
   new pqParaViewBehaviors(aViewWindow,aViewWindow);
   pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
   QObject::connect(builder, &pqObjectBuilder::sourceCreated, this, &SPV3D_ViewModel::onSourceCreated);
@@ -225,14 +227,18 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs )
   DBG_FUN();
   // try do downcast object
   if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( prs )){
-    if(aPrs->IsNull())
-      return;
   pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
+  pqActiveObjects::instance().setActiveView(getView());
   pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer();
   pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"GeometryRepresentation"));
   vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true);
   myRepr->setVisible(1);
   aPrs->SetRepresentation(myRepr);
+  vtkSMPVRepresentationProxy* proxy(dynamic_cast<vtkSMPVRepresentationProxy*>(myRepr->getProxy()));
+  vtkSMPropertyHelper inputHelper(proxy, "Input");
+  vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy());
+  input->UpdatePipeline();
+  getView()->resetDisplay();
   getView()->render();
 #if 0
     if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){