1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_ViewManager_i.cc
25 // Author : Alexey PETROV
28 #include "VISU_ViewManager_i.hh"
29 #include "VISU_View_i.hh"
30 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Table_i.hh"
32 #include "VISU_Tools.h"
34 #include "VISU_Actor.h"
35 #include "VISU_ActorFactory.h"
37 #include "SUIT_Tools.h"
38 #include "SUIT_Session.h"
39 #include "SUIT_ViewWindow.h"
40 #include "SUIT_ViewManager.h"
42 #include "SVTK_ViewWindow.h"
43 #include "SVTK_ViewModel.h"
44 #include "VTKViewer_Algorithm.h"
45 #include "SPlot2d_Curve.h"
46 #include "SPlot2d_ViewModel.h"
47 #include "Plot2d_ViewFrame.h"
48 #include "Plot2d_ViewWindow.h"
49 #include "Plot2d_ViewModel.h"
50 #include "Plot2d_ViewManager.h"
52 #include "SalomeApp_Study.h"
53 #include "SalomeApp_Application.h"
54 #include "LightApp_SelectionMgr.h"
56 #include "SALOME_Event.h"
57 #include "SALOME_ListIO.hxx"
58 #include "SALOME_ListIteratorOfListIO.hxx"
60 #include "VTKViewer_Algorithm.h"
61 #include "SVTK_Functor.h"
63 #include <vtkCamera.h>
64 #include <vtkRenderer.h>
65 #include <vtkRenderWindow.h>
67 #include <QApplication>
72 static int MYDEBUG = 0;
74 static int MYDEBUG = 0;
79 struct TNewViewManagerEvent: public SALOME_Event
82 typedef SalomeApp_Application* TResult;
85 TNewViewManagerEvent (const int theStudyId):
86 myStudyId(theStudyId),
94 MESSAGE("Find application for study with id = : " << myStudyId);
95 SUIT_Session* aSession = SUIT_Session::session();
96 QList<SUIT_Application*> anApplications = aSession->applications();
97 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
98 while ( anIter != anApplications.end() ) {
99 SUIT_Application* anApp = *anIter;
100 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
101 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
102 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
103 //if (myStudyName == aCStudy->Name()) {
104 if (myStudyId == aCStudy->StudyId()) {
105 myResult = dynamic_cast<SalomeApp_Application*>(anApp);
114 //MESSAGE("Error: application is not found for study : " << myStudyName);
115 MESSAGE("Error: application is not found for study with id = : " << myStudyId);
120 //===========================================================================
121 ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy)
123 if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i - "<<this);
125 //CORBA::String_var aStudyName = theStudy->Name();
126 //myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
127 int aStudyID = theStudy->StudyId();
128 myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyID));
132 ViewManager_i::~ViewManager_i()
134 if(MYDEBUG) MESSAGE("ViewManager_i::~ViewManager_i - "<<this);
138 struct TCurrentViewEvent: public SALOME_Event
140 SalomeApp_Application* myApplication;
141 typedef VISU::View_ptr TResult;
144 TCurrentViewEvent(SalomeApp_Application* theApplication):
145 myApplication(theApplication),
146 myResult(VISU::View::_nil())
153 VISU::View3D_i* aView = new View3D_i (myApplication);
154 if (aView->Create(0))
155 myResult = aView->_this();
159 VISU::View_ptr ViewManager_i::GetCurrentView(){
160 return ProcessEvent(new TCurrentViewEvent(myApplication));
164 template<class TViewFrame>
165 struct TCreateViewFrameEvent: public SALOME_Event
167 SalomeApp_Application* myApplication;
168 typedef typename TViewFrame::TInterface TInterface;
169 typedef typename TInterface::_ptr_type TResult;
172 TCreateViewFrameEvent (SalomeApp_Application* theApplication):
173 myApplication(theApplication),
174 myResult(TInterface::_nil())
181 //if (CheckStudy(myStudyDocument)) {
183 TViewFrame* pView = new TViewFrame (myApplication);
184 if (pView->Create(1)) {
185 myResult = pView->_this();
186 qApp->processEvents(); // Fix for bug 9929
193 VISU::View3D_ptr ViewManager_i::Create3DView()
195 if (MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
196 return ProcessEvent(new TCreateViewFrameEvent<View3D_i>(myApplication));
199 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot()
201 if (MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
202 return ProcessEvent(new TCreateViewFrameEvent<XYPlot_i>(myApplication));
205 class TCreateViewEvent: public SALOME_Event
208 TCreateViewEvent (SalomeApp_Application* theApplication)
209 : myApplication(theApplication)
212 SalomeApp_Application* myApplication;
215 class TCreateTableViewFrameEvent: public TCreateViewEvent
219 TCreateTableViewFrameEvent (SalomeApp_Application* theApplication,
221 TCreateViewEvent(theApplication),
223 myResult(VISU::TableView::_nil())
226 virtual void Execute()
228 //if (CheckStudy(myStudyDocument)) {
229 VISU::TableView_i* pView = new TableView_i (myApplication);
230 if (pView->Create(myTable) != NULL)
231 myResult = pView->_this();
234 typedef VISU::TableView_ptr TResult;
238 VISU::TableView_ptr ViewManager_i::CreateTableView (VISU::Table_ptr theTable)
240 if (MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
241 //return ProcessEvent(new TCreateViewFrameEvent<TableView_i>(myApplication));
242 return ProcessEvent(new TCreateTableViewFrameEvent (myApplication, theTable));
245 void ViewManager_i::Destroy (View_ptr theView)
247 class TEvent: public SALOME_Event {
250 TEvent(View_ptr theView):
253 virtual void Execute(){
254 if (!CORBA::is_nil(myView)) {
255 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
257 pView->_remove_ref();
263 if (MYDEBUG) MESSAGE("ViewManager_i::Destroy - " << theView->_is_nil());
264 ProcessVoidEvent(new TEvent(theView));
267 //===========================================================================
268 // VISU namespace functions
269 //===========================================================================
270 vtkRenderer* GetRenderer (SUIT_ViewWindow* theViewWindow)
272 if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(theViewWindow))
273 return vw->getRenderer();
277 vtkCamera* GetCamera (SUIT_ViewWindow* theViewWindow)
279 return GetRenderer(theViewWindow)->GetActiveCamera();
282 void RepaintView (SUIT_ViewWindow* theViewWindow)
284 if (SVTK_ViewWindow* vf = dynamic_cast<SVTK_ViewWindow*>(theViewWindow)) {
285 vf->getRenderer()->ResetCameraClippingRange();
286 vf->getRenderWindow()->Render();
290 VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs)
292 SVTK_ViewWindow* vf = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
293 if (!vf) return NULL;
294 if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
295 vtkRenderer *aRen = vf->getRenderer();
296 VTK::ActorCollectionCopy aCopy(aRen->GetActors());
297 vtkActorCollection* anActColl = aCopy.GetActors();
299 VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
300 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
301 if(anActor->IsA("VISU_Actor")){
302 anVISUActor = VISU_Actor::SafeDownCast(anActor);
303 if (thePrs == anVISUActor->GetPrs3d()) {
304 aResActor = anVISUActor;
305 if(theDisplaing < eErase) {
306 aResActor->VisibilityOn();
307 VISU::SetVisibilityState(aResActor, Qtx::ShownState);
310 aResActor->VisibilityOff();
311 VISU::SetVisibilityState(aResActor, Qtx::HiddenState);
314 if(theDisplaing == eEraseAll || theDisplaing == eDisplayOnly) {
315 anVISUActor->VisibilityOff();
316 VISU::SetVisibilityState(aResActor, Qtx::HiddenState);
318 else if ( theDisplaing == eDisplayAll ) {
319 anVISUActor->VisibilityOn();
320 VISU::SetVisibilityState(aResActor, Qtx::HiddenState);
326 RepaintView(theViewWindow);
329 if(thePrs != NULL && theDisplaing < eErase){
331 anVISUActor = thePrs->CreateActor();
332 vf->AddActor(anVISUActor);
333 }catch(std::exception& exc){
334 if(MYDEBUG) INFOS(exc.what());
337 if(MYDEBUG) INFOS("Unknown exception was occured!!!");
341 RepaintView(theViewWindow);
345 struct TUpdatePlot2dEvent: public SALOME_Event
350 TUpdatePlot2dEvent (Curve_i* theCurve, const int theDisplaying):
352 myDisplaying(theDisplaying)
355 virtual void Execute()
357 SalomeApp_Application* anApp = NULL;
358 CORBA::String_var studyName = myCurve->GetStudyDocument()->Name();
359 std::string aStudyName = studyName.in();
360 SUIT_Session* aSession = SUIT_Session::session();
361 QList<SUIT_Application*> anApplications = aSession->applications();
362 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
363 while (anIter != anApplications.end()) {
364 SUIT_Application* aSUITApp = *anIter;
365 if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
366 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
367 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
368 if (aStudyName == aCStudy->Name()) {
369 anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
380 ViewManagerList aViewManagerList;
381 anApp->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
382 SUIT_ViewManager* aViewManager;
383 foreach( aViewManager, aViewManagerList ) {
384 if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
385 if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel())) {
386 if (Plot2d_ViewFrame* aViewFrame = aViewer->getActiveViewFrame()) {
387 UpdatePlot2d(myCurve, myDisplaying, aViewFrame);
395 void UpdatePlot2d (Curve_i* theCurve, int theDisplaying, Plot2d_ViewFrame* theView)
397 if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = " << theDisplaying);
400 ProcessVoidEvent(new TUpdatePlot2dEvent(theCurve, theDisplaying));
403 QList<Plot2d_Curve*> clist;
404 theView->getCurves(clist);
405 if (theDisplaying == eEraseAll) {
406 for (int i = 0; i < clist.count(); i++) {
407 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - " << clist.at(i));
408 theView->eraseCurve(clist.at(i));
410 } else if (theDisplaying == eErase) {
412 for (int i = 0; i < clist.count(); i++) {
413 SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
414 if (aSPlot2dC->hasIO() &&
415 !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
416 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC);
417 theView->eraseCurve(aSPlot2dC);
421 } else if (theDisplaying == eDisplay ||
422 theDisplaying == eDisplayOnly ||
423 theDisplaying == eUpdateData) {
426 for (int i = 0; i < clist.count(); i++) {
427 SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
428 if (aSPlot2dC->hasIO() &&
429 !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
430 if (theDisplaying == eUpdateData) {
431 if(MYDEBUG) MESSAGE("UpdatePlot2d - updating data : curve - " << aSPlot2dC);
434 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
439 int nbPoints = theCurve->GetData( xList, yList, zList );
440 if (nbPoints > 0 && xList && yList) {
441 aSPlot2dC->setData( xList, yList, nbPoints, zList );
443 if (theDisplaying == eUpdateData) {
444 theView->updateCurve(aSPlot2dC, true);
446 aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
447 aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
448 aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
449 aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
450 if (!theCurve->IsAuto()) {
451 aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(),
452 theCurve->GetLineWidth());
453 aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker());
454 SALOMEDS::Color color = theCurve->GetColor();
455 aSPlot2dC->setColor(QColor((int)(color.R*255.),
457 (int)(color.B*255.)));
459 aSPlot2dC->setAutoAssign(theCurve->IsAuto());
460 theView->displayCurve(aSPlot2dC);
463 } else if (theDisplaying == eDisplayOnly) {
464 theView->eraseCurve(aSPlot2dC);
467 if (!bFound && theDisplaying != eUpdateData) {
468 Plot2d_Curve* crv = theCurve->CreatePresentation();
469 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
471 theView->displayCurve( crv );
472 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
473 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
474 SALOMEDS::Color newColor;
475 newColor.R = crv->getColor().red()/255.;
476 newColor.G = crv->getColor().green()/255.;
477 newColor.B = crv->getColor().blue()/255.;
478 theCurve->SetColor( newColor );
479 crv->setAutoAssign( theCurve->IsAuto() );
487 //----------------------------------------------------------------------------
490 VISU::Prs3d_i* myPrs3d;
492 TIsSamePrs3d(VISU::Prs3d_i* thePrs3d):
497 operator()(VISU_Actor* theActor)
499 return theActor->GetPrs3d() == myPrs3d;
504 //----------------------------------------------------------------------------
506 FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d)
511 vtkRenderer* aRenderer = theViewWindow->getRenderer();
512 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
513 vtkActorCollection* anActors = aCopy.GetActors();
514 return SVTK::Find<VISU_Actor>(anActors, VISU::TIsSamePrs3d(thePrs3d));
518 //----------------------------------------------------------------------------
521 VISU::TActorFactory* myActor;
523 TIsSameActor(VISU::TActorFactory* theActor):
528 operator()(VISU_ActorBase* theActor)
530 return theActor->GetFactory() == myActor;
534 //----------------------------------------------------------------------------
536 FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor)
541 vtkRenderer* aRenderer = theViewWindow->getRenderer();
542 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
543 vtkActorCollection* anActors = aCopy.GetActors();
544 return SVTK::Find<VISU_ActorBase>(anActors, VISU::TIsSameActor(theActor));
548 //----------------------------------------------------------------------------
549 struct TDeleteActorsEvent: public SALOME_Event
551 VISU::Curve_i* myPrs;
553 TDeleteActorsEvent (VISU::Curve_i* thePrs):
563 // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
564 SALOMEDS::Study_var myStudyDocument = myPrs->GetStudyDocument();
565 SalomeApp_Application* anApp = NULL;
566 CORBA::String_var studyName = myStudyDocument->Name();
567 std::string aStudyName = studyName.in();
568 SUIT_Session* aSession = SUIT_Session::session();
569 QList<SUIT_Application*> anApplications = aSession->applications();
570 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
571 while ( anIter != anApplications.end() ) {
572 SUIT_Application* aSUITApp = *anIter;
573 if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
574 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
575 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
576 if (aStudyName == aCStudy->Name()) {
577 anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
588 // 2. Remove corresponding IO from selection
589 SALOMEDS::SObject_var aSObject = myPrs->GetSObject();
590 CORBA::String_var anEntry = aSObject->GetID();
592 LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
593 SALOME_ListIO aListIO, aNewListIO;
594 aSelectionMgr->selectedObjects(aListIO);
596 for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
597 if (it.Value()->hasEntry()) {
598 std::string aCurEntry (it.Value()->getEntry());
599 if (aCurEntry != std::string( anEntry.in() ) ) {
600 aNewListIO.Append(it.Value());
605 aSelectionMgr->setSelectedObjects(aNewListIO);
608 ViewManagerList aViewManagerList;
609 anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
610 QList<SUIT_ViewManager*>::Iterator anVMIter = aViewManagerList.begin();
611 for (; anVMIter != aViewManagerList.end(); anVMIter++ ) {
612 SUIT_ViewManager* aViewManager = *anVMIter;
613 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
614 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
615 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
616 if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
617 Plot2d_ViewFrame* vf = vw->getViewFrame();
618 QList<Plot2d_Curve*> clist;
619 vf->getCurves(clist);
620 for (int i = 0; i < clist.count(); i++) {
621 if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
623 strcmp(myPrs->GetEntry().c_str(), cu->getIO()->getEntry())) {
629 //jfa tmp:aViewFrame->unHighlightAll();
637 void DeleteActors (VISU::Curve_i* thePrs)
640 ProcessVoidEvent(new TDeleteActorsEvent (thePrs));
642 /* // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
643 SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
644 SalomeApp_Application* anApp = NULL;
645 CORBA::String_var studyName = myStudyDocument->Name();
646 std::string aStudyName = studyName.in();
647 SUIT_Session* aSession = SUIT_Session::session();
648 QPtrList<SUIT_Application> anApplications = aSession->applications();
649 QPtrListIterator<SUIT_Application> anIter (anApplications);
650 while (SUIT_Application* aSUITApp = anIter.current()) {
652 if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
653 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
654 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
655 if (aStudyName == aCStudy->Name()) {
656 anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
666 // 2. Remove corresponding IO from selection
667 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
668 CORBA::String_var anEntry = aSObject->GetID();
670 LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
671 SALOME_ListIO aListIO, aNewListIO;
672 aSelectionMgr->selectedObjects(aListIO);
674 for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
675 if (it.Value()->hasEntry()) {
676 std::string aCurEntry (it.Value()->getEntry());
677 if (aCurEntry != std::string( anEntry.in() ) ) {
678 aNewListIO.Append(it.Value());
683 aSelectionMgr->setSelectedObjects(aNewListIO);
686 ViewManagerList aViewManagerList;
687 anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
688 QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
689 for (; anVMIter.current(); ++anVMIter) {
690 SUIT_ViewManager* aViewManager = anVMIter.current();
691 QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
692 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
693 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
694 if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
695 Plot2d_ViewFrame* vf = vw->getViewFrame();
696 QList<Plot2d_Curve> clist;
697 vf->getCurves(clist);
698 for (int i = 0; i < clist.count(); i++) {
699 if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
701 strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) {
707 //jfa tmp:aViewFrame->unHighlightAll();
714 void DeleteActors (VISU::Prs3d_i* thePrs)
718 // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
719 SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
720 SalomeApp_Application* anApp = NULL;
721 CORBA::String_var studyName = myStudyDocument->Name();
722 std::string aStudyName = studyName.in();
723 SUIT_Session* aSession = SUIT_Session::session();
724 QList<SUIT_Application*> anApplications = aSession->applications();
725 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
726 while (anIter != anApplications.end()) {
727 SUIT_Application* aSUITApp = *anIter;
728 if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
729 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
730 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
731 if (aStudyName == aCStudy->Name()) {
732 anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
743 // 2. Remove corresponding IO from selection
744 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
745 CORBA::String_var anEntry = aSObject->GetID();
747 LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
748 SALOME_ListIO aListIO, aNewListIO;
749 aSelectionMgr->selectedObjects(aListIO);
751 for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
752 if (it.Value()->hasEntry()) {
753 std::string aCurEntry (it.Value()->getEntry());
754 if (aCurEntry != std::string( anEntry.in() ) ) {
755 aNewListIO.Append(it.Value());
760 aSelectionMgr->setSelectedObjects(aNewListIO);
763 ViewManagerList aViewManagerList;
764 anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
765 QList<SUIT_ViewManager*>::Iterator anVMIter = aViewManagerList.begin();
766 for (; anVMIter != aViewManagerList.end(); anVMIter++ ) {
767 SUIT_ViewManager* aViewManager = *anVMIter;
768 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
769 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
770 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
771 if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
772 VISU_Actor* anActor = NULL;
773 VTK::ActorCollectionCopy aCopy(vw->getRenderer()->GetActors());
774 vtkActorCollection *anActColl = aCopy.GetActors();
775 anActColl->InitTraversal();
776 vtkActor *aVTKActor = anActColl->GetNextActor();
777 for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
778 if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
779 if (thePrs == anVISUActor->GetPrs3d()) {
780 anActor = anVISUActor;
785 vw->RemoveActor(anActor);