#include <vtkActorCollection.h>
+#include <pqDataRepresentation.h>
+
//---------------------------------------------------------
#define USE_DEBUG
#define MBCLASSNAME "SPV3D_Prs"
/*!
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
SPV3D_Prs:: ~SPV3D_Prs()
{
DBG_FUN();
- if ( myObjects ) myObjects->Delete();
}
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);
}
-// 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
// 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"
{
public:
explicit SPV3D_Prs( const char* entry );
- SPV3D_Prs( const char* entry, const vtkActor* obj );
~SPV3D_Prs();
void DisplayIn( SALOME_View* v ) const override;
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
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.
pqView *SPV3D_ViewModel::getView() const
{
return _view;
- //return pqActiveObjects::instance().activeView();
}
/*!
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 )){
- 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()){
- anActorCollection->InitTraversal();
- while(vtkActor* anActor = anActorCollection->GetNextActor()){
- // NYI
- }
+
+ if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( 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<vtkSMPVRepresentationProxy*>(myRepr->getProxy()));
+ vtkSMPropertyHelper inputHelper(proxy, "Input");
+ vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy());
+ input->UpdatePipeline();
+ getView()->resetDisplay();
+ getView()->render();
}
}
if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( 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);
}
}
DBG_FUN();
SALOME_View::EraseAll( d, forced );
-
+ if(SPV3D_ViewWindow* aViewWindow = dynamic_cast<SPV3D_ViewWindow*>(getViewManager()->getActiveView()))
+ aViewWindow->EraseAll();
Repaint();
}
ARG(entry);
SPV3D_Prs* prs = new SPV3D_Prs( entry );
if ( entry ) {
- if(SPV3D_ViewWindow* aViewWindow = dynamic_cast<SPV3D_ViewWindow*>(getViewManager()->getActiveView())) {
- // if(SPV3D_View* aView = aViewWindow->getView()){
- // // NYI
- // }
+ if(SPV3D_ViewWindow* aViewWindow = dynamic_cast<SPV3D_ViewWindow*>(getViewManager()->getActiveView()))
+ {
+ aViewWindow->appendPrs( prs );
}
}
return prs;
*/
bool SPV3D_ViewModel::isVisible( const Handle(SALOME_InteractiveObject)& io )
{
- // NYI
+ if(SPV3D_ViewWindow* aViewWindow = dynamic_cast<SPV3D_ViewWindow*>(getViewManager()->getActiveView()))
+ return aViewWindow->isVisible( io );
return false;
}
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"; }
#include "QtxActionGroup.h"
#include "SALOME_ListIO.hxx"
+#include "SPV3D_Prs.h"
//---------------------------------------------------------
#define USE_DEBUG
setCentralWidget( myModel->getView()->widget() );
}
+void SPV3D_ViewWindow::appendPrs( SPV3D_Prs* prs )
+{
+ myPrs.push_back(prs);
+}
+
/*!
Destructor
*/
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
bool theImmediatly)
{
DBG_FUN();
-
- // NYI
}
/*!
void SPV3D_ViewWindow::EraseAll()
{
DBG_FUN();
- // NYI
+ for(auto prs : myPrs)
+ {
+ prs->hide();
+ }
+ if(myModel)
+ myModel->render();
}
/*!
void SPV3D_ViewWindow::Repaint(bool )//(bool theUpdateTrihedron)
{
// NYI
+ if(myModel)
+ myModel->render();
}
/*!
#include <QImage>
#include <vtkSmartPointer.h>
+#include <list>
+
class SUIT_Desktop;
class SUIT_ResourceMgr;
class SPV3D_KeyFreeInteractorStyle;
class SPV3D_ViewParameterDlg;
class SPV3D_Recorder;
+class SPV3D_Prs;
namespace salomevtk
{
//! 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 */
//----------------------------------------------------------------------------
protected:
SPV3D_ViewModel* myModel;
+ std::list< SPV3D_Prs* > myPrs;
};
#ifdef WIN32