From: Anthony Geay Date: Wed, 5 Apr 2023 15:46:53 +0000 (+0200) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aba924a34610351336aa79e9dd9158bdb4e50306;p=modules%2Fgui.git WIP --- diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index 8c03e33cc..cc520896c 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -27,6 +27,8 @@ #include +#include + //--------------------------------------------------------- #define USE_DEBUG #define MBCLASSNAME "SPV3D_Prs" @@ -36,21 +38,11 @@ /*! Default constructor */ -SPV3D_Prs::SPV3D_Prs( const char* entry ) : SALOME_PV3DPrs(entry), myObjects( 0 ) +SPV3D_Prs::SPV3D_Prs( const char* entry ) : SALOME_PV3DPrs(entry) { DBG_FUN(); ARG(entry); } - -/*! - Standard constructor -*/ -SPV3D_Prs::SPV3D_Prs( const char* entry, const vtkActor* obj ) : SALOME_PV3DPrs(entry) -{ - DBG_FUN(); - ARG(entry); - AddObject( obj ); -} /*! Destructor @@ -58,7 +50,6 @@ SPV3D_Prs::SPV3D_Prs( const char* entry, const vtkActor* obj ) : SALOME_PV3DPrs( SPV3D_Prs:: ~SPV3D_Prs() { DBG_FUN(); - if ( myObjects ) myObjects->Delete(); } void SPV3D_Prs::DisplayIn( SALOME_View* v ) const @@ -66,29 +57,20 @@ void SPV3D_Prs::DisplayIn( SALOME_View* v ) const SALOME_PV3DPrs::DisplayIn(v); } -/*! - \return actors list -*/ -vtkActorCollection* SPV3D_Prs::GetObjects() const -{ - return myObjects; +bool SPV3D_Prs::IsNull() const +{ + return !_sourceProducer && !_repr; } -/*! - Add actor -*/ -void SPV3D_Prs::AddObject( const vtkActor* obj ) -{ - DBG_FUN(); - if ( !myObjects) - myObjects = vtkActorCollection::New(); - myObjects->AddItem( (vtkActor*)obj ); +bool SPV3D_Prs::isVisible() const +{ + if( IsNull() ) + return false; + return _repr->isVisible(); } - -/*! - \return 0 if list of the actors is empty [ Reimplemented from SALOME_Prs ] -*/ -bool SPV3D_Prs::IsNull() const -{ - return !myObjects || myObjects->GetNumberOfItems() <= 0; + +void SPV3D_Prs::hide() const +{ + if( _repr ) + _repr->setVisible(0); } diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index 4aefaec32..36318017e 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -1,7 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -20,11 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SALOME PV3DViewer : build PV3D viewer into Salome desktop -// File : SPV3D_Prs.h - -#ifndef SPV3D_Prs_H -#define SPV3D_Prs_H +#pragma once #include "SPV3D.h" #include "SALOME_Prs.h" @@ -38,7 +31,6 @@ class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs { public: explicit SPV3D_Prs( const char* entry ); - SPV3D_Prs( const char* entry, const vtkActor* obj ); ~SPV3D_Prs(); void DisplayIn( SALOME_View* v ) const override; @@ -47,19 +39,15 @@ public: pqPipelineSource *GetSourceProducer() const { return _sourceProducer; } void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; } + pqDataRepresentation *GetRepresentation() const { return _repr; } - vtkActorCollection* GetObjects() const; - // Get actors list - void AddObject( const vtkActor* obj ); - // Add actor - - bool IsNull() const; - // Reimplemented from SALOME_Prs + bool IsNull() const override; + +public: + void hide() const; + bool isVisible() const; private: - vtkActorCollection* myObjects; // list of actors pqPipelineSource *_sourceProducer = nullptr; mutable pqDataRepresentation *_repr = nullptr; }; - -#endif diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx index ccd03eadd..952f5a620 100644 --- a/src/SPV3D/SPV3D_ViewModel.cxx +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -95,6 +95,11 @@ void SPV3D_ViewModel::initialize() DBG_FUN(); } +void SPV3D_ViewModel::render() const +{ + if( _view ) + _view->render(); +} /*!Create new instance of view window on desktop \a theDesktop. *\retval SUIT_ViewWindow* - created view window pointer. @@ -215,7 +220,6 @@ void SPV3D_ViewModel::enableSelection(bool isEnabled) pqView *SPV3D_ViewModel::getView() const { return _view; - //return pqActiveObjects::instance().activeView(); } /*! @@ -225,29 +229,26 @@ pqView *SPV3D_ViewModel::getView() const void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) { DBG_FUN(); - // try do downcast object - if(const SPV3D_Prs* aPrs = dynamic_cast( prs )){ - 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(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()){ - anActorCollection->InitTraversal(); - while(vtkActor* anActor = anActorCollection->GetNextActor()){ - // NYI - } + + if(const SPV3D_Prs* aPrs = dynamic_cast( prs )) + { + if( !aPrs->GetRepresentation() ) + { + 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); + aPrs->SetRepresentation(myRepr); } -#endif + pqDataRepresentation* myRepr = aPrs->GetRepresentation(); + myRepr->setVisible(1); + vtkSMPVRepresentationProxy* proxy(dynamic_cast(myRepr->getProxy())); + vtkSMPropertyHelper inputHelper(proxy, "Input"); + vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()); + input->UpdatePipeline(); + getView()->resetDisplay(); + getView()->render(); } } @@ -264,11 +265,11 @@ void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool forced ) if(const SPV3D_Prs* aPrs = dynamic_cast( prs )){ if(aPrs->IsNull()) return; - - pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); - pqServer* activeServer = pqActiveObjects::instance().activeServer(); - - builder->destroySources(activeServer); + aPrs->GetRepresentation()->setVisible(0); + getView()->render(); + //pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); + //pqServer* activeServer = pqActiveObjects::instance().activeServer(); + //builder->destroySources(activeServer); } } @@ -281,7 +282,8 @@ void SPV3D_ViewModel::EraseAll( SALOME_Displayer* d, const bool forced ) DBG_FUN(); SALOME_View::EraseAll( d, forced ); - + if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + aViewWindow->EraseAll(); Repaint(); } @@ -295,10 +297,9 @@ SALOME_Prs* SPV3D_ViewModel::CreatePrs( const char* entry ) ARG(entry); SPV3D_Prs* prs = new SPV3D_Prs( entry ); if ( entry ) { - if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) { - // if(SPV3D_View* aView = aViewWindow->getView()){ - // // NYI - // } + if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + { + aViewWindow->appendPrs( prs ); } } return prs; @@ -310,7 +311,8 @@ SALOME_Prs* SPV3D_ViewModel::CreatePrs( const char* entry ) */ bool SPV3D_ViewModel::isVisible( const Handle(SALOME_InteractiveObject)& io ) { - // NYI + if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + return aViewWindow->isVisible( io ); return false; } diff --git a/src/SPV3D/SPV3D_ViewModel.h b/src/SPV3D/SPV3D_ViewModel.h index 21da9fe7a..1c9c9469b 100644 --- a/src/SPV3D/SPV3D_ViewModel.h +++ b/src/SPV3D/SPV3D_ViewModel.h @@ -53,7 +53,7 @@ class SPV3D_EXPORT SPV3D_ViewModel : public PV3DViewer_ViewModel, public SALOME_ public: void setView(pqView *view) { _view = view; } pqView *getView() const; - + void render() const; public: //! Define string representation of the viewer type static QString Type() { return "ParaView3D"; } diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index bb97d3da7..d8daba0e3 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -51,6 +51,7 @@ #include "QtxActionGroup.h" #include "SALOME_ListIO.hxx" +#include "SPV3D_Prs.h" //--------------------------------------------------------- #define USE_DEBUG @@ -79,6 +80,11 @@ void SPV3D_ViewWindow::init() setCentralWidget( myModel->getView()->widget() ); } +void SPV3D_ViewWindow::appendPrs( SPV3D_Prs* prs ) +{ + myPrs.push_back(prs); +} + /*! Destructor */ @@ -87,6 +93,17 @@ SPV3D_ViewWindow::~SPV3D_ViewWindow() DBG_FUN(); } +bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject) +{ + std::string ior( theIObject->getEntry() ); + for(auto prs : myPrs) + { + if(ior == prs->GetEntry() ) + return prs->isVisible(); + } + return false; +} + /*! Display object \param theIO - object @@ -109,8 +126,6 @@ void SPV3D_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, bool theImmediatly) { DBG_FUN(); - - // NYI } /*! @@ -139,7 +154,12 @@ void SPV3D_ViewWindow::DisplayAll() void SPV3D_ViewWindow::EraseAll() { DBG_FUN(); - // NYI + for(auto prs : myPrs) + { + prs->hide(); + } + if(myModel) + myModel->render(); } /*! @@ -148,6 +168,8 @@ void SPV3D_ViewWindow::EraseAll() void SPV3D_ViewWindow::Repaint(bool )//(bool theUpdateTrihedron) { // NYI + if(myModel) + myModel->render(); } /*! diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h index eeada3ec3..d68b4a929 100644 --- a/src/SPV3D/SPV3D_ViewWindow.h +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -37,6 +37,8 @@ #include #include +#include + class SUIT_Desktop; class SUIT_ResourceMgr; @@ -65,6 +67,7 @@ class SPV3D_InteractorStyle; class SPV3D_KeyFreeInteractorStyle; class SPV3D_ViewParameterDlg; class SPV3D_Recorder; +class SPV3D_Prs; namespace salomevtk { @@ -84,9 +87,13 @@ class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow //SUIT_ViewWi //! To construct #SPV3D_ViewWindow instance SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel); + void appendPrs( SPV3D_Prs* prs ); + void init(); virtual ~SPV3D_ViewWindow(); + + bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject); /* display */ //---------------------------------------------------------------------------- @@ -131,6 +138,7 @@ protected slots: protected: SPV3D_ViewModel* myModel; + std::list< SPV3D_Prs* > myPrs; }; #ifdef WIN32