-// VISU OBJECT : interactive object for VISU entities implementation
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// VISU OBJECT : interactive object for VISU entities implementation
// File : VISU_ViewManager_i.cc
// Author : Alexey PETROV
// Module : VISU
-
+//
#include "VISU_ViewManager_i.hh"
#include "VISU_View_i.hh"
#include "VISU_Prs3d_i.hh"
#include "VISU_Table_i.hh"
#include "VISU_Actor.h"
+#include "VISU_ActorFactory.h"
#include "SUIT_Tools.h"
#include "SUIT_Session.h"
#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
-#include "SVTK_RenderWindow.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
#include "SPlot2d_Curve.h"
#include "Plot2d_ViewFrame.h"
+#include "Plot2d_ViewWindow.h"
#include "Plot2d_ViewModel.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+
+#include "SALOME_Event.h"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SALOME_Event.hxx"
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
+#include <QApplication>
+
using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
struct TNewViewManagerEvent: public SALOME_Event
{
- std::string myStudyName;
+ int myStudyId;
typedef SalomeApp_Application* TResult;
TResult myResult;
- TNewViewManagerEvent(const char* theStudyName):
- myStudyName(theStudyName),
+ TNewViewManagerEvent (const int theStudyId):
+ myStudyId(theStudyId),
myResult(NULL)
{}
void
Execute()
{
+ MESSAGE("Find application for study with id = : " << myStudyId);
SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> anApplications = aSession->applications();
- QPtrListIterator<SUIT_Application> anIter(anApplications);
- while(SUIT_Application* anApp = anIter.current()){
- ++anIter;
- if(SUIT_Study* aSStudy = anApp->activeStudy()){
- if(SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)){
- if(_PTR(Study) aCStudy = aStudy->studyDS()){
- if(myStudyName == aCStudy->Name()){
- myResult = dynamic_cast<SalomeApp_Application*>(anApp);
- break;
+ QList<SUIT_Application*> anApplications = aSession->applications();
+ QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+ while ( anIter != anApplications.end() ) {
+ SUIT_Application* anApp = *anIter;
+ if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ //if (myStudyName == aCStudy->Name()) {
+ if (myStudyId == aCStudy->StudyId()) {
+ myResult = dynamic_cast<SalomeApp_Application*>(anApp);
+ break;
}
}
}
}
+ anIter++;
+ }
+ if (!myResult) {
+ //MESSAGE("Error: application is not found for study : " << myStudyName);
+ MESSAGE("Error: application is not found for study with id = : " << myStudyId);
}
}
};
{
if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i - "<<this);
- CORBA::String_var aStudyName = theStudy->Name();
- myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
+ //CORBA::String_var aStudyName = theStudy->Name();
+ //myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
+ int aStudyID = theStudy->StudyId();
+ myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyID));
}
struct TCurrentViewEvent: public SALOME_Event
{
- const SalomeApp_Application* myApplication;
+ SalomeApp_Application* myApplication;
typedef VISU::View_ptr TResult;
TResult myResult;
- TCurrentViewEvent(const SalomeApp_Application* theApplication):
+ TCurrentViewEvent(SalomeApp_Application* theApplication):
myApplication(theApplication),
myResult(VISU::View::_nil())
{}
void
Execute()
{
- //if (SUIT_ViewManager *aViewManager = myApplication->activeViewManager()) {
- // if (aViewManager->getType() == "VTKViewer") {
- // if (SUIT_ViewWindow *aViewWindow = aViewManager->getActiveView()) {
- VISU::View3D_i* pView =
- new View3D_i ((SalomeApp_Application*)myApplication);
- if (pView->Create(0))
- myResult = pView->_this();
- // }
- // }
- //}
+ VISU::View3D_i* aView = new View3D_i (myApplication);
+ if (aView->Create(0))
+ myResult = aView->_this();
}
};
template<class TViewFrame>
struct TCreateViewFrameEvent: public SALOME_Event
{
- //const SUIT_Application* myApplication;
SalomeApp_Application* myApplication;
typedef typename TViewFrame::TInterface TInterface;
typedef typename TInterface::_ptr_type TResult;
TResult myResult;
- //TCreateViewFrameEvent (const SUIT_Application* theApplication):
TCreateViewFrameEvent (SalomeApp_Application* theApplication):
myApplication(theApplication),
myResult(TInterface::_nil())
void
Execute()
{
- //if (CheckStudy(myStudyDocument)){
+ //if (CheckStudy(myStudyDocument)) {
+ if (myApplication) {
TViewFrame* pView = new TViewFrame (myApplication);
- if (pView->Create(1))
+ if (pView->Create(1)) {
myResult = pView->_this();
- //}
+ qApp->processEvents(); // Fix for bug 9929
+ }
+ }
}
};
//===========================================================================
// VISU namespace functions
//===========================================================================
- SVTK_ViewWindow* GetViewWindow (SUIT_ViewWindow* theStudyFrame)
+ vtkRenderer* GetRenderer (SUIT_ViewWindow* theViewWindow)
{
- return dynamic_cast<SVTK_ViewWindow*>(theStudyFrame);
- }
-
- vtkRenderer* GetRenderer (SUIT_ViewWindow* theStudyFrame)
- {
- return GetViewWindow(theStudyFrame)->getRenderer();
+ if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(theViewWindow))
+ return vw->getRenderer();
+ return NULL;
}
- vtkCamera* GetCamera (SUIT_ViewWindow* theStudyFrame)
+ vtkCamera* GetCamera (SUIT_ViewWindow* theViewWindow)
{
- return GetRenderer(theStudyFrame)->GetActiveCamera();
+ return GetRenderer(theViewWindow)->GetActiveCamera();
}
void RepaintView (SUIT_ViewWindow* theViewWindow)
{
- SVTK_ViewWindow* vf = GetViewWindow(theViewWindow);
- vf->getRenderer()->ResetCameraClippingRange();
- vf->getRenderWindow()->getRenderWindow()->Render();
+ if (SVTK_ViewWindow* vf = dynamic_cast<SVTK_ViewWindow*>(theViewWindow)) {
+ vf->getRenderer()->ResetCameraClippingRange();
+ vf->getRenderWindow()->Render();
+ }
}
- VISU_Actor* UpdateViewer (SUIT_ViewWindow* theStudyFrame, int theDisplaing, Prs3d_i* thePrs)
+ VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs)
{
- SVTK_ViewWindow* vf = GetViewWindow(theStudyFrame);
+ SVTK_ViewWindow* vf = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
if (!vf) return NULL;
if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
vtkRenderer *aRen = vf->getRenderer();
if(anActor->IsA("VISU_Actor")){
anVISUActor = VISU_Actor::SafeDownCast(anActor);
if (thePrs == anVISUActor->GetPrs3d()) {
- aResActor = anVISUActor->GetParent();
+ aResActor = anVISUActor;
if(theDisplaing < eErase)
aResActor->VisibilityOn();
else
}
}
if (aResActor) {
- RepaintView(theStudyFrame);
+ RepaintView(theViewWindow);
return aResActor;
}
if(thePrs != NULL && theDisplaing < eErase){
return NULL;
}
}
- RepaintView(theStudyFrame);
+ RepaintView(theViewWindow);
return anVISUActor;
}
if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = " << theDisplaying);
if (!theView)
return;
- QList<Plot2d_Curve> clist;
+ QList<Plot2d_Curve*> clist;
theView->getCurves(clist);
if (theDisplaying == eEraseAll) {
for (int i = 0; i < clist.count(); i++) {
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
- !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+ !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC);
theView->eraseCurve(aSPlot2dC);
}
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
- !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+ !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
double* xList = 0;
double* yList = 0;
- int nbPoints = theCurve->GetData( xList, yList );
+ QStringList zList;
+ int nbPoints = theCurve->GetData( xList, yList, zList );
if (nbPoints > 0 && xList && yList) {
- aSPlot2dC->setData( xList, yList, nbPoints );
+ aSPlot2dC->setData( xList, yList, nbPoints, zList );
}
if (!theCurve->IsAuto()) {
- aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(),
+ aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(),
theCurve->GetLineWidth());
- aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker());
+ aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker());
SALOMEDS::Color color = theCurve->GetColor();
aSPlot2dC->setColor(QColor((int)(color.R*255.),
(int)(color.G*255.),
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
- !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+ !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC);
aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
double* xList = 0;
double* yList = 0;
- int nbPoints = theCurve->GetData( xList, yList );
+ QStringList zList;
+ int nbPoints = theCurve->GetData( xList, yList, zList );
if ( nbPoints > 0 && xList && yList ) {
- aSPlot2dC->setData( xList, yList, nbPoints );
+ aSPlot2dC->setData( xList, yList, nbPoints, zList );
}
if ( !theCurve->IsAuto() ) {
- aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth());
- aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker());
+ aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth());
+ aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker());
SALOMEDS::Color color = theCurve->GetColor();
aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.)));
}
}
}
- VISU_Actor* GetActor (VISU::Prs3d_i* thePrs3d, SVTK_ViewWindow* theVTKFrame)
+
+ //----------------------------------------------------------------------------
+ struct TIsSamePrs3d
{
- vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
- anActColl->InitTraversal();
- while (vtkActor *anActor = anActColl->GetNextActor())
- if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
- if (thePrs3d == anVISUActor->GetPrs3d())
- return anVISUActor->GetParent();
- return NULL;
+ VISU::Prs3d_i* myPrs3d;
+
+ TIsSamePrs3d(VISU::Prs3d_i* thePrs3d):
+ myPrs3d(thePrs3d)
+ {}
+
+ bool
+ operator()(VISU_Actor* theActor)
+ {
+ return theActor->GetPrs3d() == myPrs3d;
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ VISU_Actor*
+ FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d)
+ {
+ if(!thePrs3d)
+ return NULL;
+
+ vtkRenderer* aRenderer = theViewWindow->getRenderer();
+ vtkActorCollection* anActors = aRenderer->GetActors();
+ return SVTK::Find<VISU_Actor>(anActors, VISU::TIsSamePrs3d(thePrs3d));
+ }
+
+
+ //----------------------------------------------------------------------------
+ struct TIsSameActor
+ {
+ VISU::TActorFactory* myActor;
+
+ TIsSameActor(VISU::TActorFactory* theActor):
+ myActor(theActor)
+ {}
+
+ bool
+ operator()(VISU_ActorBase* theActor)
+ {
+ return theActor->GetFactory() == myActor;
+ }
+ };
+
+ //----------------------------------------------------------------------------
+ VISU_ActorBase*
+ FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor)
+ {
+ if(!theActor)
+ return NULL;
+
+ vtkRenderer* aRenderer = theViewWindow->getRenderer();
+ vtkActorCollection* anActors = aRenderer->GetActors();
+ return SVTK::Find<VISU_ActorBase>(anActors, VISU::TIsSameActor(theActor));
+ }
+
+
+ //----------------------------------------------------------------------------
+ struct TDeleteActorsEvent: public SALOME_Event
+ {
+ VISU::Curve_i* myPrs;
+
+ TDeleteActorsEvent (VISU::Curve_i* thePrs):
+ myPrs(thePrs)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ if (!myPrs) return;
+
+ // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+ SALOMEDS::Study_var myStudyDocument = myPrs->GetStudyDocument();
+ SalomeApp_Application* anApp = NULL;
+ CORBA::String_var studyName = myStudyDocument->Name();
+ std::string aStudyName = studyName.in();
+ SUIT_Session* aSession = SUIT_Session::session();
+ QList<SUIT_Application*> anApplications = aSession->applications();
+ QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+ while ( anIter != anApplications.end() ) {
+ SUIT_Application* aSUITApp = *anIter;
+ if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ if (aStudyName == aCStudy->Name()) {
+ anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+ break;
+ }
+ }
+ }
+ }
+ anIter++;
+ }
+ if (!anApp)
+ return;
+
+ // 2. Remove corresponding IO from selection
+ SALOMEDS::SObject_var aSObject = myPrs->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+ SALOME_ListIO aListIO, aNewListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+
+ for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+ if (it.Value()->hasEntry()) {
+ std::string aCurEntry (it.Value()->getEntry());
+ if (aCurEntry != std::string( anEntry.in() ) ) {
+ aNewListIO.Append(it.Value());
+ }
+ }
+ }
+
+ aSelectionMgr->setSelectedObjects(aNewListIO);
+
+ // 3. Remove Actors
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+ QList<SUIT_ViewManager*>::Iterator anVMIter = aViewManagerList.begin();
+ for (; anVMIter != aViewManagerList.end(); anVMIter++ ) {
+ SUIT_ViewManager* aViewManager = *anVMIter;
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+ if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+ if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
+ Plot2d_ViewFrame* vf = vw->getViewFrame();
+ QList<Plot2d_Curve*> clist;
+ vf->getCurves(clist);
+ for (int i = 0; i < clist.count(); i++) {
+ if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
+ if (cu->hasIO() &&
+ strcmp(myPrs->GetEntry().c_str(), cu->getIO()->getEntry())) {
+ vf->eraseCurve(cu);
+ }
+ }
+ }
+ vf->Repaint();
+ //jfa tmp:aViewFrame->unHighlightAll();
+ }
+ }
+ }
+ }
+ }
+ };
+
+ void DeleteActors (VISU::Curve_i* thePrs)
+ {
+ if (!thePrs) return;
+ ProcessVoidEvent(new TDeleteActorsEvent (thePrs));
+
+/* // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+ SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
+ SalomeApp_Application* anApp = NULL;
+ CORBA::String_var studyName = myStudyDocument->Name();
+ std::string aStudyName = studyName.in();
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> anApplications = aSession->applications();
+ QPtrListIterator<SUIT_Application> anIter (anApplications);
+ while (SUIT_Application* aSUITApp = anIter.current()) {
+ ++anIter;
+ if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ if (aStudyName == aCStudy->Name()) {
+ anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!anApp)
+ return;
+
+ // 2. Remove corresponding IO from selection
+ SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+ SALOME_ListIO aListIO, aNewListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+
+ for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+ if (it.Value()->hasEntry()) {
+ std::string aCurEntry (it.Value()->getEntry());
+ if (aCurEntry != std::string( anEntry.in() ) ) {
+ aNewListIO.Append(it.Value());
+ }
+ }
+ }
+
+ aSelectionMgr->setSelectedObjects(aNewListIO);
+
+ // 3. Remove Actors
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+ QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
+ for (; anVMIter.current(); ++anVMIter) {
+ SUIT_ViewManager* aViewManager = anVMIter.current();
+ QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+ for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+ if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+ if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
+ Plot2d_ViewFrame* vf = vw->getViewFrame();
+ QList<Plot2d_Curve> clist;
+ vf->getCurves(clist);
+ for (int i = 0; i < clist.count(); i++) {
+ if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
+ if (cu->hasIO() &&
+ strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) {
+ vf->eraseCurve(cu);
+ }
+ }
+ }
+ vf->Repaint();
+ //jfa tmp:aViewFrame->unHighlightAll();
+ }
+ }
+ }
+}*/
+ }
+
+ void DeleteActors (VISU::Prs3d_i* thePrs)
+ {
+ if (!thePrs) return;
+
+ // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+ SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
+ SalomeApp_Application* anApp = NULL;
+ CORBA::String_var studyName = myStudyDocument->Name();
+ std::string aStudyName = studyName.in();
+ SUIT_Session* aSession = SUIT_Session::session();
+ QList<SUIT_Application*> anApplications = aSession->applications();
+ QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+ while (anIter != anApplications.end()) {
+ SUIT_Application* aSUITApp = *anIter;
+ if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ if (aStudyName == aCStudy->Name()) {
+ anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+ break;
+ }
+ }
+ }
+ }
+ anIter++;
+ }
+ if (!anApp)
+ return;
+
+ // 2. Remove corresponding IO from selection
+ SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+ SALOME_ListIO aListIO, aNewListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+
+ for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+ if (it.Value()->hasEntry()) {
+ std::string aCurEntry (it.Value()->getEntry());
+ if (aCurEntry != std::string( anEntry.in() ) ) {
+ aNewListIO.Append(it.Value());
+ }
+ }
+ }
+
+ aSelectionMgr->setSelectedObjects(aNewListIO);
+
+ // 3. Remove Actors
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+ QList<SUIT_ViewManager*>::Iterator anVMIter = aViewManagerList.begin();
+ for (; anVMIter != aViewManagerList.end(); anVMIter++ ) {
+ SUIT_ViewManager* aViewManager = *anVMIter;
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+ if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+ if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
+ VISU_Actor* anActor = NULL;
+ vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
+ anActColl->InitTraversal();
+ vtkActor *aVTKActor = anActColl->GetNextActor();
+ for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
+ if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
+ if (thePrs == anVISUActor->GetPrs3d()) {
+ anActor = anVISUActor;
+ }
+ }
+ }
+ if (anActor) {
+ vw->RemoveActor(anActor);
+ }
+ }
+ }
+ }
+ }
}
}