]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_ViewManager_i.cc
Salome HOME
The fix solve problem with NonRegression Test execition for 001/L0 -L7 cases.
[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
29 #include "VISU_PrsObject_i.hh"
30 #include "VISU_Result_i.hh"
31 #include "VISU_Gen_i.hh"
32
33 #include "VISU_Prs3d_i.hh"
34 #include "VISU_Mesh_i.hh"
35 #include "VISU_ScalarMap_i.hh"
36 #include "VISU_IsoSurfaces_i.hh"
37 #include "VISU_DeformedShape_i.hh"
38 #include "VISU_CutPlanes_i.hh"
39 #include "VISU_CutLines_i.hh"
40 #include "VISU_Vectors_i.hh"
41 #include "VISU_StreamLines_i.hh"
42
43 #include "VISU_Table_i.hh"
44 #include "VISU_ScalarBarActor.hxx"
45 #include "VISU_Actor.h"
46
47 #include "SALOME_Event.hxx"
48
49 #include "QAD_Application.h"
50 #include "QAD_Desktop.h"
51 #include "QAD_Tools.h"
52 #include "QAD_Study.h"
53 #include "QAD_LeftFrame.h"
54 #include "QAD_RightFrame.h"
55 #include "QAD_StudyFrame.h"
56 #include "QAD_PyEditor.h"
57
58 #include "VTKViewer_ViewFrame.h"
59 #include "VTKViewer_RenderWindow.h"
60 #include "SALOMEGUI_TableDlg.h"
61 #include "Plot2d_CurveContainer.h"
62 #include "Plot2d_ViewFrame.h"
63
64 #include <memory>
65
66 #include <qstring.h>
67 #include <qfileinfo.h>
68
69 #include <vtkRenderer.h>
70 #include <vtkCamera.h>
71
72 using namespace std;
73
74 #ifdef _DEBUG_
75 static int MYDEBUG = 0;
76 #else
77 static int MYDEBUG = 0;
78 #endif
79
80 static QFileInfo aFileInfo;
81
82 namespace VISU{
83   //===========================================================================
84   typedef TVoidMemFunEvent<QAD_StudyFrame> TFrameActionEvent;
85
86   template<class TObject>
87   class TSetBackgroundEvent: public SALOME_Event{
88     TObject* myView;
89     const SALOMEDS::Color& myColor;
90   public:
91     TSetBackgroundEvent(TObject* theView, const SALOMEDS::Color& theColor):
92       myView(theView), myColor(theColor)
93     {}
94     virtual void Execute(){
95       int aColor[3];
96       aColor[0] = int(255.0*myColor.R);
97       aColor[1] = int(255.0*myColor.G);
98       aColor[2] = int(255.0*myColor.B);
99       QColor aNewColor(aColor[0],aColor[1],aColor[2]);
100       myView->setBackgroundColor(aNewColor);
101     }
102   };
103
104   class TSetViewRepresentation: public SALOME_Event{
105     VISU::View::ViewRepresentation myViewRepr;
106     View_i*                        myView;
107     CORBA::Boolean                 myState;
108  public:
109     TSetViewRepresentation( View_i*  aView, 
110                             VISU::View::ViewRepresentation ViewRepr,
111                             CORBA::Boolean State ):
112       SALOME_Event(), myViewRepr( ViewRepr ), myView( aView ), myState( State )
113     {}
114     virtual void Execute(){
115
116   bool old = myView->IsPartShown( myViewRepr );
117
118   QAD_RightFrame* fr = myView->myStudyFrame->getRightFrame();
119
120   if( myView->myStudyFrame != NULL ){
121     switch( myViewRepr )
122       {
123       case VISU::View::OBJECTBROWSER:
124         if( myState!=old )
125           if( myState )
126             myView->myStudyFrame->unCompressLeft();
127           else
128             myView->myStudyFrame->compressLeft();
129         break;
130       case VISU::View::VIEWER:
131         if( myState!=old )
132           if( myState )
133             fr->unCompressUp();
134           else
135             fr->compressUp();
136         break;
137       case VISU::View::PYTHON:
138         if( myState!=old )
139           if( myState )
140             fr->unCompressLeft();
141           else
142             fr->compressLeft();
143         break;
144       case VISU::View::MESSAGES:
145         if( myState!=old )
146           if( myState )
147             fr->unCompressRight();
148           else
149             fr->compressRight();
150         break;
151       };
152     }
153   }
154 };
155
156   class TGetViewRepresentation: public SALOME_Event
157   {
158   public:
159     typedef CORBA::Boolean TResult;
160     TResult myResult;
161     VISU::View::ViewRepresentation myPart;
162     View_i*  myView;
163
164     TGetViewRepresentation( View_i* aView, VISU::View::ViewRepresentation Part ):
165       SALOME_Event(), myResult( false ), myPart( Part ), myView( aView )
166         {
167         }
168       virtual void Execute(){
169         switch( myPart )
170           {
171           case VISU::View::OBJECTBROWSER:
172             myResult = !myView->myStudyFrame->isCompressedLeft();
173             break;
174           case VISU::View::VIEWER:
175             myResult = !myView->myStudyFrame->getRightFrame()->isCompressedViewFrame();
176             break;
177           case VISU::View::PYTHON:
178             myResult = !myView->myStudyFrame->getRightFrame()->isCompressedPython();
179             break;
180           case VISU::View::MESSAGES:
181             myResult = !myView->myStudyFrame->getRightFrame()->isCompressedMessage();
182           }
183       }
184   };
185
186   class TSetViewWidthHeight: public SALOME_Event{
187     CORBA::Long mySize;
188     bool myIsWidth;
189     View_i*  myView;
190   public:
191       TSetViewWidthHeight( View_i* aView, CORBA::Long Size, bool IsWidth ):
192         SALOME_Event(), mySize( Size ), myView( aView ), myIsWidth( IsWidth )
193           {}
194       virtual void Execute(){
195         if( myView->myStudyFrame != NULL ){
196           QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
197           int aleft   = aStudyParent->frameGeometry().left();
198           int atop    = aStudyParent->frameGeometry().top();
199           int aheight = aStudyParent->frameGeometry().height();
200           int awidth  = aStudyParent->frameGeometry().width();
201           QRect aQRect;
202           if( myIsWidth )
203             aQRect = QRect( aleft, atop, mySize, aheight );
204           else
205             aQRect = QRect( aleft, atop, awidth, mySize );
206
207           aStudyParent->setGeometry(aQRect);
208         } 
209       }
210   };    
211
212   class TGetViewWidthHeight: public SALOME_Event{
213   public:
214     typedef CORBA::Long TResult;
215     TResult myResult;
216     bool myIsWidth;
217     View_i*  myView;
218   public:
219       TGetViewWidthHeight( View_i* aView, bool IsWidth ):
220         SALOME_Event(), myView( aView ), myIsWidth( IsWidth )
221           {}
222
223           virtual void Execute()
224             {
225               if( myView ) {
226                 QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
227                 if( myIsWidth )
228                   myResult = aStudyParent->frameGeometry().width();
229                 else
230                   myResult = aStudyParent->frameGeometry().height();
231               }
232             }
233   };
234
235   class TSetViewPositionHorizontal: public SALOME_Event{
236     VISU::View::ViewPosition     myViewPos;
237     View_i*                      myView;   
238   public:
239      TSetViewPositionHorizontal ( View_i* aView,
240                                   VISU::View::ViewPosition ViewPos  ):
241        SALOME_Event(), myView( aView ), myViewPos(ViewPos)
242     {}
243     virtual void Execute(){
244     QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
245     QWidget* aStudy = dynamic_cast <QWidget*> (myView->myStudyFrame);
246     QWidget* aStudyParent = aStudy->parentWidget(true);
247     if ( aStudyParent != 0 )
248       if ( aWorkspace!=NULL || aStudy != NULL )
249         switch(myViewPos){
250           case VISU::View::LEFT:
251           QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignLeft);
252             break;
253           case VISU::View::CENTER:
254             QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignHCenter);
255             break;
256           case VISU::View::RIGHT:
257             QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignRight);
258             break;
259         }
260     }
261   };
262
263   class TSetViewPositionVertical: public SALOME_Event{
264     VISU::View::ViewPosition     myViewPos;
265     View_i*                      myView;
266   public:
267       TSetViewPositionVertical ( View_i* aView,
268                                  VISU::View::ViewPosition ViewPos  ):
269         SALOME_Event(), myView( aView ), myViewPos(ViewPos)
270     {}
271     virtual void Execute(){
272     QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
273     QWidget* aStudy = dynamic_cast <QWidget*>(myView->myStudyFrame);
274     QWidget* aStudyParent = aStudy->parentWidget(true);
275     if ( aStudyParent != 0 )
276       if ( aWorkspace!=NULL || aStudy != NULL )
277         switch(myViewPos){
278           case VISU::View::TOP:
279           QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignTop);
280             break;
281           case VISU::View::CENTER:
282             QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignVCenter);
283             break;
284           case VISU::View::BOTTOM:
285             QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignBottom);
286             break;
287         }
288     }
289   };
290
291   class TSetRelativePosition : public SALOME_Event
292   {
293     View_i*                      myView;
294     CORBA::Double                myX, myY;
295   public:
296     TSetRelativePosition ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
297       SALOME_Event(), myView( aView ), myX( X ), myY( Y )
298     {}
299     virtual void Execute(){
300       QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
301       if( aWorkspace )
302       {
303         QAD_StudyFrame* aFrame = myView->myStudyFrame;
304         QWidget* aStudyParent = aFrame->parentWidget(true);
305         aStudyParent->move( int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
306       }
307     }
308   };
309
310   class TSetRelativeSize : public SALOME_Event
311   {
312     View_i*                      myView;
313     CORBA::Double                myX, myY;
314   public:
315     TSetRelativeSize ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
316       SALOME_Event(), myView( aView ), myX( X ), myY( Y )
317     {}
318     virtual void Execute(){
319       QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
320       if( aWorkspace )
321       {
322         QAD_StudyFrame* aFrame = myView->myStudyFrame;
323         QWidget* aStudyParent = aFrame->parentWidget(true);
324         aStudyParent->setGeometry( aStudyParent->x(), aStudyParent->y(),
325                              int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
326       }
327     }
328   };
329
330
331
332   class TSavePictureEvent: public SALOME_Event{
333     QWidget* myWidget;
334     const char* myFileName;
335   public:
336     typedef CORBA::Boolean TResult;
337     TResult myResult;
338     TSavePictureEvent(QWidget* theWidget, const char* theFileName):
339       myWidget(theWidget),
340       myFileName(theFileName),
341       myResult(false)
342     {}
343     virtual void Execute(){
344       if(myWidget){
345         QPixmap px = QPixmap::grabWindow(myWidget->winId());
346         if (!QString(myFileName).isNull()) {
347           QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper();
348           if (fmt.isEmpty())
349             fmt = QString("BMP"); // default format
350           if (fmt == "JPG")
351             fmt = "JPEG";
352           myResult = px.save(myFileName, fmt.latin1());
353         }
354       }
355     }
356   };
357
358
359   void RepaintView(QAD_StudyFrame* theStudyFrame);
360   class TRepaintViewEvent: public SALOME_Event{
361     QAD_StudyFrame* myStudyFrame;
362   public:
363     TRepaintViewEvent(QAD_StudyFrame* theStudyFrame):
364       myStudyFrame(theStudyFrame)
365     {}
366     virtual void Execute(){
367       RepaintView(myStudyFrame);
368     }
369   };
370   
371
372   VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
373     return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
374   }
375   vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
376     return GetViewFrame(theStudyFrame)->getRenderer();
377   }
378   vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
379     return GetRenderer(theStudyFrame)->GetActiveCamera();
380   }
381
382
383   void RepaintView(VTKViewer_ViewFrame* theViewFrame){
384     theViewFrame->getRenderer()->ResetCameraClippingRange();
385     theViewFrame->getRW()->getRenderWindow()->Render();
386     //GetViewFrame(theStudyFrame)->Repaint();
387   }
388
389   void RepaintView(QAD_StudyFrame* theStudyFrame){
390     RepaintView(GetViewFrame(theStudyFrame));
391   }
392
393
394   VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
395     VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
396     if (!vf) return NULL;
397     if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
398     vtkRenderer *aRen = vf->getRenderer();
399     vtkActorCollection *anActColl = aRen->GetActors();
400     vtkActor *anActor;
401     VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
402     for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
403       if(anActor->IsA("VISU_Actor")){ 
404         anVISUActor = VISU_Actor::SafeDownCast(anActor);
405         if (thePrs == anVISUActor->GetPrs3d()) {
406           aResActor = anVISUActor->GetParent();
407           if(theDisplaing < eErase)
408             aResActor->VisibilityOn();
409           else
410             aResActor->VisibilityOff();
411         } else {
412           if(theDisplaing > eDisplay)
413             anVISUActor->VisibilityOff();
414           else
415             anVISUActor->VisibilityOn();
416         } 
417       }
418     }
419     if (aResActor) {
420       RepaintView(theStudyFrame);
421       return aResActor;
422     }
423     if(thePrs != NULL && theDisplaing < eErase){
424       try{
425         anVISUActor = thePrs->CreateActor();
426         vf->AddActor(anVISUActor);
427       }catch(std::exception& exc){
428         if(MYDEBUG) INFOS(exc.what());
429         return NULL;
430       }catch(...){
431         if(MYDEBUG) INFOS("Unknown exception was occured!!!");
432         return NULL;
433       }
434     }
435     RepaintView(theStudyFrame);
436     return anVISUActor;
437   }
438   void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
439     if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
440     if ( !theView )
441       return;
442     QList<Plot2d_Curve> clist;
443     theView->getCurves( clist );
444     if ( theDisplaying == eEraseAll ) {
445       for ( int i = 0; i < clist.count(); i++ ) {
446         if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
447         theView->eraseCurve( clist.at( i ) );
448       }
449     }
450     else if ( theDisplaying == eErase ) {
451       for ( int i = 0; i < clist.count(); i++ ) {
452         if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
453           if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
454           theView->eraseCurve( clist.at( i ) );
455         }
456       }
457     }
458     else if ( theDisplaying == eDisplay ) {
459       bool bFound = false;
460       for ( int i = 0; i < clist.count(); i++ ) {
461         if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
462           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
463           clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
464           clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
465           clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
466           clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
467           double* xList = 0;
468           double* yList = 0;
469           int     nbPoints = theCurve->GetData( xList, yList );
470           if ( nbPoints > 0 && xList && yList ) {
471             clist.at( i )->setData( xList, yList, nbPoints );
472           }
473           if ( !theCurve->IsAuto() ) {
474             clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
475             clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
476             SALOMEDS::Color color = theCurve->GetColor();
477             clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
478           }
479           clist.at( i )->setAutoAssign( theCurve->IsAuto() );
480           theView->displayCurve( clist.at( i ) );
481           bFound = true;
482         }
483       }
484       if ( !bFound ) {
485         Plot2d_Curve* crv = theCurve->CreatePresentation();
486         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
487         if ( crv ) {
488           theView->displayCurve( crv );
489           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
490           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
491           SALOMEDS::Color newColor;
492           newColor.R = crv->getColor().red()/255.;
493           newColor.G = crv->getColor().green()/255.;
494           newColor.B = crv->getColor().blue()/255.;
495           theCurve->SetColor( newColor );
496           crv->setAutoAssign( theCurve->IsAuto() );
497         }
498       }
499     }
500     else if ( theDisplaying == eDisplayOnly ) {
501       bool bFound = false;
502       for ( int i = 0; i < clist.count(); i++ ) {
503         if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
504           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
505           clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
506           clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
507           clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
508           clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
509           double* xList = 0;
510           double* yList = 0;
511           int     nbPoints = theCurve->GetData( xList, yList );
512           if ( nbPoints > 0 && xList && yList ) {
513             clist.at( i )->setData( xList, yList, nbPoints );
514           }
515           if ( !theCurve->IsAuto() ) {
516             clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
517             clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
518             SALOMEDS::Color color = theCurve->GetColor();
519             clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
520           }
521           clist.at( i )->setAutoAssign( theCurve->IsAuto() );
522           theView->displayCurve( clist.at( i ) );
523           bFound = true;
524         }
525         else {
526           theView->eraseCurve( clist.at( i ) );
527         }
528       }
529       if ( !bFound ) {
530         Plot2d_Curve* crv = theCurve->CreatePresentation();
531         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
532         if ( crv ) {
533           theView->displayCurve( crv );
534           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
535           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
536           SALOMEDS::Color newColor;
537           newColor.R = crv->getColor().red()/255.;
538           newColor.G = crv->getColor().green()/255.;
539           newColor.B = crv->getColor().blue()/255.;
540           theCurve->SetColor( newColor );
541           crv->setAutoAssign( theCurve->IsAuto() );
542         }
543       }
544     }
545   }
546
547   QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) {
548     QAD_Desktop* aDesktop = QAD_Application::getDesktop();
549     QAD_Study* aStudy = aDesktop->findStudy(theStudy);
550     if(!aStudy){
551       CORBA::String_var aName = theStudy->Name();
552       aFileInfo.setFile(aName.in());
553       if (aFileInfo.exists()) 
554         aStudy = aDesktop->loadStudy(aFileInfo.baseName());
555       else 
556         aStudy = aDesktop->loadStudy(aName.in());
557       if (!aStudy) {
558         MESSAGE("CheckStudy()::ERROR: Can't load study");
559       }
560     }
561     return aStudy;
562   }
563   //===========================================================================
564   ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
565     if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
566     myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
567   }
568
569
570   class TGetCurrentViewEvent: public SALOME_Event{
571     SALOMEDS::Study_ptr myStudyDocument;
572   public:
573     TGetCurrentViewEvent( SALOMEDS::Study_ptr theStudy):
574       myStudyDocument(theStudy),
575       myResult(VISU::View::_nil())
576     {}
577     virtual void Execute(){
578       if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
579         if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
580           if(MYDEBUG) 
581             MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
582           if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
583             VISU::View3D_i* pView = new View3D_i(myStudyDocument);
584             if(pView->Create(0)) 
585               myResult = pView->_this();
586           } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
587             VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
588             if(pView->Create(0)) 
589               myResult = pView->_this();
590           }
591         }
592       }
593     }
594     typedef VISU::View_ptr TResult;
595     TResult myResult;
596   };
597
598   VISU::View_ptr ViewManager_i::GetCurrentView(){
599     return ProcessEvent(new TGetCurrentViewEvent( myStudyDocument ));
600   }
601   
602   
603   class TCreateViewEvent: public SALOME_Event{
604   public:
605     TCreateViewEvent( SALOMEDS::Study_ptr theStudy):
606       myStudyDocument(theStudy)
607     {};
608   protected:
609     SALOMEDS::Study_ptr myStudyDocument;
610   };
611
612
613   template<class TViewFrame>
614   class TCreateViewFrameEvent: public TCreateViewEvent{
615   public:
616     typedef typename TViewFrame::TInterface TInterface;
617     typedef typename TInterface::_ptr_type TResult;
618     TResult myResult;
619     TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy):
620       TCreateViewEvent(theStudy),
621       myResult(TInterface::_nil())
622     {}
623     virtual void Execute(){
624       if(CheckStudy(myStudyDocument)){
625         TViewFrame* pView = new TViewFrame(myStudyDocument);
626         if(pView->Create(1)) 
627           myResult = pView->_this();
628       }
629     }
630   };
631
632
633   VISU::View3D_ptr ViewManager_i::Create3DView(){
634     if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
635     return ProcessEvent(new TCreateViewFrameEvent<VISU::View3D_i>(myStudyDocument));
636   }
637
638   
639   VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
640     if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
641     return ProcessEvent(new TCreateViewFrameEvent<VISU::XYPlot_i>(myStudyDocument));
642   }
643
644
645   class TCreateTableViewEvent: public TCreateViewEvent{
646     Table_ptr myTable;
647   public:
648     TCreateTableViewEvent(SALOMEDS::Study_ptr theStudy,
649                           Table_ptr theTable):
650       TCreateViewEvent(theStudy),
651       myTable(theTable),
652       myResult(VISU::TableView::_nil())
653     {}
654     virtual void Execute(){
655       if ( CheckStudy( myStudyDocument ) ) {
656         VISU::TableView_i* pView = new TableView_i(myStudyDocument);
657         if(pView->Create(myTable) != NULL) 
658           myResult = pView->_this();
659       }
660     }
661     typedef VISU::TableView_ptr TResult;
662     TResult myResult;
663   };
664
665   VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
666     if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
667     return ProcessEvent(new TCreateTableViewEvent(myStudyDocument,theTable));
668   }
669
670
671   void ViewManager_i::Destroy(View_ptr theView){
672     class TEvent: public SALOME_Event{
673       View_ptr myView;
674     public:
675       TEvent(View_ptr theView):
676         myView(theView)
677       {}
678       virtual void Execute(){
679         if(!CORBA::is_nil(myView)){
680           if(VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
681             pView->Close();
682             pView->_remove_ref();
683           }
684         }
685       }
686     };
687     if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
688     ProcessVoidEvent(new TEvent(theView));
689   }
690
691
692   //===========================================================================
693   View_i::View_i(SALOMEDS::Study_ptr theStudy) {
694     myStudyFrame =  NULL;
695     if(MYDEBUG) MESSAGE("View_i::View_i");
696     CORBA::String_var aName = theStudy->Name();
697     myStudy = CheckStudy(theStudy);
698     if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
699   }
700
701   View_i::~View_i(){
702     if(MYDEBUG) MESSAGE("View_i::~View_i");
703   }
704
705   void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
706   SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
707   void View_i::Minimize() {}
708   void View_i::Restore() {}
709   void View_i::Maximize() {}
710   void View_i::EraseAll() {}
711   void View_i::DisplayAll() {}
712   void View_i::Erase(PrsObject_ptr thePrsObj) {}
713   void View_i::Display(PrsObject_ptr thePrsObj) {}
714   void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
715   void View_i::Update() {}
716
717   CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
718
719   const char* View_i::GetComment() const { return "";}
720   void View_i::ToStream(std::ostringstream& theStr) {}
721
722   string View_i::GetEntry(){ 
723     SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
724     CORBA::String_var anEntry = aSObject->GetID();
725     return string(anEntry.in());
726   }
727
728
729   //===========================================================================
730   XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
731     if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
732   }
733
734   Storable* XYPlot_i::Create(int theNew){
735     if(theNew)
736       myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
737     else
738       myStudyFrame = myStudy->getActiveStudyFrame();
739     myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
740     myView->Repaint();
741     return this;
742   } 
743
744
745   void XYPlot_i::Update() {
746     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
747   }
748
749
750   void XYPlot_i::Close(){
751     myStudyFrame->close();
752   }
753
754   XYPlot_i::~XYPlot_i() {
755     if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
756   }
757
758
759   void XYPlot_i::SetTitle(const char* theTitle){
760     ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
761                      (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle)));
762   }
763   char* XYPlot_i::GetTitle() {
764     return CORBA::string_dup(myStudyFrame->title().latin1());
765   }
766
767
768   void XYPlot_i::SetSubTitle(const char* theTitle){
769     ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
770                      (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle)));
771   }
772   char* XYPlot_i::GetSubTitle() {
773     return CORBA::string_dup(myView->getTitle());
774   }
775
776
777   void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
778     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
779                      (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
780   }
781   VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
782     return (VISU::XYPlot::CurveType)myView->getCurveType();
783   }
784
785
786   void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
787     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
788                      (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
789   }
790   CORBA::Long XYPlot_i::GetMarkerSize(){
791     return myView->getMarkerSize();
792   }
793
794
795   class TEnbleGridEvent: public SALOME_Event{
796   public:
797     typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true);
798     TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun,
799                     CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
800                     CORBA::Boolean theMinor, CORBA::Long theNumMinor):
801       myView(theView), myFun(theFun),
802       myMajor(theMajor), myNumMajor(theNumMajor),
803       myMinor(theMinor), myNumMinor(theNumMinor)
804     {}
805     virtual void Execute(){
806       (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor);
807     }
808   protected:
809     Plot2d_ViewFrame* myView;
810     TFun myFun;
811     CORBA::Boolean myMajor, myNumMajor;
812     CORBA::Boolean myMinor, myNumMinor;
813   };
814
815
816   void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
817                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
818   {
819     ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
820                                          theMajor,theNumMajor,theMinor,theNumMinor));
821   }
822   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
823                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
824   {
825     ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
826                                          theMajor,theNumMajor,theMinor,theNumMinor));
827   }
828
829
830   class TSetScaleModeEvent: public SALOME_Event{
831   public:
832     typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true);
833     TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
834       myView(theView), myFun(theFun), myScaling(theScaling)
835     {}
836     virtual void Execute(){
837       (myView->*myFun)(myScaling);
838     }
839   protected:
840     Plot2d_ViewFrame* myView;
841     TFun myFun;
842     int myScaling;
843   };
844
845
846   void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
847     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
848                                             theScaling == VISU::LOGARITHMIC));
849   }
850   VISU::Scaling XYPlot_i::GetHorScaling(){
851     return (VISU::Scaling)myView->getHorScaleMode();
852   }
853
854
855   void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
856     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
857                                             theScaling == VISU::LOGARITHMIC));
858   }
859   VISU::Scaling XYPlot_i::GetVerScaling(){
860     return (VISU::Scaling)myView->getVerScaleMode();
861   }
862
863
864   class TSetTitleEvent: public SALOME_Event{
865   public:
866     typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
867     TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
868       myView(theView), myFun(theFun), myTitle(theTitle)
869     {}
870     virtual void Execute(){
871       (myView->*myFun)(true,myTitle);
872     }
873   protected:
874     Plot2d_ViewFrame* myView;
875     TFun myFun;
876     const char* myTitle;
877   };
878
879
880   void XYPlot_i::SetXTitle(const char* theTitle){
881     ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle));
882   }
883   char* XYPlot_i::GetXTitle() {
884     return CORBA::string_dup(myView->getXTitle());
885   }
886
887
888   void XYPlot_i::SetYTitle(const char* theTitle){
889     ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle));
890   }
891   char* XYPlot_i::GetYTitle() {
892     return CORBA::string_dup(myView->getYTitle());
893   }
894
895
896   void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
897     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
898                      (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
899   }
900
901
902   void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
903     ProcessVoidEvent(new TSetBackgroundEvent<Plot2d_ViewFrame>(myView,theColor));
904   }
905   SALOMEDS::Color XYPlot_i::GetBackground() {
906     SALOMEDS::Color aColor;
907     aColor.R = myView->backgroundColor().red()/255.0;
908     aColor.G = myView->backgroundColor().green()/255.0;
909     aColor.B = myView->backgroundColor().blue()/255.0;
910     return aColor;
911   }
912
913   void XYPlot_i::Minimize() {
914     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
915   }
916
917   void XYPlot_i::Restore() {
918     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
919   }
920
921   void XYPlot_i::Maximize() {
922     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
923   }
924
925
926   class TXYPlotViewEvent: public SALOME_Event{
927     QAD_Study* myStudy;
928     Plot2d_ViewFrame* myView;
929     PrsObject_ptr myPrsObj;
930     int myDisplaing;
931   public:
932     TXYPlotViewEvent(QAD_Study* theStudy, 
933                      Plot2d_ViewFrame* theView, 
934                      PrsObject_ptr thePrsObj, 
935                      int theDisplaing):
936       myStudy(theStudy),
937       myView(theView), 
938       myPrsObj(thePrsObj), 
939       myDisplaing(theDisplaing)
940     {}
941     virtual void Execute(){
942       // is it Curve ?
943       if(Curve_i* aCurve =  dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
944         UpdatePlot2d(myView,myDisplaing,aCurve);
945       }
946       // is it Container ?
947       if(Container_i* aContainer =  dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
948         int nbCurves = aContainer->GetNbCurves();
949         for ( int i = 1; i <= nbCurves; i++ ) {
950           VISU::Curve_i* aCurve = aContainer->GetCurve( i );
951           if ( aCurve && aCurve->IsValid() ) {
952             UpdatePlot2d(myView,myDisplaing,aCurve);
953           }
954         }
955         myView->Repaint();
956       }
957       // is it Table ?
958       if(Table_i* aTable =  dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
959         SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
960         SALOMEDS::SObject_var TableSO = aStudy->FindObjectID( aTable->GetEntry() );
961         if ( !TableSO->_is_nil() ) {
962           SALOMEDS::ChildIterator_var Iter = aStudy->NewChildIterator( TableSO );
963           for ( ; Iter->More(); Iter->Next() ) {
964             CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
965             if( !CORBA::is_nil( childObject ) ) {
966               CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
967               if( !CORBA::is_nil( aCurve ) )
968                 UpdatePlot2d(myView,myDisplaing,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
969             }
970           }
971           myView->Repaint();
972         }
973       }
974     }
975   };
976
977
978   void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
979     ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplay));
980   }
981
982
983   void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
984     ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eErase));
985   }
986
987
988   void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
989     ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplayOnly));
990   }
991
992
993   void XYPlot_i::EraseAll() {
994     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::EraseAll));
995   }
996
997
998   void XYPlot_i::FitAll() {
999     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::fitAll));
1000   }
1001
1002
1003   CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
1004     return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(),theFileName));
1005   }
1006
1007
1008   //===========================================================================
1009   TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
1010   Storable* TableView_i::Create(VISU::Table_ptr theTable){
1011     if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
1012     if(!theTable->_is_nil()){
1013       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1014       if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
1015       if(table != NULL) {
1016         SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
1017         if(!aSObject->_is_nil()) {
1018           myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
1019                                           aSObject,
1020                                           false, 
1021                                           SALOMEGUI_TableDlg::ttAuto, 
1022                                           Qt::Vertical);
1023           myView->show();
1024           return this;
1025         }
1026       }
1027     }
1028     return NULL;
1029   }
1030
1031
1032   TableView_i::~TableView_i() {
1033     if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1034     delete myView;
1035   }
1036
1037
1038   void TableView_i::SetTitle(const char* theTitle){
1039     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SALOMEGUI_TableDlg,const QString&,QString>
1040                      (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle)));
1041   }
1042
1043
1044   char* TableView_i::GetTitle() {
1045     return CORBA::string_dup(myView->caption().latin1());
1046   }
1047
1048
1049   void TableView_i::Close(){
1050     myView->close();
1051   }
1052
1053
1054   //===========================================================================
1055   int View3D_i::myNbViewParams = 0;
1056   const string View3D_i::myComment = "VIEW3D";
1057   const char* View3D_i::GetComment() const { return myComment.c_str();}
1058   QString View3D_i::GenerateViewParamsName() { 
1059     return VISU::GenerateName( "ViewParams", ++myNbViewParams ); 
1060   }
1061
1062   View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
1063     if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
1064   }
1065
1066   Storable* View3D_i::Create(int theNew){
1067     if(MYDEBUG) MESSAGE("View3D_i::Create");
1068     if(theNew)
1069       myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
1070     else
1071       myStudyFrame = myStudy->getActiveStudyFrame();
1072     return this;
1073   }
1074
1075
1076   void View3D_i::Update(){
1077     class TEvent: public SALOME_Event{
1078       QAD_StudyFrame* myStudyFrame;
1079     public:
1080       TEvent(QAD_StudyFrame* theStudyFrame):
1081         myStudyFrame(theStudyFrame)
1082       {}
1083       virtual void Execute(){
1084         VTKViewer_ViewFrame* vf =  GetViewFrame(myStudyFrame);
1085         vtkRenderer* Renderer = vf->getRenderer();
1086         vtkActorCollection* theActors = Renderer->GetActors();
1087         theActors->InitTraversal();
1088         while(vtkActor *anAct = theActors->GetNextActor()){
1089           if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
1090             VISU::Prs3d_i* aPrs3d  = anActor->GetPrs3d();
1091             if(anActor->GetVisibility() && aPrs3d){
1092               aPrs3d->Update();
1093               aPrs3d->UpdateActor(anActor);
1094             }
1095           }
1096         }
1097         RepaintView(myStudyFrame);
1098       }
1099     };
1100     ProcessVoidEvent(new TEvent(myStudyFrame));
1101   }
1102
1103
1104   CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
1105     return ProcessEvent(new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName));
1106   }
1107
1108
1109   bool View3D_i::SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
1110     QAD_Study* aStudy = theStudyFrame->getStudy();
1111     SALOMEDS::Study_var aStudyDoc = aStudy->getStudyDocument();
1112     if ( theName ) {
1113       SALOMEDS::Study::ListOfSObject_var aList = 
1114         aStudyDoc->FindObjectByName(theName,"VISU");
1115       SALOMEDS::GenericAttribute_var anAttr;
1116       int iEnd = aList->length();
1117       for(int i = 0; i < iEnd; i++){
1118         SALOMEDS::SObject_var anObj = aList[i];
1119         CORBA::String_var aString = anObj->GetID();
1120         string anEntry(aString);
1121         if(MYDEBUG)  MESSAGE("View3D_i::SaveViewParams - anEntry = "<<anEntry);
1122         if(anObj->FindAttribute(anAttr, "AttributeComment")){
1123           SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1124           aString = aCmnt->Value();
1125           string aComm(aString);
1126           if(MYDEBUG)  MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
1127           if(aComm.compare(View3D_i::myComment) >= 0){
1128             aCmnt->SetValue(ToString(theStudyFrame).c_str());
1129             return true;
1130           }
1131         }
1132       }
1133     }
1134     SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(aStudyDoc);
1135     CORBA::String_var aSComponentEntry = aSComponent->GetID();
1136     string anEntry = CreateAttributes(aStudyDoc,aSComponentEntry.in(),"","",theName,"",ToString(theStudyFrame).c_str());
1137     return true;
1138   }
1139   CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
1140     return SaveViewParams(myStudyFrame,theName);
1141   }
1142
1143
1144   bool View3D_i::RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
1145     SALOMEDS::Study::ListOfSObject_var aList = 
1146       theStudyFrame->getStudy()->getStudyDocument()->FindObjectByName(theName,"VISU");
1147     SALOMEDS::GenericAttribute_var anAttr;
1148     int iEnd = aList->length();
1149     if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
1150     for(int i = 0; i < iEnd; i++){
1151       SALOMEDS::SObject_var anObj = aList[i];
1152       CORBA::String_var aString = anObj->GetID();
1153       string anEntry(aString);
1154       if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
1155       if(anObj->FindAttribute(anAttr, "AttributeComment")){
1156         SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1157         aString = aCmnt->Value();
1158         QString strIn(aString);
1159         Storable::TRestoringMap aMap;
1160         Storable::StrToMap(strIn,aMap);
1161         if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
1162           if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
1163           Restore(theStudyFrame,aMap);
1164           return true;
1165         }
1166       }
1167     }
1168     return false;
1169   }
1170
1171
1172   class TRestoreViewParamsEvent: public SALOME_Event{
1173     QAD_StudyFrame* myStudyFrame;
1174     const char* myName;
1175   public:
1176     TRestoreViewParamsEvent(QAD_StudyFrame* theStudyFrame,
1177                             const char* theName):
1178       myStudyFrame(theStudyFrame),
1179       myName(theName)
1180     {}
1181     virtual void Execute(){
1182       myResult = View3D_i::RestoreViewParams(myStudyFrame,myName);
1183     }
1184     typedef CORBA::Boolean TResult;
1185     TResult myResult;
1186   };
1187
1188   CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
1189     return ProcessEvent(new TRestoreViewParamsEvent(myStudyFrame,theName));
1190   }
1191
1192
1193   void View3D_i::Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap){
1194     SALOMEDS::Color aColor;  
1195     aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1196     aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1197     aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1198     
1199     double aPosition[3];
1200     aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1201     aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1202     aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1203     
1204     double aFocalPnt[3];
1205     aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1206     aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1207     aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1208     
1209     double aViewUp[3];
1210     aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1211     aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1212     aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1213     
1214     double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1215      
1216     double aScaleFactor[3];
1217     aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1218     aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1219     aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1220     
1221     SetBackground(theStudyFrame,aColor);
1222     SetPointOfView(theStudyFrame,aPosition);
1223     SetViewUp(theStudyFrame,aViewUp);
1224     SetFocalPoint(theStudyFrame,aFocalPnt);
1225     SetParallelScale(theStudyFrame,aParallelScale);
1226     ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1227     ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1228     ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1229   }
1230     
1231
1232   string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){
1233     ostringstream strOut;
1234     Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1235     ToStream(theStudyFrame,strOut);
1236     strOut<<ends;
1237     if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1238     return strOut.str(); 
1239   }
1240   void View3D_i::ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr) {
1241     Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1242     
1243     float backint[3];  
1244     GetRenderer(theStudyFrame)->GetBackground(backint);
1245     Storable::DataToStream(theStr,"myColor.R",backint[0]);
1246     Storable::DataToStream(theStr,"myColor.G",backint[1]);
1247     Storable::DataToStream(theStr,"myColor.B",backint[2]);
1248     
1249     double aPosition[3];
1250     GetPointOfView(theStudyFrame,aPosition);
1251     Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1252     Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1253     Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1254     
1255     double aFocalPnt[3];
1256     GetFocalPoint(theStudyFrame,aFocalPnt);
1257     Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1258     Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1259     Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1260     
1261     double aViewUp[3];
1262     GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1263     Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1264     Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1265     Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1266     
1267     Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1268     
1269     double aScaleFactor[3];
1270     GetViewFrame(theStudyFrame)->GetScale(aScaleFactor);
1271     Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1272     Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1273     Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1274   }
1275   void View3D_i::ToStream(std::ostringstream& theStr) {
1276     ToStream(myStudyFrame,theStr);
1277   }
1278
1279
1280   void View3D_i::Close(){
1281     myStudyFrame->close();
1282   }
1283
1284   View3D_i::~View3D_i() {
1285     if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1286   }
1287
1288   //-------------------- View interface --------------------
1289
1290   void View_i::ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state  ) {
1291     ProcessVoidEvent( new TSetViewRepresentation( this, ViewRepr, state ) );
1292     Update();
1293   }
1294
1295   CORBA::Boolean View_i::IsPartShown( VISU::View::ViewRepresentation Part )
1296   {
1297     return ProcessEvent( new TGetViewRepresentation( this, Part ) );
1298   }
1299
1300   void View_i::SetViewWidth(CORBA::Long Width){
1301     ProcessVoidEvent( new TSetViewWidthHeight( this, Width, true ) );
1302      }
1303   
1304   void View_i::SetViewHeight(CORBA::Long Height){ 
1305     ProcessVoidEvent( new TSetViewWidthHeight( this, Height, false ) );
1306      }
1307
1308   CORBA::Long View_i::GetViewWidth() 
1309   {
1310     return ProcessEvent( new TGetViewWidthHeight( this, true ) );
1311   }
1312
1313   CORBA::Long View_i::GetViewHeight()
1314   {
1315     return ProcessEvent( new TGetViewWidthHeight( this, false ) );
1316   }
1317
1318   void View_i::SetViewPositionHorizontal( VISU::View::ViewPosition ViewPosHor ){
1319     ProcessVoidEvent( new TSetViewPositionHorizontal( this, ViewPosHor ) );
1320   }
1321
1322   void View_i::SetViewPositionVertical( VISU::View::ViewPosition ViewPosVer ){
1323     ProcessVoidEvent( new TSetViewPositionVertical( this, ViewPosVer ) );
1324   }
1325
1326   void View_i::SetRelativePosition( CORBA::Double x, CORBA::Double y )
1327   {
1328     ProcessVoidEvent( new TSetRelativePosition( this, x, y ) );
1329   }
1330
1331   void View_i::SetRelativeSize( CORBA::Double x, CORBA::Double y )
1332   {
1333     ProcessVoidEvent( new TSetRelativeSize( this, x, y ) );
1334   }
1335
1336
1337
1338
1339   void View3D_i::SetTitle(const char* theTitle){
1340     ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
1341                      (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle)));
1342   }
1343   char* View3D_i::GetTitle() {
1344     return CORBA::string_dup(myStudyFrame->title().latin1());
1345   }
1346
1347
1348   void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
1349     int aColor[3];
1350     aColor[0] = int(255.0*theColor.R);
1351     aColor[1] = int(255.0*theColor.G);
1352     aColor[2] = int(255.0*theColor.B);
1353     QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1354     GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
1355   }
1356   void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
1357     ProcessVoidEvent(new TSetBackgroundEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),theColor));
1358   }
1359
1360
1361   SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) { 
1362     SALOMEDS::Color aColor;
1363     float backint[3];  
1364     GetRenderer(theStudyFrame)->GetBackground(backint);
1365     aColor.R = backint[0];  aColor.G = backint[1];  aColor.B = backint[2];
1366     return aColor;
1367   }
1368   SALOMEDS::Color View3D_i::GetBackground() { 
1369     return GetBackground(myStudyFrame);
1370   }
1371
1372
1373   void View3D_i::Minimize() {
1374     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
1375   }
1376   void View3D_i::Restore() {
1377     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
1378   }
1379   void View3D_i::Maximize() {
1380     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
1381   }
1382
1383
1384   //===========================================================================
1385   class TUpdateViewerEvent: public SALOME_Event{
1386     QAD_StudyFrame* myStudyFrame;
1387     Prs3d_i* myPrs3d;
1388     int myDisplaing;
1389   public:
1390     TUpdateViewerEvent(QAD_StudyFrame* theStudyFrame,
1391                        Prs3d_i* thePrs3d,
1392                        int theDisplaing):
1393       myStudyFrame(theStudyFrame),
1394       myPrs3d(thePrs3d),
1395       myDisplaing(theDisplaing)
1396     {}
1397     virtual void Execute(){
1398       UpdateViewer(myStudyFrame,myDisplaing,myPrs3d);
1399     }
1400   };
1401
1402   void View3D_i::EraseAll() {
1403     if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1404     ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eEraseAll));
1405   }
1406
1407   void View3D_i::DisplayAll() {
1408     if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1409     ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eDisplayAll));
1410   }
1411
1412   void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1413     if(MYDEBUG) MESSAGE("View3D_i::Erase");
1414     CORBA::Object_ptr anObj = thePrsObj;
1415     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1416       ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eErase));
1417     }
1418   }
1419
1420   void View3D_i::Display(PrsObject_ptr thePrsObj) {
1421     if(MYDEBUG) MESSAGE("View3D_i::Display"); 
1422     CORBA::Object_ptr anObj = thePrsObj;
1423     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1424       ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplay));
1425     }
1426   }
1427
1428   void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1429     if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1430     CORBA::Object_ptr anObj = thePrsObj;
1431     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1432       ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplayOnly));
1433     }
1434   }
1435
1436   //-------------------- View3D interface --------------------
1437   void View3D_i::FitAll() { 
1438     ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll));
1439     Update();
1440   }
1441
1442
1443   void View3D_i::SetView(VISU::View3D::ViewType theType) {
1444     switch(theType){
1445     case VISU::View3D::FRONT : 
1446       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront));
1447       break;
1448     case VISU::View3D::BACK : 
1449       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
1450       break;
1451     case VISU::View3D::LEFT : 
1452       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
1453       break;
1454     case VISU::View3D::RIGHT : 
1455       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
1456       break;
1457     case VISU::View3D::TOP : 
1458       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
1459       break;
1460     case VISU::View3D::BOTTOM : 
1461       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
1462       break;
1463     }
1464     Update();
1465   }
1466
1467
1468   class TSet3DViewParamEvent: public SALOME_Event{
1469   public:
1470     typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, const CORBA::Double theParam[3]);
1471     TSet3DViewParamEvent(TFun theFun,
1472                          QAD_StudyFrame* theStudyFrame,
1473                          const CORBA::Double theParam[3]):
1474       myFun(theFun),
1475       myStudyFrame(theStudyFrame),
1476       myParam(theParam)
1477     {}
1478     virtual void Execute(){
1479       myFun(myStudyFrame,myParam);
1480     }
1481   private:
1482     TFun myFun;
1483     QAD_StudyFrame* myStudyFrame;
1484     const CORBA::Double* myParam;
1485   };
1486
1487
1488   void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1489     GetCamera(theStudyFrame)->SetPosition(thePosition);
1490   }
1491   void View3D_i::SetPointOfView(const VISU::View3D::XYZ thePosition) {
1492     if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1493     ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myStudyFrame,thePosition));
1494   }
1495
1496
1497   void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) { 
1498     GetCamera(theStudyFrame)->GetPosition(thePosition);
1499   }
1500   VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { 
1501     if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1502     CORBA::Double aPosition[3];
1503     GetPointOfView(myStudyFrame,aPosition);
1504     return VISU::View3D::XYZ_dup(aPosition);
1505   }
1506
1507
1508   void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1509     GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1510   }
1511   void View3D_i::SetViewUp(const VISU::View3D::XYZ theViewUp) {
1512     if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1513     ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myStudyFrame,theViewUp));
1514   }
1515
1516
1517   void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) { 
1518     GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1519   }
1520   VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { 
1521     if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1522     CORBA::Double aViewUp[3];
1523     GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1524     return VISU::View3D::XYZ_dup(aViewUp);
1525   }
1526
1527
1528   void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1529     GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1530   }
1531   void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1532     if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1533     ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myStudyFrame,theCoord));
1534   }
1535
1536
1537   void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) { 
1538     GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1539   }
1540   VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { 
1541     if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1542     CORBA::Double aFocalPnt[3];
1543     GetFocalPoint(myStudyFrame,aFocalPnt);
1544     return VISU::View3D::XYZ_dup(aFocalPnt);
1545   }
1546
1547
1548   class TSetViewParamEvent: public SALOME_Event{
1549   public:
1550     typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, CORBA::Double theParam);
1551     TSetViewParamEvent(TFun theFun,
1552                        QAD_StudyFrame* theStudyFrame,
1553                        CORBA::Double theParam):
1554       myFun(theFun),
1555       myStudyFrame(theStudyFrame),
1556       myParam(theParam)
1557     {}
1558     virtual void Execute(){
1559       myFun(myStudyFrame,myParam);
1560     }
1561   private:
1562     TFun myFun;
1563     QAD_StudyFrame* myStudyFrame;
1564     CORBA::Double myParam;
1565   };
1566
1567
1568   void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1569     GetCamera(theStudyFrame)->SetParallelScale(theScale);
1570   }
1571   void View3D_i::SetParallelScale(CORBA::Double theScale) {
1572     if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1573     ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myStudyFrame,theScale));
1574   }
1575
1576
1577   CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) { 
1578     return GetCamera(theStudyFrame)->GetParallelScale();
1579   }
1580   CORBA::Double View3D_i::GetParallelScale() { 
1581     if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1582     return GetParallelScale(myStudyFrame);
1583   }
1584
1585   void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1586     VTKViewer_ViewFrame* aViewFrame =  GetViewFrame(theStudyFrame);
1587     double aScaleFactor[3];
1588     aViewFrame->GetScale(aScaleFactor);
1589     aScaleFactor[theAxis] = theParam;
1590     aViewFrame->SetScale(aScaleFactor);
1591   }
1592   
1593   void SetScaleView(QAD_StudyFrame* theStudyFrame, const CORBA::Double theScale[3]){
1594     double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1595     GetViewFrame(theStudyFrame)->SetScale(aScale);
1596   }
1597   void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1598     if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1599     double aScale[3];
1600     GetViewFrame(myStudyFrame)->GetScale(aScale);
1601     aScale[theAxis] = theParam;
1602     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1603   }
1604   void View3D_i::RemoveScale() {
1605     if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1606     double aScale[3] = {1.0, 1.0, 1.0};
1607     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1608   }
1609   //===========================================================================
1610
1611
1612   VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){
1613     vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
1614     anActColl->InitTraversal();
1615     while(vtkActor *anActor = anActColl->GetNextActor())
1616       if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
1617         if(thePrs3d == anVISUActor->GetPrs3d())
1618           return anVISUActor->GetParent();
1619     return NULL;
1620   }
1621
1622
1623   void DeletePrs3d(Prs3d_ptr thePrs3d){
1624     if(Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in())){
1625       SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
1626       SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
1627       if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){
1628         if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)){
1629           aStudy->unHighlightAll();
1630           int aNbStudyFrames = aStudy->getStudyFramesCount();
1631           for(int aFrameId = 0; aFrameId < aNbStudyFrames; aFrameId++){
1632             if(QAD_StudyFrame* aFrame = aStudy->getStudyFrame(aFrameId)){
1633               QAD_ViewFrame* aViewFrame = aFrame->getRightFrame()->getViewFrame();
1634               if(VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame)){
1635                 if(VISU_Actor* anActor = VISU::GetActor(aPrs3d,aVTKFrame)){
1636                   aVTKFrame->RemoveActor(anActor);
1637                   anActor->Delete();
1638                 }
1639                 aVTKFrame->unHighlightAll();
1640               }
1641             }
1642           }
1643
1644           aPrs3d->RemoveFromStudy(); 
1645           aPrs3d->Destroy(); 
1646
1647           aStudy->updateObjBrowser(); //update Object browser
1648         }
1649       }
1650     }
1651   }
1652
1653
1654   void VISU_Gen_i::DeleteResult(Result_ptr theResult)
1655   {
1656     class TEvent: public SALOME_Event{
1657       Result_ptr myResult;
1658     public:
1659       TEvent(Result_ptr theResult): myResult(theResult) {}
1660       virtual void Execute(){
1661         if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())){
1662           SALOMEDS::SObject_var aSObject = aResult->GetSObject();
1663           SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
1664           SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject);
1665           for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1666             SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1667             CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1668             if(CORBA::is_nil(aChildObj)) continue;
1669             VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1670             if(CORBA::is_nil(aPrs3d)) continue;
1671             VISU::DeletePrs3d(aPrs3d);
1672           }
1673
1674           aResult->RemoveFromStudy(); 
1675           aResult->Destroy(); 
1676
1677           if(QAD_Desktop* aDesktop = QAD_Application::getDesktop())
1678             if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
1679               aStudy->updateObjBrowser(); //update Object browser
1680         }
1681       }
1682     };
1683
1684     ProcessVoidEvent(new TEvent(theResult));
1685   }
1686
1687
1688   void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d)
1689   {
1690     class TEvent: public SALOME_Event{
1691       Prs3d_ptr myPrs3d;
1692     public:
1693       TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
1694       virtual void Execute(){
1695         VISU::DeletePrs3d(myPrs3d);
1696       }
1697     };
1698
1699     ProcessVoidEvent(new TEvent(thePrs3d));
1700   }
1701
1702 }