From 76b9b7e98fc1a6c139c65b8d925a48c59081a1ff Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 31 Mar 2023 17:42:17 +0200 Subject: [PATCH] WIP --- src/SPV3D/SPV3D_Prs.cxx | 5 +++++ src/SPV3D/SPV3D_Prs.h | 14 +++++++++++--- src/SPV3D/SPV3D_ViewManager.cxx | 26 ++++++++++++++++++++++++-- src/SPV3D/SPV3D_ViewModel.cxx | 15 +++++++++++++++ src/SPV3D/SPV3D_ViewModel.h | 5 +++++ 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index 2ce19a7c0..8c03e33cc 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -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 */ diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index 933fe776f..4aefaec32 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -31,16 +31,22 @@ 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 diff --git a/src/SPV3D/SPV3D_ViewManager.cxx b/src/SPV3D/SPV3D_ViewManager.cxx index d729ff14f..89f04e9f4 100644 --- a/src/SPV3D/SPV3D_ViewManager.cxx +++ b/src/SPV3D/SPV3D_ViewManager.cxx @@ -32,6 +32,16 @@ #include +#include +#include +#include +#include +#include +#include + +#include +#include + //--------------------------------------------------------- #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(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* ) ) ); diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx index 5657ad201..7e660807d 100644 --- a/src/SPV3D/SPV3D_ViewModel.cxx +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -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( 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 } } diff --git a/src/SPV3D/SPV3D_ViewModel.h b/src/SPV3D/SPV3D_ViewModel.h index fde983c61..21da9fe7a 100644 --- a/src/SPV3D/SPV3D_ViewModel.h +++ b/src/SPV3D/SPV3D_ViewModel.h @@ -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 -- 2.39.2