]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_ViewManager_i.cc
Salome HOME
Merge with branch V2_2_0_VISU_improvement
[modules/visu.git] / src / VISU_I / VISU_ViewManager_i.cc
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //  File   : VISU_ViewManager_i.cc
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_ViewManager_i.hh"
28 #include "VISU_View_i.hh"
29 #include "VISU_Prs3d_i.hh"
30 #include "VISU_Table_i.hh"
31
32 #include "VISU_Actor.h"
33
34 #include "SUIT_Tools.h"
35 #include "SUIT_Session.h"
36 #include "SUIT_ViewWindow.h"
37 #include "SUIT_ViewManager.h"
38
39 #include "SVTK_RenderWindow.h"
40 #include "SVTK_ViewWindow.h"
41 #include "SVTK_ViewModel.h"
42 #include "SPlot2d_Curve.h"
43 #include "Plot2d_ViewFrame.h"
44 #include "Plot2d_ViewWindow.h"
45 #include "Plot2d_ViewModel.h"
46
47 #include "SalomeApp_Study.h"
48 #include "SalomeApp_Application.h"
49 #include "SalomeApp_SelectionMgr.h"
50
51 #include "SALOME_Event.hxx"
52 #include "SALOME_ListIO.hxx"
53 #include "SALOME_ListIteratorOfListIO.hxx"
54
55 #include <vtkCamera.h>
56 #include <vtkRenderer.h>
57 #include <vtkRenderWindow.h>
58
59 using namespace std;
60
61 #ifdef _DEBUG_
62 static int MYDEBUG = 1;
63 #else
64 static int MYDEBUG = 0;
65 #endif
66
67 namespace VISU {
68
69   struct TNewViewManagerEvent: public SALOME_Event
70   {
71     int myStudyId;
72     typedef SalomeApp_Application* TResult;
73     TResult myResult;
74
75     TNewViewManagerEvent (const int theStudyId):
76       myStudyId(theStudyId),
77       myResult(NULL)
78     {}
79
80     virtual
81     void
82     Execute()
83     {
84       MESSAGE("Find application for study with id = : " << myStudyId);
85       SUIT_Session* aSession = SUIT_Session::session();
86       QPtrList<SUIT_Application> anApplications = aSession->applications();
87       QPtrListIterator<SUIT_Application> anIter (anApplications);
88       while (SUIT_Application* anApp = anIter.current()) {
89         ++anIter;
90         if (SUIT_Study* aSStudy = anApp->activeStudy()) {
91           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
92             if (_PTR(Study) aCStudy = aStudy->studyDS()) {
93               //if (myStudyName == aCStudy->Name()) {
94               if (myStudyId == aCStudy->StudyId()) {
95                 myResult = dynamic_cast<SalomeApp_Application*>(anApp);
96                 break;
97               }
98             }
99           }
100         }
101       }
102       if (!myResult) {
103         //MESSAGE("Error: application is not found for study : " << myStudyName);
104         MESSAGE("Error: application is not found for study with id = : " << myStudyId);
105       }
106     }
107   };
108
109   //===========================================================================
110   ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy)
111   {
112     if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i - "<<this);
113
114     //CORBA::String_var aStudyName = theStudy->Name();
115     //myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
116     int aStudyID = theStudy->StudyId();
117     myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyID));
118   }
119
120
121   ViewManager_i::~ViewManager_i()
122   {
123     if(MYDEBUG) MESSAGE("ViewManager_i::~ViewManager_i - "<<this);
124   }
125
126
127   struct TCurrentViewEvent: public SALOME_Event
128   {
129     const SalomeApp_Application* myApplication;
130     typedef VISU::View_ptr TResult;
131     TResult myResult;
132
133     TCurrentViewEvent(const SalomeApp_Application* theApplication):
134       myApplication(theApplication),
135       myResult(VISU::View::_nil())
136     {}
137
138     virtual
139     void
140     Execute()
141     {
142       //if (SUIT_ViewManager *aViewManager = myApplication->activeViewManager()) {
143       //  if (aViewManager->getType() == "VTKViewer") {
144       //    if (SUIT_ViewWindow *aViewWindow = aViewManager->getActiveView()) {
145             VISU::View3D_i* pView =
146               new View3D_i ((SalomeApp_Application*)myApplication);
147             if (pView->Create(0))
148               myResult = pView->_this();
149       //    }
150       //  }
151       //}
152     }
153   };
154
155   VISU::View_ptr ViewManager_i::GetCurrentView(){
156     return ProcessEvent(new TCurrentViewEvent(myApplication));
157   }
158
159
160   template<class TViewFrame>
161   struct TCreateViewFrameEvent: public SALOME_Event
162   {
163     SalomeApp_Application* myApplication;
164     typedef typename TViewFrame::TInterface TInterface;
165     typedef typename TInterface::_ptr_type TResult;
166     TResult myResult;
167
168     TCreateViewFrameEvent (SalomeApp_Application* theApplication):
169       myApplication(theApplication),
170       myResult(TInterface::_nil())
171     {}
172
173     virtual
174     void
175     Execute()
176     {
177       //if (CheckStudy(myStudyDocument)) {
178       if (myApplication) {
179         TViewFrame* pView = new TViewFrame (myApplication);
180         if (pView->Create(1))
181           myResult = pView->_this();
182       }
183     }
184   };
185
186
187   VISU::View3D_ptr ViewManager_i::Create3DView()
188   {
189     if (MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
190     return ProcessEvent(new TCreateViewFrameEvent<View3D_i>(myApplication));
191   }
192
193   VISU::XYPlot_ptr ViewManager_i::CreateXYPlot()
194   {
195     if (MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
196     return ProcessEvent(new TCreateViewFrameEvent<XYPlot_i>(myApplication));
197   }
198
199   class TCreateViewEvent: public SALOME_Event
200   {
201   public:
202     TCreateViewEvent (SalomeApp_Application* theApplication)
203       : myApplication(theApplication)
204     {}
205   protected:
206     SalomeApp_Application* myApplication;
207   };
208
209   class TCreateTableViewFrameEvent: public TCreateViewEvent
210   {
211     Table_ptr myTable;
212   public:
213     TCreateTableViewFrameEvent (SalomeApp_Application* theApplication,
214                                 Table_ptr theTable):
215       TCreateViewEvent(theApplication),
216       myTable(theTable),
217       myResult(VISU::TableView::_nil())
218     {}
219
220     virtual void Execute()
221     {
222       //if (CheckStudy(myStudyDocument)) {
223         VISU::TableView_i* pView = new TableView_i (myApplication);
224         if (pView->Create(myTable) != NULL)
225           myResult = pView->_this();
226       //}
227     }
228     typedef VISU::TableView_ptr TResult;
229     TResult myResult;
230   };
231
232   VISU::TableView_ptr ViewManager_i::CreateTableView (VISU::Table_ptr theTable)
233   {
234     if (MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
235     //return ProcessEvent(new TCreateViewFrameEvent<TableView_i>(myApplication));
236     return ProcessEvent(new TCreateTableViewFrameEvent (myApplication, theTable));
237   }
238
239   void ViewManager_i::Destroy (View_ptr theView)
240   {
241     class TEvent: public SALOME_Event {
242       View_ptr myView;
243     public:
244       TEvent(View_ptr theView):
245         myView(theView)
246       {}
247       virtual void Execute(){
248         if (!CORBA::is_nil(myView)) {
249           if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
250             pView->Close();
251             pView->_remove_ref();
252           }
253         }
254       }
255     };
256
257     if (MYDEBUG) MESSAGE("ViewManager_i::Destroy - " << theView->_is_nil());
258     ProcessVoidEvent(new TEvent(theView));
259   }
260
261   //===========================================================================
262   // VISU namespace functions
263   //===========================================================================
264   SVTK_ViewWindow* GetViewWindow (SUIT_ViewWindow* theStudyFrame)
265   {
266     return dynamic_cast<SVTK_ViewWindow*>(theStudyFrame);
267   }
268
269   vtkRenderer* GetRenderer (SUIT_ViewWindow* theStudyFrame)
270   {
271     return GetViewWindow(theStudyFrame)->getRenderer();
272   }
273
274   vtkCamera* GetCamera (SUIT_ViewWindow* theStudyFrame)
275   {
276     return GetRenderer(theStudyFrame)->GetActiveCamera();
277   }
278
279   void RepaintView (SUIT_ViewWindow* theViewWindow)
280   {
281     SVTK_ViewWindow* vf = GetViewWindow(theViewWindow);
282     vf->getRenderer()->ResetCameraClippingRange();
283     vf->getRenderWindow()->getRenderWindow()->Render();
284   }
285
286   VISU_Actor* UpdateViewer (SUIT_ViewWindow* theStudyFrame, int theDisplaing, Prs3d_i* thePrs)
287   {
288     SVTK_ViewWindow* vf = GetViewWindow(theStudyFrame);
289     if (!vf) return NULL;
290     if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
291     vtkRenderer *aRen = vf->getRenderer();
292     vtkActorCollection *anActColl = aRen->GetActors();
293     vtkActor *anActor;
294     VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
295     for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
296       if(anActor->IsA("VISU_Actor")){
297         anVISUActor = VISU_Actor::SafeDownCast(anActor);
298         if (thePrs == anVISUActor->GetPrs3d()) {
299           aResActor = anVISUActor->GetParent();
300           if(theDisplaing < eErase)
301             aResActor->VisibilityOn();
302           else
303             aResActor->VisibilityOff();
304         } else {
305           if(theDisplaing > eDisplay)
306             anVISUActor->VisibilityOff();
307           else
308             anVISUActor->VisibilityOn();
309         }
310       }
311     }
312     if (aResActor) {
313       RepaintView(theStudyFrame);
314       return aResActor;
315     }
316     if(thePrs != NULL && theDisplaing < eErase){
317       try{
318         anVISUActor = thePrs->CreateActor();
319         vf->AddActor(anVISUActor);
320       }catch(std::exception& exc){
321         if(MYDEBUG) INFOS(exc.what());
322         return NULL;
323       }catch(...){
324         if(MYDEBUG) INFOS("Unknown exception was occured!!!");
325         return NULL;
326       }
327     }
328     RepaintView(theStudyFrame);
329     return anVISUActor;
330   }
331
332   void UpdatePlot2d (Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve)
333   {
334     if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = " << theDisplaying);
335     if (!theView)
336       return;
337     QList<Plot2d_Curve> clist;
338     theView->getCurves(clist);
339     if (theDisplaying == eEraseAll) {
340       for (int i = 0; i < clist.count(); i++) {
341         if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - " << clist.at(i));
342         theView->eraseCurve(clist.at(i));
343       }
344     } else if (theDisplaying == eErase) {
345       if (theCurve) {
346         for (int i = 0; i < clist.count(); i++) {
347           SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
348           if (aSPlot2dC->hasIO() &&
349               !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
350             if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC);
351             theView->eraseCurve(aSPlot2dC);
352           }
353         }
354       }
355     } else if (theDisplaying == eDisplay) {
356       if (theCurve) {
357         bool bFound = false;
358         for (int i = 0; i < clist.count(); i++) {
359           SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
360           if (aSPlot2dC->hasIO() &&
361               !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
362             if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
363             aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
364             aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
365             aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
366             aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
367             double* xList = 0;
368             double* yList = 0;
369             int     nbPoints = theCurve->GetData( xList, yList );
370             if (nbPoints > 0 && xList && yList) {
371               aSPlot2dC->setData( xList, yList, nbPoints );
372             }
373             if (!theCurve->IsAuto()) {
374               aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(),
375                                  theCurve->GetLineWidth());
376               aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker());
377               SALOMEDS::Color color = theCurve->GetColor();
378               aSPlot2dC->setColor(QColor((int)(color.R*255.),
379                                          (int)(color.G*255.),
380                                          (int)(color.B*255.)));
381             }
382             aSPlot2dC->setAutoAssign(theCurve->IsAuto());
383             theView->displayCurve(aSPlot2dC);
384             bFound = true;
385           }
386         }
387         if (!bFound) {
388           Plot2d_Curve* crv = theCurve->CreatePresentation();
389           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
390           if (crv) {
391             theView->displayCurve( crv );
392             theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
393             theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
394             SALOMEDS::Color newColor;
395             newColor.R = crv->getColor().red()/255.;
396             newColor.G = crv->getColor().green()/255.;
397             newColor.B = crv->getColor().blue()/255.;
398             theCurve->SetColor( newColor );
399             crv->setAutoAssign( theCurve->IsAuto() );
400           }
401         }
402       }
403     } else if (theDisplaying == eDisplayOnly) {
404       if (theCurve) {
405         bool bFound = false;
406         for (int i = 0; i < clist.count(); i++) {
407           SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
408           if (aSPlot2dC->hasIO() &&
409               !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
410             if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC);
411             aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
412             aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
413             aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
414             aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
415             double* xList = 0;
416             double* yList = 0;
417             int     nbPoints = theCurve->GetData( xList, yList );
418             if ( nbPoints > 0 && xList && yList ) {
419               aSPlot2dC->setData( xList, yList, nbPoints );
420             }
421             if ( !theCurve->IsAuto() ) {
422               aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth());
423               aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker());
424               SALOMEDS::Color color = theCurve->GetColor();
425               aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.)));
426             }
427             aSPlot2dC->setAutoAssign(theCurve->IsAuto());
428             theView->displayCurve(aSPlot2dC);
429             bFound = true;
430           } else {
431             theView->eraseCurve(aSPlot2dC);
432           }
433         }
434         if (!bFound) {
435           Plot2d_Curve* crv = theCurve->CreatePresentation();
436           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - " << crv);
437           if (crv) {
438             theView->displayCurve(crv);
439             theCurve->SetLine((VISU::Curve::LineType)crv->getLine(), crv->getLineWidth());
440             theCurve->SetMarker((VISU::Curve::MarkerType)crv->getMarker());
441             SALOMEDS::Color newColor;
442             newColor.R = crv->getColor().red()/255.;
443             newColor.G = crv->getColor().green()/255.;
444             newColor.B = crv->getColor().blue()/255.;
445             theCurve->SetColor(newColor);
446             crv->setAutoAssign(theCurve->IsAuto());
447           }
448         }
449       }
450     }
451   }
452
453   VISU_Actor* GetActor (VISU::Prs3d_i* thePrs3d, SVTK_ViewWindow* theVTKFrame)
454   {
455     vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
456     anActColl->InitTraversal();
457     while (vtkActor *anActor = anActColl->GetNextActor())
458       if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
459         if (thePrs3d == anVISUActor->GetPrs3d())
460           return anVISUActor->GetParent();
461     return NULL;
462   }
463
464   struct TDeleteActorsEvent: public SALOME_Event
465   {
466     VISU::Curve_i* myPrs;
467
468     TDeleteActorsEvent (VISU::Curve_i* thePrs):
469       myPrs(thePrs)
470     {}
471
472     virtual
473     void
474     Execute()
475     {
476       if (!myPrs) return;
477
478       // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
479       SALOMEDS::Study_var myStudyDocument = myPrs->GetStudyDocument();
480       SalomeApp_Application* anApp = NULL;
481       CORBA::String_var studyName = myStudyDocument->Name();
482       std::string aStudyName = studyName.in();
483       SUIT_Session* aSession = SUIT_Session::session();
484       QPtrList<SUIT_Application> anApplications = aSession->applications();
485       QPtrListIterator<SUIT_Application> anIter (anApplications);
486       while (SUIT_Application* aSUITApp = anIter.current()) {
487         ++anIter;
488         if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
489           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
490             if (_PTR(Study) aCStudy = aStudy->studyDS()) {
491               if (aStudyName == aCStudy->Name()) {
492                 anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
493                 break;
494               }
495             }
496           }
497         }
498       }
499       if (!anApp)
500         return;
501
502       // 2. Remove corresponding IO from selection
503       SALOMEDS::SObject_var aSObject = myPrs->GetSObject();
504       CORBA::String_var anEntry = aSObject->GetID();
505
506       SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
507       SALOME_ListIO aListIO, aNewListIO;
508       aSelectionMgr->selectedObjects(aListIO);
509
510       for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
511         if (it.Value()->hasEntry()) {
512           std::string aCurEntry (it.Value()->getEntry());
513           if (aCurEntry != std::string( anEntry.in() ) ) {
514             aNewListIO.Append(it.Value());
515           }
516         }
517       }
518
519       aSelectionMgr->setSelectedObjects(aNewListIO);
520
521       // 3. Remove Actors
522       ViewManagerList aViewManagerList;
523       anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
524       QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
525       for (; anVMIter.current(); ++anVMIter) {
526         SUIT_ViewManager* aViewManager = anVMIter.current();
527         QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
528         for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
529           if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
530             if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
531               Plot2d_ViewFrame* vf = vw->getViewFrame();
532               QList<Plot2d_Curve> clist;
533               vf->getCurves(clist);
534               for (int i = 0; i < clist.count(); i++) {
535                 if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
536                   if (cu->hasIO() &&
537                       strcmp(cu->getIO()->getEntry(), myPrs->GetEntry()) == 0) {
538                     vf->eraseCurve(cu);
539                   }
540                 }
541               }
542               vf->Repaint();
543               //jfa tmp:aViewFrame->unHighlightAll();
544             }
545           }
546         }
547       }
548     }
549   };
550
551   void DeleteActors (VISU::Curve_i* thePrs)
552   {
553     if (!thePrs) return;
554     ProcessVoidEvent(new TDeleteActorsEvent (thePrs));
555
556 /*    // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
557     SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
558     SalomeApp_Application* anApp = NULL;
559     CORBA::String_var studyName = myStudyDocument->Name();
560     std::string aStudyName = studyName.in();
561     SUIT_Session* aSession = SUIT_Session::session();
562     QPtrList<SUIT_Application> anApplications = aSession->applications();
563     QPtrListIterator<SUIT_Application> anIter (anApplications);
564     while (SUIT_Application* aSUITApp = anIter.current()) {
565       ++anIter;
566       if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
567         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
568           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
569             if (aStudyName == aCStudy->Name()) {
570               anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
571               break;
572             }
573           }
574         }
575       }
576     }
577     if (!anApp)
578       return;
579
580     // 2. Remove corresponding IO from selection
581     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
582     CORBA::String_var anEntry = aSObject->GetID();
583
584     SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
585     SALOME_ListIO aListIO, aNewListIO;
586     aSelectionMgr->selectedObjects(aListIO);
587
588     for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
589       if (it.Value()->hasEntry()) {
590         std::string aCurEntry (it.Value()->getEntry());
591         if (aCurEntry != std::string( anEntry.in() ) ) {
592           aNewListIO.Append(it.Value());
593         }
594       }
595     }
596
597     aSelectionMgr->setSelectedObjects(aNewListIO);
598
599     // 3. Remove Actors
600     ViewManagerList aViewManagerList;
601     anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
602     QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
603     for (; anVMIter.current(); ++anVMIter) {
604       SUIT_ViewManager* aViewManager = anVMIter.current();
605       QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
606       for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
607         if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
608           if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
609             Plot2d_ViewFrame* vf = vw->getViewFrame();
610             QList<Plot2d_Curve> clist;
611             vf->getCurves(clist);
612             for (int i = 0; i < clist.count(); i++) {
613               if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
614                 if (cu->hasIO() &&
615                     strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) {
616                   vf->eraseCurve(cu);
617                 }
618               }
619             }
620             vf->Repaint();
621             //jfa tmp:aViewFrame->unHighlightAll();
622           }
623         }
624       }
625 }*/
626   }
627
628   void DeleteActors (VISU::Prs3d_i* thePrs)
629   {
630     if (!thePrs) return;
631
632     // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
633     SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
634     SalomeApp_Application* anApp = NULL;
635     CORBA::String_var studyName = myStudyDocument->Name();
636     std::string aStudyName = studyName.in();
637     SUIT_Session* aSession = SUIT_Session::session();
638     QPtrList<SUIT_Application> anApplications = aSession->applications();
639     QPtrListIterator<SUIT_Application> anIter (anApplications);
640     while (SUIT_Application* aSUITApp = anIter.current()) {
641       ++anIter;
642       if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
643         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
644           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
645             if (aStudyName == aCStudy->Name()) {
646               anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
647               break;
648             }
649           }
650         }
651       }
652     }
653     if (!anApp)
654       return;
655
656     // 2. Remove corresponding IO from selection
657     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
658     CORBA::String_var anEntry = aSObject->GetID();
659
660     SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
661     SALOME_ListIO aListIO, aNewListIO;
662     aSelectionMgr->selectedObjects(aListIO);
663
664     for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
665       if (it.Value()->hasEntry()) {
666         std::string aCurEntry (it.Value()->getEntry());
667         if (aCurEntry != std::string( anEntry.in() ) ) {
668           aNewListIO.Append(it.Value());
669         }
670       }
671     }
672
673     aSelectionMgr->setSelectedObjects(aNewListIO);
674
675     // 3. Remove Actors
676     ViewManagerList aViewManagerList;
677     anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
678     QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
679     for (; anVMIter.current(); ++anVMIter) {
680       SUIT_ViewManager* aViewManager = anVMIter.current();
681       QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
682       for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
683         if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
684           if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
685             VISU_Actor* anActor = NULL;
686             vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
687             anActColl->InitTraversal();
688             vtkActor *aVTKActor = anActColl->GetNextActor();
689             for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
690               if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
691                 if (thePrs == anVISUActor->GetPrs3d()) {
692                   anActor = anVISUActor->GetParent();
693                 }
694               }
695             }
696             if (anActor) {
697               vw->RemoveActor(anActor);
698               anActor->Delete();
699             }
700           }
701         }
702       }
703     }
704   }
705 }