]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 31 Mar 2023 15:42:17 +0000 (17:42 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 31 Mar 2023 15:42:17 +0000 (17:42 +0200)
src/SPV3D/SPV3D_Prs.cxx
src/SPV3D/SPV3D_Prs.h
src/SPV3D/SPV3D_ViewManager.cxx
src/SPV3D/SPV3D_ViewModel.cxx
src/SPV3D/SPV3D_ViewModel.h

index 2ce19a7c0695842247abc1496ce0d058f0ade8fa..8c03e33cc3779d5afe558947df53d63dcaec79ed 100644 (file)
@@ -61,6 +61,11 @@ SPV3D_Prs:: ~SPV3D_Prs()
   if ( myObjects ) myObjects->Delete(); 
 }
 
+void SPV3D_Prs::DisplayIn( SALOME_View* v ) const
+{
+  SALOME_PV3DPrs::DisplayIn(v);
+}
+
 /*!
   \return actors list
 */
index 933fe776fc5e4191b22aeaf513a1768ff3c93585..4aefaec32da77f535522278b12253c39cea61366 100644 (file)
 
 class vtkActorCollection;
 class vtkActor;
+class pqPipelineSource;
+class pqDataRepresentation;
 
 class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs
 {
 public:
   explicit SPV3D_Prs( const char* entry );
-  // Default constructor
   SPV3D_Prs( const char* entry, const vtkActor* obj );
-  // Standard constructor
   ~SPV3D_Prs();
-  // Destructor
+  
+  void DisplayIn( SALOME_View* v ) const override;
+
+  void SetSourceProducer(pqPipelineSource *sourceProducer) { _sourceProducer = sourceProducer; }
+  pqPipelineSource *GetSourceProducer() const { return _sourceProducer; }
+  
+  void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
 
   vtkActorCollection* GetObjects() const;
   // Get actors list
@@ -52,6 +58,8 @@ public:
 
 private:
   vtkActorCollection* myObjects;    // list of actors
+  pqPipelineSource *_sourceProducer = nullptr;
+  mutable pqDataRepresentation *_repr = nullptr;
 };
 
 #endif
index d729ff14f59fd6a58b87145f63ce86b400fbd540..89f04e9f48ab8217388a61c1260112861c82a772 100644 (file)
 
 #include <SUIT_Desktop.h>
 
+#include <pqObjectBuilder.h>
+#include <pqApplicationCore.h>
+#include <pqServerManagerModel.h>
+#include <pqServerResource.h>
+#include <pqView.h>
+#include <pqPVApplicationCore.h>
+
+#include <QVBoxLayout>
+#include <QApplication>
+
 //---------------------------------------------------------
 #define USE_DEBUG
 #define MBCLASSNAME "SPV3D_ViewManager"
@@ -46,9 +56,21 @@ SPV3D_ViewManager::SPV3D_ViewManager( SUIT_Study* study, SUIT_Desktop* theDeskto
 {
   DBG_FUN();
   setTitle( PV3DViewer_ViewManager::tr( "PARAVIEW3D_VIEW_TITLE" ) );
-
+  int argc = 1;
+  char *argv[2];
+  argv[0] = strdup("salome");
+  argv[1] = nullptr;
+  pqPVApplicationCore appPV(argc,argv);
+  QApplication::instance()->installEventFilter(&appPV);
+  pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
+  pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
+  pqView *view=builder->createView(QString("RenderView"),serv);
+  static_cast<SPV3D_ViewModel *>(this->getViewModel())->setView(view);
+  //QVBoxLayout *lay(new QVBoxLayout(theDesktop));
+  //lay->addWidget( view->widget() );
+  view->widget()->setParent( theDesktop);
   // Initialize minimal paraview stuff (if not already done)
-  PVViewer_InitSingleton::Init(theDesktop);
+  //PVViewer_InitSingleton::Init(theDesktop);
 
   connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
            this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
index 5657ad2018e1913375447d697fbf4ebaf5965677..7e660807de79b88334268a8a2875e05eadf8ea34 100644 (file)
@@ -186,6 +186,12 @@ void SPV3D_ViewModel::enableSelection(bool isEnabled)
 
 }
 
+pqView *SPV3D_ViewModel::getView() const
+{
+  return _view;
+  //return pqActiveObjects::instance().activeView();
+}
+
 /*!
   Display presentation
   \param prs - presentation
@@ -197,12 +203,21 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs )
   if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( prs )){
     if(aPrs->IsNull())
       return;
+  pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
+  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);
+  getView()->render();
+#if 0
     if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
       anActorCollection->InitTraversal();
       while(vtkActor* anActor = anActorCollection->GetNextActor()){
         // NYI
       }
     }
+#endif
   }
 }
 
index fde983c611ebcb34da88ddc432d268dd09376f0c..21da9fe7ae0b3ab359a032ad7d8d0227d7b14bf9 100644 (file)
@@ -43,12 +43,16 @@ class PV3DViewer_Actor;
 class pqPipelineSource;
 class pqCADSelection;
 class pqCADGroupModel;
+class pqView;
 
 
 //! Extends two interfaces #SPV3D_ViewModelBase and #SALOME_View 
 class SPV3D_EXPORT SPV3D_ViewModel : public PV3DViewer_ViewModel, public SALOME_View 
 {
   Q_OBJECT
+public:
+  void setView(pqView *view) { _view = view; }
+  pqView *getView() const;
 
 public:
   //! Define string representation of the viewer type
@@ -119,6 +123,7 @@ private:
 
 private:
   bool                 mySelectionEnabled;
+  pqView *_view = nullptr;
 };
 
 #endif