]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_ViewManager_i.cc
Salome HOME
Merge with version on tag OCC-V2_1_0d
[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::runtime_error& exc){
428         INFOS(exc.what());
429         return NULL;
430       }
431     }
432     RepaintView(theStudyFrame);
433     return anVISUActor;
434   }
435   void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
436     if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
437     if ( !theView )
438       return;
439     QList<Plot2d_Curve> clist;
440     theView->getCurves( clist );
441     if ( theDisplaying == eEraseAll ) {
442       for ( int i = 0; i < clist.count(); i++ ) {
443         if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
444         theView->eraseCurve( clist.at( i ) );
445       }
446     }
447     else if ( theDisplaying == eErase ) {
448       for ( int i = 0; i < clist.count(); i++ ) {
449         if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
450           if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
451           theView->eraseCurve( clist.at( i ) );
452         }
453       }
454     }
455     else if ( theDisplaying == eDisplay ) {
456       bool bFound = false;
457       for ( int i = 0; i < clist.count(); i++ ) {
458         if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
459           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
460           clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
461           clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
462           clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
463           clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
464           double* xList = 0;
465           double* yList = 0;
466           int     nbPoints = theCurve->GetData( xList, yList );
467           if ( nbPoints > 0 && xList && yList ) {
468             clist.at( i )->setData( xList, yList, nbPoints );
469           }
470           if ( !theCurve->IsAuto() ) {
471             clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
472             clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
473             SALOMEDS::Color color = theCurve->GetColor();
474             clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
475           }
476           clist.at( i )->setAutoAssign( theCurve->IsAuto() );
477           theView->displayCurve( clist.at( i ) );
478           bFound = true;
479         }
480       }
481       if ( !bFound ) {
482         Plot2d_Curve* crv = theCurve->CreatePresentation();
483         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
484         if ( crv ) {
485           theView->displayCurve( crv );
486           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
487           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
488           SALOMEDS::Color newColor;
489           newColor.R = crv->getColor().red()/255.;
490           newColor.G = crv->getColor().green()/255.;
491           newColor.B = crv->getColor().blue()/255.;
492           theCurve->SetColor( newColor );
493           crv->setAutoAssign( theCurve->IsAuto() );
494         }
495       }
496     }
497     else if ( theDisplaying == eDisplayOnly ) {
498       bool bFound = false;
499       for ( int i = 0; i < clist.count(); i++ ) {
500         if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
501           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
502           clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
503           clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
504           clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
505           clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
506           double* xList = 0;
507           double* yList = 0;
508           int     nbPoints = theCurve->GetData( xList, yList );
509           if ( nbPoints > 0 && xList && yList ) {
510             clist.at( i )->setData( xList, yList, nbPoints );
511           }
512           if ( !theCurve->IsAuto() ) {
513             clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
514             clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
515             SALOMEDS::Color color = theCurve->GetColor();
516             clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
517           }
518           clist.at( i )->setAutoAssign( theCurve->IsAuto() );
519           theView->displayCurve( clist.at( i ) );
520           bFound = true;
521         }
522         else {
523           theView->eraseCurve( clist.at( i ) );
524         }
525       }
526       if ( !bFound ) {
527         Plot2d_Curve* crv = theCurve->CreatePresentation();
528         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
529         if ( crv ) {
530           theView->displayCurve( crv );
531           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
532           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
533           SALOMEDS::Color newColor;
534           newColor.R = crv->getColor().red()/255.;
535           newColor.G = crv->getColor().green()/255.;
536           newColor.B = crv->getColor().blue()/255.;
537           theCurve->SetColor( newColor );
538           crv->setAutoAssign( theCurve->IsAuto() );
539         }
540       }
541     }
542   }
543
544   QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) {
545     QAD_Desktop* aDesktop = QAD_Application::getDesktop();
546     QAD_Study* aStudy = aDesktop->findStudy(theStudy);
547     if(!aStudy){
548       CORBA::String_var aName = theStudy->Name();
549       aFileInfo.setFile(aName.in());
550       if (aFileInfo.exists()) 
551         aStudy = aDesktop->loadStudy(aFileInfo.baseName());
552       else 
553         aStudy = aDesktop->loadStudy(aName.in());
554       if (!aStudy) {
555         MESSAGE("CheckStudy()::ERROR: Can't load study");
556       }
557     }
558     return aStudy;
559   }
560   //===========================================================================
561   ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
562     if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
563     myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
564   }
565
566
567   class TGetCurrentViewEvent: public SALOME_Event{
568     SALOMEDS::Study_ptr myStudyDocument;
569   public:
570     TGetCurrentViewEvent( SALOMEDS::Study_ptr theStudy):
571       myStudyDocument(theStudy),
572       myResult(VISU::View::_nil())
573     {}
574     virtual void Execute(){
575       if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
576         if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
577           if(MYDEBUG) 
578             MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
579           if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
580             VISU::View3D_i* pView = new View3D_i(myStudyDocument);
581             if(pView->Create(0)) 
582               myResult = pView->_this();
583           } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
584             VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
585             if(pView->Create(0)) 
586               myResult = pView->_this();
587           }
588         }
589       }
590     }
591     typedef VISU::View_ptr TResult;
592     TResult myResult;
593   };
594
595   VISU::View_ptr ViewManager_i::GetCurrentView(){
596     return ProcessEvent(new TGetCurrentViewEvent( myStudyDocument ));
597   }
598   
599   
600   class TCreateViewEvent: public SALOME_Event{
601   public:
602     TCreateViewEvent( SALOMEDS::Study_ptr theStudy):
603       myStudyDocument(theStudy)
604     {};
605   protected:
606     SALOMEDS::Study_ptr myStudyDocument;
607   };
608
609
610   template<class TViewFrame>
611   class TCreateViewFrameEvent: public TCreateViewEvent{
612   public:
613     typedef typename TViewFrame::TInterface TInterface;
614     typedef typename TInterface::_ptr_type TResult;
615     TResult myResult;
616     TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy):
617       TCreateViewEvent(theStudy),
618       myResult(TInterface::_nil())
619     {}
620     virtual void Execute(){
621       if(CheckStudy(myStudyDocument)){
622         TViewFrame* pView = new TViewFrame(myStudyDocument);
623         if(pView->Create(1)) 
624           myResult = pView->_this();
625       }
626     }
627   };
628
629
630   VISU::View3D_ptr ViewManager_i::Create3DView(){
631     if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
632     return ProcessEvent(new TCreateViewFrameEvent<VISU::View3D_i>(myStudyDocument));
633   }
634
635   
636   VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
637     if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
638     return ProcessEvent(new TCreateViewFrameEvent<VISU::XYPlot_i>(myStudyDocument));
639   }
640
641
642   class TCreateTableViewEvent: public TCreateViewEvent{
643     Table_ptr myTable;
644   public:
645     TCreateTableViewEvent(SALOMEDS::Study_ptr theStudy,
646                           Table_ptr theTable):
647       TCreateViewEvent(theStudy),
648       myTable(theTable),
649       myResult(VISU::TableView::_nil())
650     {}
651     virtual void Execute(){
652       if ( CheckStudy( myStudyDocument ) ) {
653         VISU::TableView_i* pView = new TableView_i(myStudyDocument);
654         if(pView->Create(myTable) != NULL) 
655           myResult = pView->_this();
656       }
657     }
658     typedef VISU::TableView_ptr TResult;
659     TResult myResult;
660   };
661
662   VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
663     if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
664     return ProcessEvent(new TCreateTableViewEvent(myStudyDocument,theTable));
665   }
666
667
668   void ViewManager_i::Destroy(View_ptr theView){
669     class TEvent: public SALOME_Event{
670       View_ptr myView;
671     public:
672       TEvent(View_ptr theView):
673         myView(theView)
674       {}
675       virtual void Execute(){
676         if(!CORBA::is_nil(myView)){
677           if(VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
678             pView->Close();
679             pView->_remove_ref();
680           }
681         }
682       }
683     };
684     if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
685     ProcessVoidEvent(new TEvent(theView));
686   }
687
688
689   //===========================================================================
690   View_i::View_i(SALOMEDS::Study_ptr theStudy) {
691     myStudyFrame =  NULL;
692     if(MYDEBUG) MESSAGE("View_i::View_i");
693     CORBA::String_var aName = theStudy->Name();
694     myStudy = CheckStudy(theStudy);
695     if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
696   }
697
698   View_i::~View_i(){
699     if(MYDEBUG) MESSAGE("View_i::~View_i");
700   }
701
702   void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
703   SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
704   void View_i::Minimize() {}
705   void View_i::Restore() {}
706   void View_i::Maximize() {}
707   void View_i::EraseAll() {}
708   void View_i::DisplayAll() {}
709   void View_i::Erase(PrsObject_ptr thePrsObj) {}
710   void View_i::Display(PrsObject_ptr thePrsObj) {}
711   void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
712   void View_i::Update() {}
713
714   CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
715
716   const char* View_i::GetComment() const { return "";}
717   void View_i::ToStream(std::ostringstream& theStr) {}
718
719   string View_i::GetEntry(){ 
720     SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
721     CORBA::String_var anEntry = aSObject->GetID();
722     return string(anEntry.in());
723   }
724
725
726   //===========================================================================
727   XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
728     if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
729   }
730
731   Storable* XYPlot_i::Create(int theNew){
732     if(theNew)
733       myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
734     else
735       myStudyFrame = myStudy->getActiveStudyFrame();
736     myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
737     myView->Repaint();
738     return this;
739   } 
740
741
742   void XYPlot_i::Update() {
743     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
744   }
745
746
747   void XYPlot_i::Close(){
748     myStudyFrame->close();
749   }
750
751   XYPlot_i::~XYPlot_i() {
752     if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
753   }
754
755
756   void XYPlot_i::SetTitle(const char* theTitle){
757     ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
758                      (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle)));
759   }
760   char* XYPlot_i::GetTitle() {
761     return CORBA::string_dup(myStudyFrame->title().latin1());
762   }
763
764
765   void XYPlot_i::SetSubTitle(const char* theTitle){
766     ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
767                      (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle)));
768   }
769   char* XYPlot_i::GetSubTitle() {
770     return CORBA::string_dup(myView->getTitle());
771   }
772
773
774   void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
775     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
776                      (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
777   }
778   VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
779     return (VISU::XYPlot::CurveType)myView->getCurveType();
780   }
781
782
783   void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
784     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
785                      (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
786   }
787   CORBA::Long XYPlot_i::GetMarkerSize(){
788     return myView->getMarkerSize();
789   }
790
791
792   class TEnbleGridEvent: public SALOME_Event{
793   public:
794     typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true);
795     TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun,
796                     CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
797                     CORBA::Boolean theMinor, CORBA::Long theNumMinor):
798       myView(theView), myFun(theFun),
799       myMajor(theMajor), myNumMajor(theNumMajor),
800       myMinor(theMinor), myNumMinor(theNumMinor)
801     {}
802     virtual void Execute(){
803       (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor);
804     }
805   protected:
806     Plot2d_ViewFrame* myView;
807     TFun myFun;
808     CORBA::Boolean myMajor, myNumMajor;
809     CORBA::Boolean myMinor, myNumMinor;
810   };
811
812
813   void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
814                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
815   {
816     ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
817                                          theMajor,theNumMajor,theMinor,theNumMinor));
818   }
819   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
820                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
821   {
822     ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
823                                          theMajor,theNumMajor,theMinor,theNumMinor));
824   }
825
826
827   class TSetScaleModeEvent: public SALOME_Event{
828   public:
829     typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true);
830     TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
831       myView(theView), myFun(theFun), myScaling(theScaling)
832     {}
833     virtual void Execute(){
834       (myView->*myFun)(myScaling);
835     }
836   protected:
837     Plot2d_ViewFrame* myView;
838     TFun myFun;
839     int myScaling;
840   };
841
842
843   void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
844     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
845                                             theScaling == VISU::LOGARITHMIC));
846   }
847   VISU::Scaling XYPlot_i::GetHorScaling(){
848     return (VISU::Scaling)myView->getHorScaleMode();
849   }
850
851
852   void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
853     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
854                                             theScaling == VISU::LOGARITHMIC));
855   }
856   VISU::Scaling XYPlot_i::GetVerScaling(){
857     return (VISU::Scaling)myView->getVerScaleMode();
858   }
859
860
861   class TSetTitleEvent: public SALOME_Event{
862   public:
863     typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
864     TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
865       myView(theView), myFun(theFun), myTitle(theTitle)
866     {}
867     virtual void Execute(){
868       (myView->*myFun)(true,myTitle);
869     }
870   protected:
871     Plot2d_ViewFrame* myView;
872     TFun myFun;
873     const char* myTitle;
874   };
875
876
877   void XYPlot_i::SetXTitle(const char* theTitle){
878     ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle));
879   }
880   char* XYPlot_i::GetXTitle() {
881     return CORBA::string_dup(myView->getXTitle());
882   }
883
884
885   void XYPlot_i::SetYTitle(const char* theTitle){
886     ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle));
887   }
888   char* XYPlot_i::GetYTitle() {
889     return CORBA::string_dup(myView->getYTitle());
890   }
891
892
893   void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
894     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
895                      (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
896   }
897
898
899   void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
900     ProcessVoidEvent(new TSetBackgroundEvent<Plot2d_ViewFrame>(myView,theColor));
901   }
902   SALOMEDS::Color XYPlot_i::GetBackground() {
903     SALOMEDS::Color aColor;
904     aColor.R = myView->backgroundColor().red()/255.0;
905     aColor.G = myView->backgroundColor().green()/255.0;
906     aColor.B = myView->backgroundColor().blue()/255.0;
907     return aColor;
908   }
909
910   void XYPlot_i::Minimize() {
911     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
912   }
913
914   void XYPlot_i::Restore() {
915     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
916   }
917
918   void XYPlot_i::Maximize() {
919     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
920   }
921
922
923   class TXYPlotViewEvent: public SALOME_Event{
924     QAD_Study* myStudy;
925     Plot2d_ViewFrame* myView;
926     PrsObject_ptr myPrsObj;
927     int myDisplaing;
928   public:
929     TXYPlotViewEvent(QAD_Study* theStudy, 
930                      Plot2d_ViewFrame* theView, 
931                      PrsObject_ptr thePrsObj, 
932                      int theDisplaing):
933       myStudy(theStudy),
934       myView(theView), 
935       myPrsObj(thePrsObj), 
936       myDisplaing(theDisplaing)
937     {}
938     virtual void Execute(){
939       // is it Curve ?
940       if(Curve_i* aCurve =  dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
941         UpdatePlot2d(myView,myDisplaing,aCurve);
942       }
943       // is it Container ?
944       if(Container_i* aContainer =  dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
945         int nbCurves = aContainer->GetNbCurves();
946         for ( int i = 1; i <= nbCurves; i++ ) {
947           VISU::Curve_i* aCurve = aContainer->GetCurve( i );
948           if ( aCurve && aCurve->IsValid() ) {
949             UpdatePlot2d(myView,myDisplaing,aCurve);
950           }
951         }
952         myView->Repaint();
953       }
954       // is it Table ?
955       if(Table_i* aTable =  dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
956         SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
957         SALOMEDS::SObject_var TableSO = aStudy->FindObjectID( aTable->GetEntry() );
958         if ( !TableSO->_is_nil() ) {
959           SALOMEDS::ChildIterator_var Iter = aStudy->NewChildIterator( TableSO );
960           for ( ; Iter->More(); Iter->Next() ) {
961             CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
962             if( !CORBA::is_nil( childObject ) ) {
963               CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
964               if( !CORBA::is_nil( aCurve ) )
965                 UpdatePlot2d(myView,myDisplaing,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
966             }
967           }
968           myView->Repaint();
969         }
970       }
971     }
972   };
973
974
975   void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
976     ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplay));
977   }
978
979
980   void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
981     ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eErase));
982   }
983
984
985   void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
986     ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplayOnly));
987   }
988
989
990   void XYPlot_i::EraseAll() {
991     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::EraseAll));
992   }
993
994
995   void XYPlot_i::FitAll() {
996     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::fitAll));
997   }
998
999
1000   CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
1001     return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(),theFileName));
1002   }
1003
1004
1005   //===========================================================================
1006   TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
1007   Storable* TableView_i::Create(VISU::Table_ptr theTable){
1008     if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
1009     if(!theTable->_is_nil()){
1010       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1011       if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
1012       if(table != NULL) {
1013         SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
1014         if(!aSObject->_is_nil()) {
1015           myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
1016                                           aSObject,
1017                                           false, 
1018                                           SALOMEGUI_TableDlg::ttAuto, 
1019                                           Qt::Vertical);
1020           myView->show();
1021           return this;
1022         }
1023       }
1024     }
1025     return NULL;
1026   }
1027
1028
1029   TableView_i::~TableView_i() {
1030     if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1031     delete myView;
1032   }
1033
1034
1035   void TableView_i::SetTitle(const char* theTitle){
1036     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SALOMEGUI_TableDlg,const QString&,QString>
1037                      (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle)));
1038   }
1039
1040
1041   char* TableView_i::GetTitle() {
1042     return CORBA::string_dup(myView->caption().latin1());
1043   }
1044
1045
1046   void TableView_i::Close(){
1047     myView->close();
1048   }
1049
1050
1051   //===========================================================================
1052   int View3D_i::myNbViewParams = 0;
1053   const string View3D_i::myComment = "VIEW3D";
1054   const char* View3D_i::GetComment() const { return myComment.c_str();}
1055   QString View3D_i::GenerateViewParamsName() { 
1056     return VISU::GenerateName( "ViewParams", ++myNbViewParams ); 
1057   }
1058
1059   View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
1060     if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
1061   }
1062
1063   Storable* View3D_i::Create(int theNew){
1064     if(MYDEBUG) MESSAGE("View3D_i::Create");
1065     if(theNew)
1066       myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
1067     else
1068       myStudyFrame = myStudy->getActiveStudyFrame();
1069     return this;
1070   }
1071
1072
1073   void View3D_i::Update(){
1074     class TEvent: public SALOME_Event{
1075       QAD_StudyFrame* myStudyFrame;
1076     public:
1077       TEvent(QAD_StudyFrame* theStudyFrame):
1078         myStudyFrame(theStudyFrame)
1079       {}
1080       virtual void Execute(){
1081         VTKViewer_ViewFrame* vf =  GetViewFrame(myStudyFrame);
1082         vtkRenderer* Renderer = vf->getRenderer();
1083         vtkActorCollection* theActors = Renderer->GetActors();
1084         theActors->InitTraversal();
1085         while(vtkActor *anAct = theActors->GetNextActor()){
1086           if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
1087             VISU::Prs3d_i* aPrs3d  = anActor->GetPrs3d();
1088             if(anActor->GetVisibility() && aPrs3d){
1089               aPrs3d->Update();
1090               aPrs3d->UpdateActor(anActor);
1091             }
1092           }
1093         }
1094         RepaintView(myStudyFrame);
1095       }
1096     };
1097     ProcessVoidEvent(new TEvent(myStudyFrame));
1098   }
1099
1100
1101   CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
1102     return ProcessEvent(new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName));
1103   }
1104
1105
1106   bool View3D_i::SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
1107     QAD_Study* aStudy = theStudyFrame->getStudy();
1108     SALOMEDS::Study_var aStudyDoc = aStudy->getStudyDocument();
1109     if ( theName ) {
1110       SALOMEDS::Study::ListOfSObject_var aList = 
1111         aStudyDoc->FindObjectByName(theName,"VISU");
1112       SALOMEDS::GenericAttribute_var anAttr;
1113       int iEnd = aList->length();
1114       for(int i = 0; i < iEnd; i++){
1115         SALOMEDS::SObject_var anObj = aList[i];
1116         CORBA::String_var aString = anObj->GetID();
1117         string anEntry(aString);
1118         if(MYDEBUG)  MESSAGE("View3D_i::SaveViewParams - anEntry = "<<anEntry);
1119         if(anObj->FindAttribute(anAttr, "AttributeComment")){
1120           SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1121           aString = aCmnt->Value();
1122           string aComm(aString);
1123           if(MYDEBUG)  MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
1124           if(aComm.compare(View3D_i::myComment) >= 0){
1125             aCmnt->SetValue(ToString(theStudyFrame).c_str());
1126             return true;
1127           }
1128         }
1129       }
1130     }
1131     SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(aStudyDoc);
1132     CORBA::String_var aSComponentEntry = aSComponent->GetID();
1133     string anEntry = CreateAttributes(aStudyDoc,aSComponentEntry.in(),"","",theName,"",ToString(theStudyFrame).c_str());
1134     return true;
1135   }
1136   CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
1137     return SaveViewParams(myStudyFrame,theName);
1138   }
1139
1140
1141   bool View3D_i::RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
1142     SALOMEDS::Study::ListOfSObject_var aList = 
1143       theStudyFrame->getStudy()->getStudyDocument()->FindObjectByName(theName,"VISU");
1144     SALOMEDS::GenericAttribute_var anAttr;
1145     int iEnd = aList->length();
1146     if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
1147     for(int i = 0; i < iEnd; i++){
1148       SALOMEDS::SObject_var anObj = aList[i];
1149       CORBA::String_var aString = anObj->GetID();
1150       string anEntry(aString);
1151       if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
1152       if(anObj->FindAttribute(anAttr, "AttributeComment")){
1153         SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1154         aString = aCmnt->Value();
1155         QString strIn(aString);
1156         Storable::TRestoringMap aMap;
1157         Storable::StrToMap(strIn,aMap);
1158         if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
1159           if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
1160           Restore(theStudyFrame,aMap);
1161           return true;
1162         }
1163       }
1164     }
1165     return false;
1166   }
1167
1168
1169   class TRestoreViewParamsEvent: public SALOME_Event{
1170     QAD_StudyFrame* myStudyFrame;
1171     const char* myName;
1172   public:
1173     TRestoreViewParamsEvent(QAD_StudyFrame* theStudyFrame,
1174                             const char* theName):
1175       myStudyFrame(theStudyFrame),
1176       myName(theName)
1177     {}
1178     virtual void Execute(){
1179       myResult = View3D_i::RestoreViewParams(myStudyFrame,myName);
1180     }
1181     typedef CORBA::Boolean TResult;
1182     TResult myResult;
1183   };
1184
1185   CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
1186     return ProcessEvent(new TRestoreViewParamsEvent(myStudyFrame,theName));
1187   }
1188
1189
1190   void View3D_i::Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap){
1191     SALOMEDS::Color aColor;  
1192     aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1193     aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1194     aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1195     
1196     double aPosition[3];
1197     aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1198     aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1199     aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1200     
1201     double aFocalPnt[3];
1202     aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1203     aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1204     aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1205     
1206     double aViewUp[3];
1207     aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1208     aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1209     aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1210     
1211     double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1212      
1213     double aScaleFactor[3];
1214     aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1215     aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1216     aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1217     
1218     SetBackground(theStudyFrame,aColor);
1219     SetPointOfView(theStudyFrame,aPosition);
1220     SetViewUp(theStudyFrame,aViewUp);
1221     SetFocalPoint(theStudyFrame,aFocalPnt);
1222     SetParallelScale(theStudyFrame,aParallelScale);
1223     ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1224     ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1225     ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1226   }
1227     
1228
1229   string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){
1230     ostringstream strOut;
1231     Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1232     ToStream(theStudyFrame,strOut);
1233     strOut<<ends;
1234     if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1235     return strOut.str(); 
1236   }
1237   void View3D_i::ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr) {
1238     Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1239     
1240     float backint[3];  
1241     GetRenderer(theStudyFrame)->GetBackground(backint);
1242     Storable::DataToStream(theStr,"myColor.R",backint[0]);
1243     Storable::DataToStream(theStr,"myColor.G",backint[1]);
1244     Storable::DataToStream(theStr,"myColor.B",backint[2]);
1245     
1246     double aPosition[3];
1247     GetPointOfView(theStudyFrame,aPosition);
1248     Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1249     Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1250     Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1251     
1252     double aFocalPnt[3];
1253     GetFocalPoint(theStudyFrame,aFocalPnt);
1254     Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1255     Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1256     Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1257     
1258     double aViewUp[3];
1259     GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1260     Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1261     Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1262     Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1263     
1264     Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1265     
1266     double aScaleFactor[3];
1267     GetViewFrame(theStudyFrame)->GetScale(aScaleFactor);
1268     Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1269     Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1270     Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1271   }
1272   void View3D_i::ToStream(std::ostringstream& theStr) {
1273     ToStream(myStudyFrame,theStr);
1274   }
1275
1276
1277   void View3D_i::Close(){
1278     myStudyFrame->close();
1279   }
1280
1281   View3D_i::~View3D_i() {
1282     if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1283   }
1284
1285   //-------------------- View interface --------------------
1286
1287   void View_i::ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state  ) {
1288     ProcessVoidEvent( new TSetViewRepresentation( this, ViewRepr, state ) );
1289     Update();
1290   }
1291
1292   CORBA::Boolean View_i::IsPartShown( VISU::View::ViewRepresentation Part )
1293   {
1294     return ProcessEvent( new TGetViewRepresentation( this, Part ) );
1295   }
1296
1297   void View_i::SetViewWidth(CORBA::Long Width){
1298     ProcessVoidEvent( new TSetViewWidthHeight( this, Width, true ) );
1299      }
1300   
1301   void View_i::SetViewHeight(CORBA::Long Height){ 
1302     ProcessVoidEvent( new TSetViewWidthHeight( this, Height, false ) );
1303      }
1304
1305   CORBA::Long View_i::GetViewWidth() 
1306   {
1307     return ProcessEvent( new TGetViewWidthHeight( this, true ) );
1308   }
1309
1310   CORBA::Long View_i::GetViewHeight()
1311   {
1312     return ProcessEvent( new TGetViewWidthHeight( this, false ) );
1313   }
1314
1315   void View_i::SetViewPositionHorizontal( VISU::View::ViewPosition ViewPosHor ){
1316     ProcessVoidEvent( new TSetViewPositionHorizontal( this, ViewPosHor ) );
1317   }
1318
1319   void View_i::SetViewPositionVertical( VISU::View::ViewPosition ViewPosVer ){
1320     ProcessVoidEvent( new TSetViewPositionVertical( this, ViewPosVer ) );
1321   }
1322
1323   void View_i::SetRelativePosition( CORBA::Double x, CORBA::Double y )
1324   {
1325     ProcessVoidEvent( new TSetRelativePosition( this, x, y ) );
1326   }
1327
1328   void View_i::SetRelativeSize( CORBA::Double x, CORBA::Double y )
1329   {
1330     ProcessVoidEvent( new TSetRelativeSize( this, x, y ) );
1331   }
1332
1333
1334
1335
1336   void View3D_i::SetTitle(const char* theTitle){
1337     ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
1338                      (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle)));
1339   }
1340   char* View3D_i::GetTitle() {
1341     return CORBA::string_dup(myStudyFrame->title().latin1());
1342   }
1343
1344
1345   void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
1346     int aColor[3];
1347     aColor[0] = int(255.0*theColor.R);
1348     aColor[1] = int(255.0*theColor.G);
1349     aColor[2] = int(255.0*theColor.B);
1350     QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1351     GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
1352   }
1353   void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
1354     ProcessVoidEvent(new TSetBackgroundEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),theColor));
1355   }
1356
1357
1358   SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) { 
1359     SALOMEDS::Color aColor;
1360     float backint[3];  
1361     GetRenderer(theStudyFrame)->GetBackground(backint);
1362     aColor.R = backint[0];  aColor.G = backint[1];  aColor.B = backint[2];
1363     return aColor;
1364   }
1365   SALOMEDS::Color View3D_i::GetBackground() { 
1366     return GetBackground(myStudyFrame);
1367   }
1368
1369
1370   void View3D_i::Minimize() {
1371     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
1372   }
1373   void View3D_i::Restore() {
1374     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
1375   }
1376   void View3D_i::Maximize() {
1377     ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
1378   }
1379
1380
1381   //===========================================================================
1382   class TUpdateViewerEvent: public SALOME_Event{
1383     QAD_StudyFrame* myStudyFrame;
1384     Prs3d_i* myPrs3d;
1385     int myDisplaing;
1386   public:
1387     TUpdateViewerEvent(QAD_StudyFrame* theStudyFrame,
1388                        Prs3d_i* thePrs3d,
1389                        int theDisplaing):
1390       myStudyFrame(theStudyFrame),
1391       myPrs3d(thePrs3d),
1392       myDisplaing(theDisplaing)
1393     {}
1394     virtual void Execute(){
1395       UpdateViewer(myStudyFrame,myDisplaing,myPrs3d);
1396     }
1397   };
1398
1399   void View3D_i::EraseAll() {
1400     if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1401     ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eEraseAll));
1402   }
1403
1404   void View3D_i::DisplayAll() {
1405     if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1406     ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eDisplayAll));
1407   }
1408
1409   void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1410     if(MYDEBUG) MESSAGE("View3D_i::Erase");
1411     CORBA::Object_ptr anObj = thePrsObj;
1412     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1413       ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eErase));
1414     }
1415   }
1416
1417   void View3D_i::Display(PrsObject_ptr thePrsObj) {
1418     if(MYDEBUG) MESSAGE("View3D_i::Display"); 
1419     CORBA::Object_ptr anObj = thePrsObj;
1420     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1421       ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplay));
1422     }
1423   }
1424
1425   void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1426     if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1427     CORBA::Object_ptr anObj = thePrsObj;
1428     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1429       ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplayOnly));
1430     }
1431   }
1432
1433   //-------------------- View3D interface --------------------
1434   void View3D_i::FitAll() { 
1435     ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll));
1436     Update();
1437   }
1438
1439
1440   void View3D_i::SetView(VISU::View3D::ViewType theType) {
1441     switch(theType){
1442     case VISU::View3D::FRONT : 
1443       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront));
1444       break;
1445     case VISU::View3D::BACK : 
1446       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
1447       break;
1448     case VISU::View3D::LEFT : 
1449       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
1450       break;
1451     case VISU::View3D::RIGHT : 
1452       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
1453       break;
1454     case VISU::View3D::TOP : 
1455       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
1456       break;
1457     case VISU::View3D::BOTTOM : 
1458       ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
1459       break;
1460     }
1461     Update();
1462   }
1463
1464
1465   class TSet3DViewParamEvent: public SALOME_Event{
1466   public:
1467     typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, const CORBA::Double theParam[3]);
1468     TSet3DViewParamEvent(TFun theFun,
1469                          QAD_StudyFrame* theStudyFrame,
1470                          const CORBA::Double theParam[3]):
1471       myFun(theFun),
1472       myStudyFrame(theStudyFrame),
1473       myParam(theParam)
1474     {}
1475     virtual void Execute(){
1476       myFun(myStudyFrame,myParam);
1477     }
1478   private:
1479     TFun myFun;
1480     QAD_StudyFrame* myStudyFrame;
1481     const CORBA::Double* myParam;
1482   };
1483
1484
1485   void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1486     GetCamera(theStudyFrame)->SetPosition(thePosition);
1487   }
1488   void View3D_i::SetPointOfView(const VISU::View3D::XYZ thePosition) {
1489     if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1490     ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myStudyFrame,thePosition));
1491   }
1492
1493
1494   void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) { 
1495     GetCamera(theStudyFrame)->GetPosition(thePosition);
1496   }
1497   VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { 
1498     if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1499     CORBA::Double aPosition[3];
1500     GetPointOfView(myStudyFrame,aPosition);
1501     return VISU::View3D::XYZ_dup(aPosition);
1502   }
1503
1504
1505   void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1506     GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1507   }
1508   void View3D_i::SetViewUp(const VISU::View3D::XYZ theViewUp) {
1509     if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1510     ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myStudyFrame,theViewUp));
1511   }
1512
1513
1514   void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) { 
1515     GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1516   }
1517   VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { 
1518     if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1519     CORBA::Double aViewUp[3];
1520     GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1521     return VISU::View3D::XYZ_dup(aViewUp);
1522   }
1523
1524
1525   void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1526     GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1527   }
1528   void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1529     if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1530     ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myStudyFrame,theCoord));
1531   }
1532
1533
1534   void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) { 
1535     GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1536   }
1537   VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { 
1538     if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1539     CORBA::Double aFocalPnt[3];
1540     GetFocalPoint(myStudyFrame,aFocalPnt);
1541     return VISU::View3D::XYZ_dup(aFocalPnt);
1542   }
1543
1544
1545   class TSetViewParamEvent: public SALOME_Event{
1546   public:
1547     typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, CORBA::Double theParam);
1548     TSetViewParamEvent(TFun theFun,
1549                        QAD_StudyFrame* theStudyFrame,
1550                        CORBA::Double theParam):
1551       myFun(theFun),
1552       myStudyFrame(theStudyFrame),
1553       myParam(theParam)
1554     {}
1555     virtual void Execute(){
1556       myFun(myStudyFrame,myParam);
1557     }
1558   private:
1559     TFun myFun;
1560     QAD_StudyFrame* myStudyFrame;
1561     CORBA::Double myParam;
1562   };
1563
1564
1565   void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1566     GetCamera(theStudyFrame)->SetParallelScale(theScale);
1567   }
1568   void View3D_i::SetParallelScale(CORBA::Double theScale) {
1569     if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1570     ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myStudyFrame,theScale));
1571   }
1572
1573
1574   CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) { 
1575     return GetCamera(theStudyFrame)->GetParallelScale();
1576   }
1577   CORBA::Double View3D_i::GetParallelScale() { 
1578     if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1579     return GetParallelScale(myStudyFrame);
1580   }
1581
1582   void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1583     VTKViewer_ViewFrame* aViewFrame =  GetViewFrame(theStudyFrame);
1584     double aScaleFactor[3];
1585     aViewFrame->GetScale(aScaleFactor);
1586     aScaleFactor[theAxis] = theParam;
1587     aViewFrame->SetScale(aScaleFactor);
1588   }
1589   
1590   void SetScaleView(QAD_StudyFrame* theStudyFrame, const CORBA::Double theScale[3]){
1591     double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1592     GetViewFrame(theStudyFrame)->SetScale(aScale);
1593   }
1594   void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1595     if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1596     double aScale[3];
1597     GetViewFrame(myStudyFrame)->GetScale(aScale);
1598     aScale[theAxis] = theParam;
1599     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1600   }
1601   void View3D_i::RemoveScale() {
1602     if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1603     double aScale[3] = {1.0, 1.0, 1.0};
1604     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1605   }
1606   //===========================================================================
1607
1608
1609   VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){
1610     vtkActor *anActor;
1611     vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
1612     anActColl->InitTraversal();
1613     while(vtkActor *anActor = anActColl->GetNextActor())
1614       if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
1615         if(thePrs3d == anVISUActor->GetPrs3d())
1616           return anVISUActor->GetParent();
1617     return NULL;
1618   }
1619
1620
1621   void DeletePrs3d(Prs3d_ptr thePrs3d){
1622     if(Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in())){
1623       SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
1624       SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
1625       if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){
1626         if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)){
1627           aStudy->unHighlightAll();
1628           int aNbStudyFrames = aStudy->getStudyFramesCount();
1629           for(int aFrameId = 0; aFrameId < aNbStudyFrames; aFrameId++){
1630             if(QAD_StudyFrame* aFrame = aStudy->getStudyFrame(aFrameId)){
1631               QAD_ViewFrame* aViewFrame = aFrame->getRightFrame()->getViewFrame();
1632               if(VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame)){
1633                 if(VISU_Actor* anActor = VISU::GetActor(aPrs3d,aVTKFrame)){
1634                   aVTKFrame->RemoveActor(anActor);
1635                   anActor->Delete();
1636                 }
1637                 aVTKFrame->unHighlightAll();
1638               }
1639             }
1640           }
1641
1642           aPrs3d->RemoveFromStudy(); 
1643           aPrs3d->Destroy(); 
1644
1645           aStudy->updateObjBrowser(); //update Object browser
1646         }
1647       }
1648     }
1649   }
1650
1651
1652   void VISU_Gen_i::DeleteResult(Result_ptr theResult)
1653   {
1654     class TEvent: public SALOME_Event{
1655       Result_ptr myResult;
1656     public:
1657       TEvent(Result_ptr theResult): myResult(theResult) {}
1658       virtual void Execute(){
1659         if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())){
1660           SALOMEDS::SObject_var aSObject = aResult->GetSObject();
1661           SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
1662           SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject);
1663           for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1664             SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1665             CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1666             if(CORBA::is_nil(aChildObj)) continue;
1667             VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1668             if(CORBA::is_nil(aPrs3d)) continue;
1669             VISU::DeletePrs3d(aPrs3d);
1670           }
1671
1672           aResult->RemoveFromStudy(); 
1673           aResult->Destroy(); 
1674
1675           if(QAD_Desktop* aDesktop = QAD_Application::getDesktop())
1676             if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
1677               aStudy->updateObjBrowser(); //update Object browser
1678         }
1679       }
1680     };
1681
1682     ProcessVoidEvent(new TEvent(theResult));
1683   }
1684
1685
1686   void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d)
1687   {
1688     class TEvent: public SALOME_Event{
1689       Prs3d_ptr myPrs3d;
1690     public:
1691       TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
1692       virtual void Execute(){
1693         VISU::DeletePrs3d(myPrs3d);
1694       }
1695     };
1696
1697     ProcessVoidEvent(new TEvent(thePrs3d));
1698   }
1699
1700 }