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