From e06f87b07601d15bf1f92b599acd52f44ac5f51f Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 6 Mar 2023 19:12:23 +0000 Subject: [PATCH] First integration of a new PV3D viewer. --- CMakeLists.txt | 2 +- src/GEOMGUI/GEOM_Displayer.cxx | 80 +++++++++++++++++++++++++++++++--- src/GEOMGUI/GEOM_Displayer.h | 3 ++ src/GEOMGUI/GeometryGUI.cxx | 11 +++++ 4 files changed, 90 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66554ec1c..ce951a798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ IF(SALOME_BUILD_GUI) IF(EXISTS ${GUI_ROOT_DIR}) FIND_PACKAGE(SalomeGUI) SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA - SALOME_GUI_MODE(SALOME_USE_OCCVIEWER SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT + SALOME_GUI_MODE(SALOME_USE_OCCVIEWER SALOME_USE_VTKVIEWER SALOME_USE_PV3DVIEWER SALOME_USE_SALOMEOBJECT OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_PYCONSOLE) ADD_DEFINITIONS(${GUI_DEFINITIONS}) INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS}) diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index cc78136fe..3dbee39b9 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -77,10 +78,31 @@ #include #include +#include +#include + #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + // OCCT Includes #include #include @@ -126,6 +148,11 @@ #include +#include "vtkSMSourceProxy.h" +#include "pqServerManagerModel.h" +#include "vtkPVTrivialProducer.h" +#include "vtkSMViewProxy.h" + #if OCC_VERSION_LARGE >= 0x070400ff #include #endif @@ -1688,6 +1715,44 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) } } +//================================================================= +/*! + * GEOM_Displayer::Update + * Update PV3D presentation + * [ Reimplemented from SALOME_Displayer ] + */ +//================================================================= +void GEOM_Displayer::Update( SALOME_PV3DPrs* prs ) +{ + SPV3D_Prs* pv3dPrs = dynamic_cast( prs ); + + SalomeApp_Study* study = getStudy(); + + if ( !pv3dPrs || myShape.IsNull() || !study ) + return; + + if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) + { + // + // specific processing for local coordinate system presentation + // + // NYI - Update(PV3DPrs) for the local coordinate system + } + else + { + // + // processing for usual geometry presentation + // + { + pv3dPrs->SetName( myNameInObjBrowser ); + GEOM_Actor *actor = GEOM_Actor::New(); + updateActorProperties( actor, true ); + pv3dPrs->FillUsingActor( actor ); + } + } +} + + //================================================================= /*! * GEOM_Displayer::BuildPrs @@ -1783,6 +1848,7 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry, GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object ); if ( !GeomBaseObject->_is_nil() ) { + myNameInObjBrowser = getName( GeomBaseObject ); myType = GeomBaseObject->GetType(); // downcast to GEOM object @@ -2381,11 +2447,15 @@ bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer { _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toUtf8() ); //if ( ! GeometryGUI::IsInGeomComponent( anObj )) return false; - GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects - GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps - GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component - return ( !CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ) ) && - (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type()); + CORBA::Object_var anOrbObj = GeometryGUI::ClientSObjectToObject(anObj); + bool isCorbaObj = (!CORBA::is_nil(anOrbObj)); + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anOrbObj); // enable displaying of GEOM objects + GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(anOrbObj); // enable displaying of GEOM field steps + GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(anOrbObj); // enable displaying of whole GEOM component + bool isGeomObj = (!CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj )); + bool ret = ( isGeomObj ) && + (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type() || viewer_type == SPV3D_ViewModel::Type()); + return ret; } int GEOM_Displayer::SetDisplayMode( const int theMode ) diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index 6a1897221..73d7e8236 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -38,6 +38,7 @@ class SALOME_View; class SALOME_Prs; class SALOME_OCCPrs; class SALOME_VTKPrs; +class SALOME_PV3DPrs; class SALOME_OCCViewType; #include @@ -187,6 +188,7 @@ public: /* Reimplemented from SALOME_Displayer */ virtual void Update( SALOME_OCCPrs* ); virtual void Update( SALOME_VTKPrs* ); + virtual void Update( SALOME_PV3DPrs* ); virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ); virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ); virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* ); @@ -282,6 +284,7 @@ protected: TCollection_AsciiString myFieldStepName; double myFieldStepRangeMin; double myFieldStepRangeMax; + std::string myNameInObjBrowser; std::string myName; std::string myTexture; int myType; diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index e6724c4fb..163ef5ec6 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -60,6 +60,10 @@ #include #include +#include +#include +#include + #include #include @@ -372,6 +376,7 @@ void GeometryGUI::ActiveWorkingPlane() SUIT_ViewWindow* window = application()->desktop()->activeWindow(); bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); + bool ViewPV3D = ( window && window->getViewManager()->getType() == PV3DViewer_ViewModel::Type() ); if ( ViewOCC ) { OCCViewer_ViewWindow* vw = dynamic_cast( window ); @@ -395,6 +400,11 @@ void GeometryGUI::ActiveWorkingPlane() vw->onFitAll(); } } + else if ( ViewPV3D ) { + PV3DViewer_ViewWindow* vw = dynamic_cast( window ); + if ( vw ) { + } + } } //======================================================================= @@ -2097,6 +2107,7 @@ void GeometryGUI::windows( QMap& mappa ) const void GeometryGUI::viewManagers( QStringList& lst ) const { lst.append( OCCViewer_Viewer::Type() ); + //lst.append( PV3DViewer_ViewModel::Type() ); } void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )