Salome HOME
89ebe9d23e1db20499d70ae7e18d137f0c1f4919
[modules/visu.git] / src / VISU_I / VISU_View_i.cc
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU OBJECT : interactive object for VISU entities implementation
23 //  File   : VISU_View_i.cc
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //
27 #include "VISU_View_i.hh"
28
29 #include "VISU_Gen_i.hh"
30 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Table_i.hh"
32 #include "VISU_PointMap3d_i.hh"
33 #include "VISU_ScalarMap_i.hh"
34 #include "VISU_ViewManager_i.hh"
35
36 #include "VisuGUI_TableDlg.h"
37
38 #include "VISU_Actor.h"
39 #include "VISU_ScalarMapAct.h"
40 #include "VISU_PointMap3dActor.h"
41 #include "VISU_DeformedGridPL.hxx"
42
43 #include "SALOME_Event.h"
44
45 #include "SUIT_ViewWindow.h"
46 #include "SUIT_ViewManager.h"
47 #include "SUIT_Tools.h"
48
49 #include "STD_MDIDesktop.h"
50 #include "STD_TabDesktop.h"
51
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_ViewModel.h"
54 #include "VTKViewer_Algorithm.h"
55
56 #include "SPlot2d_ViewModel.h"
57 #include "Plot2d_ViewFrame.h"
58
59 #include "SalomeApp_Application.h"
60 #include "SalomeApp_Study.h"
61
62 #include <QtxWorkstack.h>
63 #include <QtxWorkspace.h>
64
65 #include <QWorkspace>
66 #include <QImage>
67
68 #include <vtkCamera.h>
69 #include <vtkRenderer.h>
70 #include <vtkActor.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 namespace VISU {
81
82   typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
83
84   struct TNewViewEvent: public SALOME_Event
85   {
86     SalomeApp_Application* myApplication;
87     typedef QWidget* TResult;
88     TResult myResult;
89
90     TNewViewEvent (SalomeApp_Application* theApplication):
91       myApplication(theApplication),
92       myResult(NULL)
93     {}
94
95     virtual
96     void
97     Execute()
98     {
99       if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
100         myResult = aDesktop->workspace();
101       }
102     }
103   };
104
105   View_i::
106   View_i (SalomeApp_Application *theApplication,
107           SUIT_ViewManager* theViewManager):
108     myApplication(theApplication),
109     myWorkspace(NULL),
110     myViewManager(theViewManager)
111   {
112     if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
113     myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
114   }
115
116   View_i::
117   ~View_i()
118   {
119     if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
120   }
121
122
123   struct TApplicationEvent: public SALOME_Event
124   {
125     SalomeApp_Application* myApplication;
126
127     TApplicationEvent(SalomeApp_Application* theApplication):
128       myApplication(theApplication)
129     {}
130   };
131
132   void
133   View_i::
134   ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
135             CORBA::Boolean theState)
136   {
137     struct TEvent: public TApplicationEvent
138     {
139       VISU::View::ViewRepresentation myViewRepresentation;
140       CORBA::Boolean myState;
141
142       TEvent(SalomeApp_Application* theApplication,
143              VISU::View::ViewRepresentation theViewRepresentation,
144              CORBA::Boolean theState):
145         TApplicationEvent(theApplication),
146         myViewRepresentation(theViewRepresentation),
147         myState(theState)
148       {}
149
150       virtual
151       void
152       Execute()
153       {
154         switch(myViewRepresentation){
155         case VISU::View::OBJECTBROWSER:
156           myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState );
157           break;
158         case VISU::View::PYTHON:
159           myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState );
160           break;
161         case VISU::View::MESSAGES:
162           myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState );
163           break;
164         case VISU::View::VIEWER:
165         {
166           ViewManagerList mgrs = myApplication->viewManagers();
167           ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end();
168           for( ; anIt!=aLast; anIt++ )
169           {
170             const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
171             for( int i=0; i<views.count(); i++ )
172               views[i]->setShown( myState );
173           }
174           break;
175         }}
176       }
177     };
178
179     ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
180   }
181
182   struct TPartShownEvent: public TApplicationEvent
183   {
184     VISU::View::ViewRepresentation myViewRepresentation;
185     typedef bool TResult;
186     TResult myResult;
187
188     TPartShownEvent(SalomeApp_Application* theApplication,
189                     VISU::View::ViewRepresentation theViewRepresentation):
190       TApplicationEvent(theApplication),
191       myViewRepresentation(theViewRepresentation),
192       myResult(false)
193     {}
194
195     virtual
196     void
197     Execute()
198     {
199       switch(myViewRepresentation){
200       case VISU::View::OBJECTBROWSER:
201         myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible();
202         break;
203       case VISU::View::PYTHON:
204         myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible();
205         break;
206       case VISU::View::MESSAGES:
207         myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible();
208         break;
209       case VISU::View::VIEWER:{
210         ViewManagerList aViewManagerList = myApplication->viewManagers();
211         ViewManagerList::const_iterator anIt = aViewManagerList.begin();
212         for( ; anIt != aViewManagerList.end(); anIt++ )
213         {
214           const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
215           for( int i=0; i<views.count(); i++ ) {
216             myResult = views[i]->isVisible();
217             return;
218           }
219         }
220         myResult = false;
221         break;
222       }}
223     }
224   };
225
226   CORBA::Boolean
227   View_i::
228   IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
229   {
230     return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
231   }
232
233   // Begin: New methods for view parameters management
234   struct TSplitEvent: public SALOME_Event
235   {
236     SalomeApp_Application * myApplication;
237     SUIT_ViewWindow       * myVW;
238     Qt::Orientation         myOrientation;
239     QtxWorkstack::SplitType mySplitType;
240
241   public:
242     TSplitEvent (SalomeApp_Application * theApplication,
243                  SUIT_ViewWindow       * theViewWindow,
244                  Qt::Orientation         theOrientation,
245                  QtxWorkstack::SplitType theSplitType):
246       myApplication(theApplication),
247       myVW(theViewWindow),
248       myOrientation(theOrientation),
249       mySplitType(theSplitType)
250     {}
251
252     virtual void Execute()
253     {
254       SUIT_Desktop* desk = myApplication->desktop();
255       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
256       if (tabDesk) {
257         QtxWorkstack* workstack = tabDesk->workstack();
258         if (workstack) {
259           workstack->Split(myVW, myOrientation, mySplitType);
260         }
261       }
262     }
263   };
264
265   void
266   View_i::
267   SplitRight()
268   {
269     SUIT_ViewWindow* aVW = GetViewWindow();
270     if (aVW)
271       ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
272                                        Qt::Horizontal, QtxWorkstack::SplitMove));
273   }
274
275   void
276   View_i::
277   SplitLeft()
278   {
279     SUIT_ViewWindow* aVW = GetViewWindow();
280     if (aVW)
281       ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
282                                        Qt::Horizontal, QtxWorkstack::SplitStay));
283   }
284
285   void
286   View_i::
287   SplitBottom()
288   {
289     SUIT_ViewWindow* aVW = GetViewWindow();
290     if (aVW)
291       ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
292                                        Qt::Vertical, QtxWorkstack::SplitMove));
293   }
294
295   void
296   View_i::
297   SplitTop()
298   {
299     SUIT_ViewWindow* aVW = GetViewWindow();
300     if (aVW)
301       ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
302                                        Qt::Vertical, QtxWorkstack::SplitStay));
303   }
304
305   void
306   View_i::
307   OnTop()
308   {
309     struct TOnTopEvent: public SALOME_Event
310     {
311       SUIT_ViewWindow * myVW;
312
313     public:
314       TOnTopEvent (SUIT_ViewWindow * theViewWindow):
315         myVW(theViewWindow)
316       {}
317
318       virtual void Execute()
319       {
320         if (myVW) {
321           myVW->setFocus();
322         }
323       }
324     };
325
326     SUIT_ViewWindow* aVW = GetViewWindow();
327     if (aVW)
328       ProcessVoidEvent(new TOnTopEvent(aVW));
329   }
330
331   struct TAttractEvent: public SALOME_Event
332   {
333     SalomeApp_Application * myApplication;
334     SUIT_ViewWindow       * myVW1;
335     SUIT_ViewWindow       * myVW2;
336     bool                    myAttractAll;
337
338   public:
339     TAttractEvent (SalomeApp_Application * theApplication,
340                    SUIT_ViewWindow       * theViewWindow1,
341                    SUIT_ViewWindow       * theViewWindow2,
342                    bool                    theAttractAll):
343       myApplication(theApplication),
344       myVW1(theViewWindow1),
345       myVW2(theViewWindow2),
346       myAttractAll(theAttractAll)
347     {}
348
349     virtual void Execute()
350     {
351       SUIT_Desktop* desk = myApplication->desktop();
352       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
353       if (tabDesk) {
354         QtxWorkstack* workstack = tabDesk->workstack();
355         if (workstack) {
356           workstack->Attract(myVW1, myVW2, myAttractAll);
357         }
358       }
359     }
360   };
361
362   void
363   View_i::
364   Attract (VISU::View_ptr theView)
365   {
366     if (!CORBA::is_nil(theView)) {
367       if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
368         if (pView) {
369           SUIT_ViewWindow* aVW1 = GetViewWindow();
370           SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
371           if (aVW1 && aVW2)
372             ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, false));
373         }
374       }
375     }
376   }
377
378   void
379   View_i::
380   AttractAll (VISU::View_ptr theView)
381   {
382     if (!CORBA::is_nil(theView)) {
383       if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
384         if (pView) {
385           SUIT_ViewWindow* aVW1 = GetViewWindow();
386           SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
387           if (aVW1 && aVW2)
388             ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, true));
389         }
390       }
391     }
392   }
393
394   struct TSizePositionEvent: public SALOME_Event
395   {
396     SalomeApp_Application * myApplication;
397     SUIT_ViewWindow       * myVW;
398     double                  myValue;
399     bool                    myIsSize;
400
401   public:
402     TSizePositionEvent (SalomeApp_Application * theApplication,
403                         SUIT_ViewWindow       * theViewWindow,
404                         double                  theValue,
405                         bool                    theIsSize):
406       myApplication(theApplication),
407       myVW(theViewWindow),
408       myValue(theValue),
409       myIsSize(theIsSize)
410     {}
411
412     virtual void Execute()
413     {
414       MESSAGE("TSizePositionEvent::Execute()");
415       SUIT_Desktop* desk = myApplication->desktop();
416       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
417       if (tabDesk) {
418         QtxWorkstack* workstack = tabDesk->workstack();
419         if (workstack) {
420           if (myIsSize) {
421             //jfa to do:workstack->SetRelativeSizeInSplitter(myVW, myValue);
422           } else {
423             workstack->SetRelativePositionInSplitter(myVW, myValue);
424           }
425         }
426       }
427     }
428   };
429
430   void
431   View_i::
432   SetRelativePositionInSplitter (CORBA::Double thePosition)
433   {
434     if (thePosition < 0.0 || 1.0 < thePosition) {
435       return;
436     }
437     SUIT_ViewWindow* aVW = GetViewWindow();
438     if (aVW)
439       ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, thePosition, false));
440   }
441
442   void
443   View_i::
444   SetRelativeSizeInSplitter (CORBA::Double theSize)
445   {
446     if (theSize < 0.0 || 1.0 < theSize) {
447       return;
448     }
449     SUIT_ViewWindow* aVW = GetViewWindow();
450     if (aVW)
451       ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, theSize, true));
452   }
453
454   struct TWSSizePositionEvent: public SALOME_Event
455   {
456     SalomeApp_Application * myApplication;
457     SUIT_ViewWindow       * myVW;
458     Qt::Orientation         myOrientation;
459     double                  myValue;
460     bool                    myIsSize;
461
462   public:
463     TWSSizePositionEvent (SalomeApp_Application * theApplication,
464                           SUIT_ViewWindow       * theViewWindow,
465                           Qt::Orientation         theOrientation,
466                           double                  theValue,
467                           bool                    theIsSize):
468       myApplication(theApplication),
469       myVW(theViewWindow),
470       myOrientation(theOrientation),
471       myValue(theValue),
472       myIsSize(theIsSize)
473     {}
474
475     virtual void Execute()
476     {
477       MESSAGE("TWSSizePositionEvent::Execute()");
478       SUIT_Desktop* desk = myApplication->desktop();
479       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
480       if (tabDesk) {
481         QtxWorkstack* workstack = tabDesk->workstack();
482         if (workstack) {
483           if (myIsSize) {
484             //jfa to do:workstack->SetRelativeSize(myVW, myOrientation, myValue);
485           } else {
486             workstack->SetRelativePosition(myVW, myOrientation, myValue);
487           }
488         }
489       }
490     }
491   };
492
493   void
494   View_i::
495   SetRelativePositionX (CORBA::Double thePosition)
496   {
497     if (thePosition < 0.0 || 1.0 < thePosition) {
498       return;
499     }
500     SUIT_ViewWindow* aVW = GetViewWindow();
501     if (aVW)
502       ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
503                                                 Qt::Horizontal, thePosition, false));
504   }
505
506   void
507   View_i::
508   SetRelativePositionY (CORBA::Double thePosition)
509   {
510     if (thePosition < 0.0 || 1.0 < thePosition) {
511       return;
512     }
513     SUIT_ViewWindow* aVW = GetViewWindow();
514     if (aVW)
515       ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
516                                                 Qt::Vertical, thePosition, false));
517   }
518
519   void
520   View_i::
521   SetRelativeSizeX (CORBA::Double theSize)
522   {
523     if (theSize < 0.0 || 1.0 < theSize) {
524       return;
525     }
526     SUIT_ViewWindow* aVW = GetViewWindow();
527     if (aVW)
528       ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
529                                                 Qt::Horizontal, theSize, true));
530   }
531
532   void
533   View_i::
534   SetRelativeSizeY (CORBA::Double theSize)
535   {
536     if (theSize < 0.0 || 1.0 < theSize) {
537       return;
538     }
539     SUIT_ViewWindow* aVW = GetViewWindow();
540     if (aVW)
541       ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
542                                                 Qt::Vertical, theSize, true));
543   }
544   // End: New methods for view parameters management
545
546   // Begin: Old methods for view parameters management, they don't work now
547   struct TSetViewSize: public SALOME_Event
548   {
549     SUIT_ViewWindow* myVW;
550     typedef void (QRect::* TAction)(int);
551     TAction myAction;
552     CORBA::Long mySize;
553
554   public:
555     TSetViewSize(SUIT_ViewWindow* theViewWindow,
556                  TAction theAction,
557                  CORBA::Long theSize):
558       myVW(theViewWindow),
559       myAction(theAction),
560       mySize(theSize)
561     {}
562
563     virtual
564     void
565     Execute()
566     {
567       if (QWidget* aParent = myVW->parentWidget()) {
568         QRect aQRect = aParent->frameGeometry();
569         (aQRect.*myAction)(mySize);
570         aParent->setGeometry(aQRect);
571       }
572     }
573   };
574
575   void
576   View_i::
577   SetViewWidth(CORBA::Long theWidth)
578   {
579     ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
580   }
581
582   void
583   View_i::
584   SetViewHeight(CORBA::Long theHeight)
585   {
586     ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
587   }
588
589
590   struct TGetViewSize: public SALOME_Event
591   {
592     SUIT_ViewWindow* myVW;
593
594     typedef int (QRect::* TAction)() const;
595     TAction myAction;
596
597     typedef CORBA::Long TResult;
598     TResult myResult;
599
600   public:
601     TGetViewSize(SUIT_ViewWindow* theViewWindow,
602                  TAction theAction):
603       myVW(theViewWindow),
604       myAction(theAction)
605     {}
606
607     virtual
608     void
609     Execute()
610     {
611       if(QWidget* aParent = myVW->parentWidget()){
612         QRect aQRect = aParent->frameGeometry();
613         myResult = (aQRect.*myAction)();
614       }
615     }
616   };
617
618
619   CORBA::Long
620   View_i::
621   GetViewWidth()
622   {
623     return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
624   }
625
626   CORBA::Long
627   View_i::
628   GetViewHeight()
629   {
630     return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
631   }
632
633
634   class TWorkspaceEvent: public SALOME_Event
635   {
636   protected:
637     QWidget* myVW;
638     QWidget* myWorkspace;
639
640   public:
641     TWorkspaceEvent(QWidget* theViewWindow,
642                     QWidget* theWorkspace):
643       myVW(theViewWindow),
644       myWorkspace(theWorkspace)
645     {}
646   };
647
648
649   class TAlignEvent: public TWorkspaceEvent
650   {
651   protected:
652     Qt::AlignmentFlag myAligment;
653
654   public:
655     TAlignEvent(QWidget* theViewWindow,
656                 QWidget* theWorkspace,
657                 Qt::AlignmentFlag theAligment):
658       TWorkspaceEvent(theViewWindow,theWorkspace),
659       myAligment(theAligment)
660     {}
661
662     virtual
663     void
664     Execute()
665     {
666       if(QWidget* aParent = myVW->parentWidget())
667         SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
668     }
669   };
670
671
672   void
673   View_i::
674   SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
675   {
676     if (myWorkspace) {
677       switch (theViewPosition) {
678       case VISU::View::LEFT:
679         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
680         break;
681       case VISU::View::CENTER:
682         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
683         break;
684       case VISU::View::RIGHT:
685         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
686         break;
687       }
688     }
689   }
690
691
692   void
693   View_i::
694   SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
695   {
696     if (myWorkspace) {
697       switch (theViewPosition) {
698       case VISU::View::TOP:
699         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
700         break;
701       case VISU::View::CENTER:
702         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
703         break;
704       case VISU::View::BOTTOM:
705         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
706         break;
707       }
708     }
709   }
710
711
712   class TXYEvent: public TWorkspaceEvent
713   {
714   protected:
715     CORBA::Double myX, myY;
716
717   public:
718     TXYEvent(QWidget* theViewWindow,
719              QWidget* theWorkspace,
720              CORBA::Double theX,
721              CORBA::Double theY):
722       TWorkspaceEvent(theViewWindow,theWorkspace),
723       myX(theX),
724       myY(theY)
725     {}
726   };
727
728
729   void
730   View_i::
731   SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
732   {
733     struct TEvent: public TXYEvent
734     {
735     public:
736       TEvent(QWidget* theViewWindow,
737              QWidget* theWorkspace,
738              CORBA::Double theX,
739              CORBA::Double theY):
740         TXYEvent(theViewWindow,theWorkspace,theX,theY)
741       {}
742
743       virtual
744       void
745       Execute()
746       {
747         if(QWidget* aParent = myVW->parentWidget())
748           aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
749       }
750     };
751
752     if (myWorkspace)
753       ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
754   }
755
756   void
757   View_i::
758   SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
759   {
760     struct TEvent: public TXYEvent
761     {
762     public:
763       TEvent(QWidget* theViewWindow,
764              QWidget* theWorkspace,
765              CORBA::Double theX,
766              CORBA::Double theY):
767         TXYEvent(theViewWindow,theWorkspace,theX,theY)
768       {}
769
770       virtual
771       void
772       Execute()
773       {
774         if(QWidget* aParent = myVW->parentWidget())
775           aParent->setGeometry(aParent->x(),
776                                aParent->y(),
777                                int(myX*myWorkspace->width()),
778                                int(myY*myWorkspace->height()));
779       }
780     };
781
782     if (myWorkspace)
783       ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
784   }
785   // End: Old methods for view parameters management, they don't work now
786
787   void
788   View_i::
789   SetBackground (const SALOMEDS::Color& theColor)
790   {
791     struct TEvent: public SALOME_Event
792     {
793       SVTK_ViewWindow* myVW;
794       SALOMEDS::Color myColor;
795     public:
796       TEvent(SVTK_ViewWindow* theViewWindow,
797              const SALOMEDS::Color& theColor):
798         myVW(theViewWindow),
799         myColor(theColor)
800       {}
801       virtual void Execute(){
802         int aColor[3];
803         aColor[0] = int(255.0*myColor.R);
804         aColor[1] = int(255.0*myColor.G);
805         aColor[2] = int(255.0*myColor.B);
806         QColor aNewColor (aColor[0],aColor[1],aColor[2]);
807         myVW->setBackgroundColor(aNewColor);
808       }
809     };
810         
811     SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
812     if (aVW)
813       ProcessVoidEvent(new TEvent(aVW, theColor));
814   }
815
816
817   struct TBackgroundEvent: public SALOME_Event
818   {
819     SVTK_ViewWindow* myVW;
820     typedef SALOMEDS::Color TResult;
821     TResult myResult;
822
823     TBackgroundEvent(SVTK_ViewWindow* theViewWindow):
824       myVW(theViewWindow)
825     {}
826
827     virtual
828     void
829     Execute()
830     {
831       vtkFloatingPointType backint[3];
832       GetRenderer(myVW)->GetBackground(backint);
833       myResult.R = backint[0];
834       myResult.G = backint[1];
835       myResult.B = backint[2];
836     }
837   };
838
839   SALOMEDS::Color
840   View_i::
841   GetBackground()
842   {
843     SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
844     if (aVW)
845       return ProcessEvent(new TBackgroundEvent(aVW));
846
847     SALOMEDS::Color aBlack;
848     aBlack.R = 0.0;
849     aBlack.G = 0.0;
850     aBlack.B = 0.0;
851     return aBlack;
852   }
853
854   void
855   View_i::
856   Minimize()
857   {
858     SUIT_ViewWindow* aVW = GetViewWindow();
859     if (aVW)
860       ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMinimized));
861   }
862
863   void
864   View_i::
865   Restore()
866   {
867     SUIT_ViewWindow* aVW = GetViewWindow();
868     if (aVW)
869       ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showNormal));
870   }
871
872   void
873   View_i::
874   Maximize()
875   {
876     SUIT_ViewWindow* aVW = GetViewWindow();
877     if (aVW)
878       ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMaximized));
879   }
880
881   void
882   View_i::
883   EraseAll()
884   {}
885
886   void
887   View_i::
888   DisplayAll()
889   {}
890
891   void
892   View_i::
893   Erase (PrsObject_ptr thePrsObj)
894   {}
895
896   void
897   View_i::
898   Display (PrsObject_ptr thePrsObj)
899   {}
900
901   void
902   View_i::
903   DisplayOnly (PrsObject_ptr thePrsObj)
904   {}
905
906   void
907   View_i::
908   Update()
909   {}
910
911   class TSavePictureEvent: public SALOME_Event
912   {
913     SUIT_ViewWindow * myVW;
914     const char      * myFileName;
915   public:
916     typedef CORBA::Boolean TResult;
917     TResult myResult;
918     TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
919       : myVW(theViewWindow),
920         myFileName(theFileName),
921         myResult(false)
922     {
923     }
924
925     virtual void Execute()
926     {
927       if (myVW) {
928         QImage img = myVW->dumpView();
929         if (!img.isNull()) {
930           QString fileName (myFileName);
931           if (!fileName.isEmpty()) {
932             QString fmt = SUIT_Tools::extension(fileName).toUpper();
933             if (fmt.isEmpty()) fmt = QString("BMP"); // default format
934             if (fmt == "JPG" ) fmt = "JPEG";
935             //QApplication::setOverrideCursor(Qt::waitCursor);
936             img.save(fileName, fmt.toLatin1().data());
937             myResult = true;
938             //QApplication::restoreOverrideCursor();
939           }
940         }
941       }
942     }
943   };
944
945   CORBA::Boolean
946   View_i::SavePicture(const char* theFileName)
947   {
948     return ProcessEvent(new TSavePictureEvent (GetViewWindow(), theFileName));
949   }
950
951   const char*
952   View_i::GetComment() const
953   {
954     return "";
955   }
956
957   void
958   View_i::
959   ToStream (std::ostringstream& theStr)
960   {
961   }
962
963   SUIT_ViewWindow* View_i::GetViewWindow()
964   {
965     if (myViewWindow) {
966       QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
967       int aPos = aViews.indexOf(myViewWindow);
968       if (aPos < 0)
969         myViewWindow = NULL;
970     }
971     return myViewWindow;
972   }
973
974   void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow)
975   {
976     myViewWindow = theViewWindow;
977   }
978
979
980   //===========================================================================
981   XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
982     : View_i(theApplication, NULL)
983   {
984     if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
985   }
986
987   struct TCreatePlot2dViewEvent: public SALOME_Event
988   {
989     XYPlot_i * myPlot2dView;
990     int        myNew;
991
992     typedef Plot2d_ViewFrame* TResult;
993     TResult myResult;
994
995     TCreatePlot2dViewEvent (XYPlot_i * thePlot2dView,
996                             const int  theNew):
997       myPlot2dView(thePlot2dView),
998       myNew(theNew),
999       myResult(NULL)
1000     {}
1001
1002     virtual
1003     void
1004     Execute()
1005     {
1006       if (!myPlot2dView->myApplication)
1007         return;
1008
1009       SUIT_ViewManager* aViewMgr =
1010         myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), false);
1011       SUIT_ViewWindow* aVW = NULL;
1012
1013       if (aViewMgr) {
1014         if (myNew)
1015           aVW = aViewMgr->createViewWindow();
1016         else
1017           aVW = aViewMgr->getActiveView();
1018       } else {
1019         if (myNew) {
1020           aViewMgr = myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), true);
1021           aVW = aViewMgr->getActiveView();
1022         } else {
1023           return; // there are no current Plot2d view
1024         }
1025       }
1026
1027       if (aVW) {
1028         Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(aVW);
1029         if (aPlot2dVW) {
1030           myResult = aPlot2dVW->getViewFrame();
1031           if (myResult) {
1032             myResult->Repaint();
1033           }
1034
1035           myPlot2dView->myViewManager = aViewMgr;
1036           myPlot2dView->SetViewWindow(aVW);
1037         }
1038       }
1039     }
1040   };
1041
1042   Storable* XYPlot_i::Create (int theNew)
1043   {
1044     myView = ProcessEvent(new TCreatePlot2dViewEvent(this, theNew));
1045     if (myView)
1046       return this;
1047     return NULL;
1048   }
1049
1050   void XYPlot_i::Update()
1051   {
1052     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
1053   }
1054
1055   struct TCloseViewEvent: public SALOME_Event
1056   {
1057     SUIT_ViewWindow* myView;
1058     TCloseViewEvent (SUIT_ViewWindow* theView):
1059       myView(theView)
1060     {}
1061     
1062     virtual void Execute()
1063     {
1064       if ( myView ) myView->close();
1065     }
1066   };
1067
1068   void XYPlot_i::Close()
1069   {
1070     ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1071     QApplication::sendPostedEvents();
1072   }
1073
1074   XYPlot_i::~XYPlot_i() {
1075     if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1076   }
1077
1078   void XYPlot_i::SetTitle (const char* theTitle)
1079   {
1080     SUIT_ViewWindow* aVW = GetViewWindow();
1081     if (aVW)
1082       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1083                        (aVW, &SUIT_ViewWindow::setWindowTitle, QString(theTitle)));
1084   }
1085   char* XYPlot_i::GetTitle()
1086   {
1087     SUIT_ViewWindow* aVW = GetViewWindow();
1088     if (aVW)
1089       return CORBA::string_dup( aVW->windowTitle().toLatin1().data());
1090     return CORBA::string_dup("");
1091   }
1092
1093   void XYPlot_i::SetSubTitle (const char* theTitle)
1094   {
1095     if (GetViewWindow())
1096       ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1097                        (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1098   }
1099
1100   char* XYPlot_i::GetSubTitle()
1101   {
1102     if (GetViewWindow())
1103       return CORBA::string_dup(myView->getTitle().toLatin1().data());
1104     return CORBA::string_dup("");
1105   }
1106
1107   void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1108   {
1109     if (GetViewWindow())
1110       ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1111                        (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1112   }
1113
1114   VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1115   {
1116     if (GetViewWindow())
1117       return (VISU::XYPlot::CurveType)myView->getCurveType();
1118     return VISU::XYPlot::POINTS;
1119   }
1120
1121   void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1122   {
1123     if (GetViewWindow())
1124       ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1125                        (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1126   }
1127
1128   CORBA::Long XYPlot_i::GetMarkerSize()
1129   {
1130     if (GetViewWindow())
1131       return myView->getMarkerSize();
1132     return -1;
1133   }
1134
1135   void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1136                               CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1137   {
1138     class TEvent: public SALOME_Event
1139     {
1140     public:
1141       TEvent (Plot2d_ViewFrame* theView, 
1142               CORBA::Boolean theMajor, 
1143               CORBA::Long theNumMajor,
1144               CORBA::Boolean theMinor, 
1145               CORBA::Long theNumMinor):
1146         myView(theView),
1147         myMajor(theMajor), 
1148         myNumMajor(theNumMajor),
1149         myMinor(theMinor), 
1150         myNumMinor(theNumMinor)
1151       {}
1152       
1153       virtual void Execute()
1154       {
1155         myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor );
1156       }
1157     protected:
1158       Plot2d_ViewFrame* myView;
1159       CORBA::Boolean myMajor, myMinor;
1160       CORBA::Long myNumMajor, myNumMinor;
1161     };
1162
1163     if ( GetViewWindow() )
1164       ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) );
1165   }
1166   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, 
1167                              CORBA::Long theNumMajor,
1168                              CORBA::Boolean theMinor, 
1169                              CORBA::Long theNumMinor)
1170   {
1171     this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 );
1172   }
1173
1174   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1175                              CORBA::Long theNumMajor,
1176                              CORBA::Boolean theMinor, 
1177                              CORBA::Long theNumMinor,
1178                              CORBA::Boolean the2Major, 
1179                              CORBA::Long the2NumMajor,
1180                              CORBA::Boolean the2Minor, 
1181                              CORBA::Long the2NumMinor)
1182   {
1183     class TEvent: public SALOME_Event
1184     {
1185     public:
1186       TEvent (Plot2d_ViewFrame* theView, 
1187               CORBA::Boolean theMajor,
1188               CORBA::Long theNumMajor,
1189               CORBA::Boolean theMinor, 
1190               CORBA::Long theNumMinor,
1191               CORBA::Boolean the2Major, 
1192               CORBA::Long the2NumMajor,
1193               CORBA::Boolean the2Minor, 
1194               CORBA::Long the2NumMinor):
1195         myView(theView),
1196         myMajor(theMajor), 
1197         myNumMajor(theNumMajor),
1198         myMinor(theMinor), 
1199         myNumMinor(theNumMinor),
1200         my2Major(the2Major), 
1201         my2NumMajor(the2NumMajor),
1202         my2Minor(the2Minor), 
1203         my2NumMinor(the2NumMinor)
1204       {}
1205       
1206       virtual void Execute()
1207       {
1208         myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor,
1209                           my2Major, my2NumMajor, my2Minor, my2NumMinor);
1210       }
1211     protected:
1212       Plot2d_ViewFrame* myView;
1213       CORBA::Boolean myMajor, myMinor, my2Major, my2Minor;
1214       CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor;
1215     };
1216
1217     if (GetViewWindow())
1218       ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor, 
1219                                     the2Major, the2NumMajor, the2Minor, the2NumMinor ) );
1220   }
1221   
1222   class TSetScaleModeEvent: public SALOME_Event
1223   {
1224   public:
1225     typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1226     TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1227       myView(theView), myFun(theFun), myScaling(theScaling)
1228     {}
1229
1230     virtual void Execute()
1231     {
1232       (myView->*myFun)(myScaling,true);
1233     }
1234   protected:
1235     Plot2d_ViewFrame* myView;
1236     TFun myFun;
1237     int myScaling;
1238   };
1239
1240   void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1241   {
1242     if (GetViewWindow())
1243       ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1244                                               theScaling == VISU::LOGARITHMIC));
1245   }
1246
1247   VISU::Scaling XYPlot_i::GetHorScaling()
1248   {
1249     //jfa: may be need to be enclosed in SALOME_Event?
1250     if (GetViewWindow())
1251       return (VISU::Scaling)myView->getHorScaleMode();
1252     return VISU::LINEAR;
1253   }
1254
1255   void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1256   {
1257     if (GetViewWindow())
1258       ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1259                                               theScaling == VISU::LOGARITHMIC));
1260   }
1261
1262   VISU::Scaling XYPlot_i::GetVerScaling()
1263   {
1264     if (GetViewWindow())
1265       return (VISU::Scaling)myView->getVerScaleMode();
1266     return VISU::LINEAR;
1267   }
1268
1269   class TSetTitleEvent: public SALOME_Event
1270   {
1271   public:
1272     TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1273       myView(theView), myType(theType), myTitle(theTitle)
1274     {}
1275     virtual void Execute()
1276     {
1277       myView->setTitle(true,myTitle,myType);
1278     }
1279   protected:
1280     Plot2d_ViewFrame* myView;
1281     Plot2d_ViewFrame::ObjectType myType;
1282     const char* myTitle;
1283   };
1284
1285   void XYPlot_i::SetXTitle (const char* theTitle)
1286   {
1287     if (GetViewWindow())
1288       ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1289   }
1290   char* XYPlot_i::GetXTitle()
1291   {
1292     if (GetViewWindow())
1293       return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle).toLatin1().data());
1294     return CORBA::string_dup("");
1295   }
1296
1297   void XYPlot_i::SetYTitle (const char* theTitle)
1298   {
1299     if (GetViewWindow())
1300       ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1301   }
1302   char* XYPlot_i::GetYTitle()
1303   {
1304     if (GetViewWindow())
1305       return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle).toLatin1().data());
1306     return CORBA::string_dup("");
1307   }
1308
1309   void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1310   {
1311     if (GetViewWindow())
1312       ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1313                        (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1314   }
1315
1316   class TXYPlotViewEvent: public SALOME_Event
1317   {
1318     SalomeApp_Application* myApplication;
1319     Plot2d_ViewFrame*      myView;
1320     PrsObject_ptr          myPrsObj;
1321     int                    myDisplaing;
1322
1323   public:
1324     TXYPlotViewEvent(SalomeApp_Application* theApplication,
1325                      Plot2d_ViewFrame*      theView,
1326                      PrsObject_ptr          thePrsObj,
1327                      int                    theDisplaing)
1328       : myApplication(theApplication),
1329       myView(theView),
1330       myPrsObj(thePrsObj),
1331       myDisplaing(theDisplaing)
1332     {
1333     }
1334
1335     virtual void Execute()
1336     {
1337       // is it Curve ?
1338       if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1339         UpdatePlot2d(myView,myDisplaing,aCurve);
1340       }
1341       // is it Container ?
1342       if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1343         int nbCurves = aContainer->GetNbCurves();
1344         for ( int i = 1; i <= nbCurves; i++ ) {
1345           VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1346           if ( aCurve && aCurve->IsValid() ) {
1347             UpdatePlot2d(myView,myDisplaing,aCurve);
1348           }
1349         }
1350         myView->Repaint();
1351       }
1352       // is it Table ?
1353       if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1354         _PTR(Study) aCStudy;
1355         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1356           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1357             aCStudy = aStudy->studyDS();
1358           }
1359         }
1360         if (!aCStudy) return;
1361         _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry());
1362         if (TableSO) {
1363           _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1364           for (; Iter->More(); Iter->Next()) {
1365             CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1366             if (!CORBA::is_nil(childObject)) {
1367               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1368               if (!CORBA::is_nil(aCurve))
1369                 UpdatePlot2d(myView, myDisplaing,
1370                              dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
1371             }
1372           }
1373           myView->Repaint();
1374         }
1375       }
1376     }
1377   };
1378
1379   void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1380   {
1381     if (GetViewWindow())
1382       ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1383   }
1384
1385   void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1386   {
1387     if (GetViewWindow())
1388       ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1389   }
1390
1391   void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1392   {
1393     if (GetViewWindow())
1394       ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1395   }
1396
1397   void XYPlot_i::EraseAll()
1398   {
1399     if (GetViewWindow())
1400       ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1401   }
1402
1403   void XYPlot_i::FitAll()
1404   {
1405     if (GetViewWindow())
1406       ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1407   }
1408
1409   class TFitRangeEvent: public SALOME_Event
1410   {
1411   public:
1412     TFitRangeEvent (Plot2d_ViewFrame* theView,
1413                     const int mode,
1414                     const double xMin, const double xMax,
1415                     const double yMin, const double yMax):
1416       myView(theView), 
1417       myMode(mode),
1418       myXMin(xMin),myXMax(xMax),
1419       myYMin(yMin),myYMax(yMax)
1420     {}
1421     virtual void Execute()
1422     {
1423       myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax);
1424     }
1425   protected:
1426     const int myMode;
1427     const double myXMin;
1428     const double myXMax;
1429     const double myYMin;
1430     const double myYMax;
1431     Plot2d_ViewFrame* myView;
1432   };
1433   
1434   void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax)
1435   {
1436     const CORBA::Long mode = 1;
1437     const CORBA::Double yMin = 0.0;
1438     const CORBA::Double yMax = 0.0;
1439     ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1440   }
1441
1442   void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax)
1443   {
1444     const CORBA::Long mode = 2;
1445     const CORBA::Double xMin = 0.0;
1446     const CORBA::Double xMax = 0.0;
1447     ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1448   }
1449
1450   void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
1451                           const CORBA::Double yMin,const CORBA::Double yMax)
1452   {
1453     const CORBA::Long mode = 0;
1454     ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1455   }
1456   
1457   void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax)
1458   {
1459     double y2Min,y2Max;
1460     myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1461   }
1462
1463   //===========================================================================
1464   TableView_i::TableView_i (SalomeApp_Application* theApplication)
1465     : View_i(theApplication, NULL)
1466   {
1467   }
1468
1469   struct TCreateTableViewEvent: public SALOME_Event
1470   {
1471     SalomeApp_Application* myApplication;
1472     VISU::Table_i*         myTable;
1473
1474     typedef VisuGUI_TableDlg* TResult;
1475     TResult myResult;
1476
1477     TCreateTableViewEvent (SalomeApp_Application* theApplication,
1478                            VISU::Table_i*         theTable):
1479       myApplication(theApplication),
1480       myTable(theTable),
1481       myResult(NULL)
1482     {}
1483
1484     virtual
1485     void
1486     Execute()
1487     {
1488       if (myTable != NULL) {
1489         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1490           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1491             if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1492               _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1493               if (aSObject) {
1494                 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1495                                                  aSObject,
1496                                                  false,
1497                                                  VisuGUI_TableDlg::ttAuto,
1498                                                  Qt::Vertical);
1499                 myResult->show();
1500               }
1501             }
1502           }
1503         }
1504       }
1505     }
1506   };
1507
1508   Storable* TableView_i::Create (VISU::Table_ptr theTable)
1509   {
1510     if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1511     if (!theTable->_is_nil()) {
1512       VISU::Table_i* table =
1513         dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1514       if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1515
1516       myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1517       if (myView)
1518         return this;
1519     }
1520     return NULL;
1521   }
1522
1523   TableView_i::~TableView_i()
1524   {
1525     if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1526     delete myView;
1527   }
1528
1529   void TableView_i::SetTitle (const char* theTitle)
1530   {
1531     ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1532                      (myView, &VisuGUI_TableDlg::setWindowTitle, QString(theTitle)));
1533   }
1534
1535   char* TableView_i::GetTitle()
1536   {
1537     //jfa: may be need to be enclosed in SALOME_Event?
1538     return CORBA::string_dup(myView->windowTitle().toLatin1().data());
1539   }
1540
1541   void TableView_i::Close()
1542   {
1543     //jfa: may be need to be enclosed in SALOME_Event?
1544     myView->close();
1545   }
1546
1547
1548   //===========================================================================
1549   int View3D_i::myNbViewParams = 0;
1550   const string View3D_i::myComment = "VIEW3D";
1551   const char* View3D_i::GetComment() const { return myComment.c_str();}
1552
1553   QString View3D_i::GenerateViewParamsName()
1554   {
1555     return VISU::GenerateName("ViewParams", ++myNbViewParams);
1556   }
1557
1558   View3D_i::View3D_i (SalomeApp_Application* theApplication)
1559     : View_i(theApplication, NULL)
1560   {
1561     if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1562   }
1563
1564   struct TCreateView3dEvent: public SALOME_Event
1565   {
1566     SalomeApp_Application *myApplication;
1567     View3D_i * myView3D;
1568     int        myNew;
1569
1570     typedef SUIT_ViewWindow* TResult;
1571     TResult myResult;
1572
1573     TCreateView3dEvent (SalomeApp_Application *theApplication,
1574                         View3D_i * theView3D,
1575                         const int  theNew):
1576       myApplication(theApplication),
1577       myView3D(theView3D),
1578       myNew(theNew),
1579       myResult(NULL)
1580     {}
1581
1582     virtual
1583     void
1584     Execute()
1585     {
1586       if (!myApplication)
1587         return;
1588
1589       if(myNew){
1590         if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1591           myResult = aViewManager->createViewWindow();
1592           myView3D->myViewManager = aViewManager;
1593         }else{
1594           if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),true)){
1595             myResult = aViewManager->getActiveView();
1596             myView3D->myViewManager = aViewManager;
1597           }
1598         }
1599       }else{
1600         if(SUIT_ViewManager* aViewManager = myApplication->activeViewManager()){
1601           if(SUIT_ViewWindow* aView = aViewManager->getActiveView()){
1602             if(dynamic_cast<SVTK_ViewWindow*>(aView)){
1603               myView3D->myViewManager = aViewManager;
1604               myResult = aViewManager->getActiveView();
1605             }
1606           }
1607         }else{
1608           if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1609             myView3D->myViewManager = aViewManager;
1610             myResult = aViewManager->getActiveView();
1611           }
1612         }
1613       }
1614     }
1615   };
1616
1617   Storable* View3D_i::Create (int theNew)
1618   {
1619     if (MYDEBUG) MESSAGE("View3D_i::Create");
1620     SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(myApplication, this, theNew));
1621     if (aVW) {
1622       SetViewWindow(aVW);
1623       return this;
1624     }
1625     return NULL;
1626   }
1627
1628   void View3D_i::Update()
1629   {
1630     class TEvent: public SALOME_Event
1631     {
1632       SUIT_ViewWindow* myViewWindow;
1633     public:
1634       TEvent(SUIT_ViewWindow* theViewWindow):
1635         myViewWindow(theViewWindow)
1636       {}
1637       virtual void Execute()
1638       {
1639         SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
1640         vtkRenderer* aRenderer = aViewWindow->getRenderer();
1641         VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1642         vtkActorCollection* anActors = aCopy.GetActors();
1643         anActors->InitTraversal();
1644         while (vtkActor *anAct = anActors->GetNextActor()) {
1645           if (VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(anAct)) {
1646             if (anActor->GetVisibility()) 
1647               anActor->UpdateFromFactory();
1648           }
1649         }
1650         RepaintView(myViewWindow);
1651       }
1652     };
1653
1654     if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
1655       ProcessVoidEvent(new TEvent(aViewWindow));
1656   }
1657
1658   bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1659   {
1660     MESSAGE("View3D_i::SaveViewParams()");
1661
1662     if (!theViewManager || theName == "")
1663       return false;
1664
1665     _PTR(Study) aCStudy;
1666     if (SUIT_Study* aSStudy = theViewManager->study()) {
1667       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1668         aCStudy = aStudy->studyDS();
1669       }
1670     }
1671     if (!aCStudy)
1672       return false;
1673
1674     if (theName != "") {
1675       std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
1676       _PTR(GenericAttribute) anAttr;
1677       int iEnd = aList.size();
1678       for (int i = 0; i < iEnd; i++) {
1679         _PTR(SObject) anObj = aList[i];
1680         string anEntry = anObj->GetID();
1681         if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1682         if (anObj->FindAttribute(anAttr, "AttributeString")) {
1683           _PTR(AttributeString) aCmnt (anAttr);
1684           string aComm (aCmnt->Value());
1685           if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1686           if (aComm.compare(View3D_i::myComment) >= 0) {
1687             aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1688             return true;
1689           }
1690         }
1691       }
1692     }
1693     _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1694     string aSComponentEntry = aSComponent->GetID();
1695     string anEntry = CreateAttributes(aCStudy, 
1696                                       aSComponentEntry.c_str(), 
1697                                       "", 
1698                                       "", 
1699                                       theName, 
1700                                       "",
1701                                       ToString(theViewManager->getActiveView()).c_str());
1702     return true;
1703   }
1704
1705   class TSaveViewParamsEvent: public SALOME_Event
1706   {
1707     SUIT_ViewManager* myViewMgr;
1708     std::string       myName;
1709   public:
1710     TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1711                           const std::string& theName):
1712       myViewMgr(theViewManager),
1713       myName(theName)
1714     {}
1715
1716     virtual void Execute()
1717     {
1718       myResult = View3D_i::SaveViewParams(myViewMgr, myName);
1719     }
1720     typedef CORBA::Boolean TResult;
1721     TResult myResult;
1722   };
1723
1724   CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
1725   {
1726     return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
1727   }
1728
1729   bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1730   {
1731     _PTR(Study) aCStudy;
1732     if (SUIT_Study* aSStudy = theViewManager->study()) {
1733       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1734         aCStudy = aStudy->studyDS();
1735       }
1736     }
1737     if (!aCStudy)
1738       return false;
1739
1740     std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1741     _PTR(GenericAttribute) anAttr;
1742     int iEnd = aList.size();
1743     if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1744     for (int i = 0; i < iEnd; i++) {
1745       _PTR(SObject) anObj = aList[i];
1746       string anEntry = anObj->GetID();
1747       if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1748       Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj);
1749       if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) {
1750         Restore(theViewManager->getActiveView(), aMap);
1751         return true;
1752       }
1753     }
1754     return false;
1755   }
1756
1757   class TRestoreViewParamsEvent: public SALOME_Event
1758   {
1759     SUIT_ViewManager* myViewMgr;
1760     std::string       myName;
1761   public:
1762     TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1763                              const std::string& theName):
1764       myViewMgr(theViewManager),
1765       myName(theName)
1766     {}
1767
1768     virtual void Execute()
1769     {
1770       myResult = View3D_i::RestoreViewParams(myViewMgr, myName);
1771     }
1772     typedef CORBA::Boolean TResult;
1773     TResult myResult;
1774   };
1775
1776   CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
1777   {
1778     return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
1779   }
1780
1781   void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
1782                           const Storable::TRestoringMap& theMap)
1783   {
1784     SALOMEDS::Color aColor;
1785     aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1786     aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1787     aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1788
1789     double aPosition[3];
1790     aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1791     aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1792     aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1793
1794     double aFocalPnt[3];
1795     aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1796     aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1797     aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1798
1799     double aViewUp[3];
1800     aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1801     aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1802     aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1803
1804     double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1805
1806     double aScaleFactor[3];
1807     aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1808     aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1809     aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1810
1811     SetBackground(theViewWindow,aColor);
1812     SetPointOfView(theViewWindow,aPosition);
1813     SetViewUp(theViewWindow,aViewUp);
1814     SetFocalPoint(theViewWindow,aFocalPnt);
1815     SetParallelScale(theViewWindow,aParallelScale);
1816     ScaleView(theViewWindow,VISU::View3D::XAxis,aScaleFactor[0]);
1817     ScaleView(theViewWindow,VISU::View3D::YAxis,aScaleFactor[1]);
1818     ScaleView(theViewWindow,VISU::View3D::ZAxis,aScaleFactor[2]);
1819   }
1820
1821
1822   string View3D_i::ToString (SUIT_ViewWindow* theViewWindow)
1823   {
1824     ostringstream strOut;
1825     Storable::DataToStream(strOut, "myComment", myComment.c_str());
1826     ToStream(theViewWindow, strOut);
1827     strOut << ends;
1828     if(MYDEBUG) MESSAGE("View3D_i::ToString - " << strOut.str());
1829     return strOut.str();
1830   }
1831
1832   void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
1833   {
1834     vtkFloatingPointType backint[3];
1835     GetRenderer(theViewWindow)->GetBackground(backint);
1836     Storable::DataToStream(theStr,"myColor.R",backint[0]);
1837     Storable::DataToStream(theStr,"myColor.G",backint[1]);
1838     Storable::DataToStream(theStr,"myColor.B",backint[2]);
1839
1840     double aPosition[3];
1841     GetPointOfView(theViewWindow,aPosition);
1842     Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1843     Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1844     Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1845
1846     double aFocalPnt[3];
1847     GetFocalPoint(theViewWindow,aFocalPnt);
1848     Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1849     Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1850     Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1851
1852     double aViewUp[3];
1853     GetCamera(theViewWindow)->GetViewUp(aViewUp);
1854     Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1855     Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1856     Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1857
1858     Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow));
1859
1860     double aScaleFactor[3];
1861     (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->GetScale(aScaleFactor);
1862     Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1863     Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1864     Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1865   }
1866
1867   void View3D_i::ToStream(std::ostringstream& theStr)
1868   {
1869     SUIT_ViewWindow* aVW = GetViewWindow();
1870     if (aVW)
1871       ToStream(aVW, theStr);
1872   }
1873
1874   void View3D_i::Close()
1875   {
1876     ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1877     QApplication::sendPostedEvents();
1878   }
1879   
1880   View3D_i::~View3D_i()
1881   {
1882     if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1883   }
1884
1885   void View3D_i::SetTitle (const char* theTitle)
1886   {
1887     SUIT_ViewWindow* aVW = GetViewWindow();
1888     if (aVW)
1889       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1890                        (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle)));
1891   }
1892
1893   char* View3D_i::GetTitle()
1894   {
1895     SUIT_ViewWindow* aVW = GetViewWindow();
1896     if (aVW)
1897       return CORBA::string_dup(aVW->windowTitle().toLatin1().data());
1898     return CORBA::string_dup("");
1899   }
1900
1901   void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow,
1902                                 const SALOMEDS::Color& theColor)
1903   {
1904     //jfa: may be need to be enclosed in SALOME_Event?
1905     int aColor[3];
1906     aColor[0] = int(255.0*theColor.R);
1907     aColor[1] = int(255.0*theColor.G);
1908     aColor[2] = int(255.0*theColor.B);
1909     QColor aNewColor (aColor[0],aColor[1],aColor[2]);
1910     (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->setBackgroundColor(aNewColor);
1911   }
1912
1913   SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow)
1914   {
1915     SALOMEDS::Color aColor;
1916     vtkFloatingPointType backint[3];
1917     GetRenderer(theViewWindow)->GetBackground(backint);
1918     aColor.R = backint[0];  aColor.G = backint[1];  aColor.B = backint[2];
1919     return aColor;
1920   }
1921
1922   class TUpdateViewerEvent: public SALOME_Event
1923   {
1924     SUIT_ViewWindow* myVW;
1925     Prs3d_i* myPrs3d;
1926     int myDisplaing;
1927   public:
1928     TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow,
1929                        Prs3d_i* thePrs3d,
1930                        int theDisplaing):
1931       myVW(theViewWindow),
1932       myPrs3d(thePrs3d),
1933       myDisplaing(theDisplaing)
1934     {}
1935     virtual void Execute(){
1936       UpdateViewer(myVW, myDisplaing, myPrs3d);
1937     }
1938   };
1939
1940   class TDisplayTableEvent: public SALOME_Event
1941   {
1942     SUIT_ViewWindow* myVW;
1943     PointMap3d_i* myTable;
1944     int myDisplaying;
1945   public:
1946     TDisplayTableEvent( SUIT_ViewWindow* theView,
1947                         PointMap3d_i* theTable,
1948                         int theDisplaying ) :
1949       myVW (theView),
1950       myTable (theTable),
1951       myDisplaying (theDisplaying)
1952     {}
1953     virtual void Execute() {
1954       SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myVW);
1955       VISU_PointMap3dActor* anActor = myTable->CreateActor();
1956       myTable->UpdateActor( anActor );
1957       aViewWindow->AddActor( anActor );
1958     }
1959   };
1960
1961   void View3D_i::EraseAll()
1962   {
1963     if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1964     SUIT_ViewWindow* aVW = GetViewWindow();
1965     if (aVW)
1966       ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll));
1967   }
1968
1969   void View3D_i::DisplayAll()
1970   {
1971     if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1972     SUIT_ViewWindow* aVW = GetViewWindow();
1973     if (aVW)
1974       ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll));
1975   }
1976
1977   void View3D_i::Erase (PrsObject_ptr thePrsObj)
1978   {
1979     if(MYDEBUG) MESSAGE("View3D_i::Erase");
1980     SUIT_ViewWindow* aVW = GetViewWindow();
1981     CORBA::Object_ptr anObj = thePrsObj;
1982     Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1983     if (aVW && aPrs)
1984       ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase));
1985   }
1986
1987   void View3D_i::Display (PrsObject_ptr thePrsObj)
1988   {
1989     if(MYDEBUG) MESSAGE("View3D_i::Display");
1990     SUIT_ViewWindow* aVW = GetViewWindow();
1991     CORBA::Object_ptr anObj = thePrsObj;
1992     Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1993     if (aVW && aPrs)
1994       ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
1995     else if (aVW && !aPrs) {
1996       PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
1997       if (aTable)
1998         ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay));
1999     }
2000   }
2001
2002   void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
2003   {
2004     if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
2005     SUIT_ViewWindow* aVW = GetViewWindow();
2006     CORBA::Object_ptr anObj = thePrsObj;
2007     Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
2008     if (aVW && aPrs)
2009       ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
2010     else if (aVW && !aPrs) {
2011       PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
2012       if (aTable)
2013         ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly));
2014     }
2015   }
2016
2017   void View3D_i::FitAll()
2018   {
2019     SUIT_ViewWindow* aVW = GetViewWindow();
2020     if (aVW) {
2021       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2022                        (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFitAll));
2023       Update();
2024     }
2025   }
2026
2027   void View3D_i::SetView (VISU::View3D::ViewType theType)
2028   {
2029     SUIT_ViewWindow* aVW = GetViewWindow();
2030     if (!aVW)
2031       return;
2032
2033     switch (theType) {
2034     case VISU::View3D::FRONT :
2035       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2036                        (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFrontView));
2037       break;
2038     case VISU::View3D::BACK :
2039       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2040                        (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onBackView));
2041       break;
2042     case VISU::View3D::LEFT :
2043       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2044                        (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onLeftView));
2045       break;
2046     case VISU::View3D::RIGHT :
2047       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2048                        (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onRightView));
2049       break;
2050     case VISU::View3D::TOP :
2051       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2052                        (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onTopView));
2053       break;
2054     case VISU::View3D::BOTTOM :
2055       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2056                        (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onBottomView));
2057       break;
2058     }
2059     Update();
2060   }
2061
2062   class TSet3DViewParamEvent: public SALOME_Event
2063   {
2064   public:
2065     typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]);
2066     TSet3DViewParamEvent (TFun theFun,
2067                           SUIT_ViewWindow* theViewWindow,
2068                           const CORBA::Double theParam[3]):
2069       myFun(theFun),
2070       myVW(theViewWindow),
2071       myParam(theParam)
2072     {}
2073     virtual void Execute() {
2074       myFun(myVW,myParam);
2075     }
2076   private:
2077     TFun myFun;
2078     SUIT_ViewWindow* myVW;
2079     const CORBA::Double* myParam;
2080   };
2081
2082   void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow,
2083                                  const CORBA::Double thePosition[3])
2084   {
2085     //jfa: may be need to be enclosed in SALOME_Event?
2086     GetCamera(theViewWindow)->SetPosition(thePosition);
2087   }
2088
2089   void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
2090   {
2091     if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
2092     SUIT_ViewWindow* aVW = GetViewWindow();
2093     if (aVW)
2094       ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition));
2095   }
2096
2097   void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
2098                                  CORBA::Double thePosition[3])
2099   {
2100     GetCamera(theViewWindow)->GetPosition(thePosition);
2101   }
2102
2103   VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
2104   {
2105     if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
2106     CORBA::Double aPosition[3];
2107     SUIT_ViewWindow* aVW = GetViewWindow();
2108     if (aVW)
2109       GetPointOfView(aVW,aPosition);
2110     return VISU::View3D::XYZ_dup(aPosition);
2111   }
2112
2113   void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow,
2114                             const CORBA::Double theViewUp[3])
2115   {
2116     GetCamera(theViewWindow)->SetViewUp(theViewUp);
2117   }
2118
2119   void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
2120   {
2121     if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
2122     SUIT_ViewWindow* aVW = GetViewWindow();
2123     if (aVW)
2124       ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp));
2125   }
2126
2127   void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
2128                             CORBA::Double theViewUp[3])
2129   {
2130     GetCamera(theViewWindow)->GetViewUp(theViewUp);
2131   }
2132
2133   VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
2134   {
2135     if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
2136     CORBA::Double aViewUp[3];
2137     SUIT_ViewWindow* aVW = GetViewWindow();
2138     if (aVW)
2139       GetCamera(aVW)->GetViewUp(aViewUp);
2140     return VISU::View3D::XYZ_dup(aViewUp);
2141   }
2142
2143   void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow,
2144                                 const CORBA::Double theFocalPnt[3])
2145   {
2146     GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt);
2147   }
2148
2149   void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
2150   {
2151     if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
2152     SUIT_ViewWindow* aVW = GetViewWindow();
2153     if (aVW)
2154       ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord));
2155   }
2156
2157
2158   void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow,
2159                                 CORBA::Double theFocalPnt[3])
2160   {
2161     GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt);
2162   }
2163
2164   VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
2165   {
2166     if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
2167     CORBA::Double aFocalPnt[3];
2168     SUIT_ViewWindow* aVW = GetViewWindow();
2169     if (aVW)
2170       GetFocalPoint(aVW,aFocalPnt);
2171     return VISU::View3D::XYZ_dup(aFocalPnt);
2172   }
2173
2174   class TSetViewParamEvent: public SALOME_Event
2175   {
2176   public:
2177     typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam);
2178     TSetViewParamEvent (TFun theFun,
2179                         SUIT_ViewWindow* theViewWindow,
2180                         CORBA::Double theParam):
2181       myFun(theFun),
2182       myVW(theViewWindow),
2183       myParam(theParam)
2184     {}
2185     virtual void Execute()
2186     {
2187       myFun(myVW,myParam);
2188     }
2189   private:
2190     TFun myFun;
2191     SUIT_ViewWindow* myVW;
2192     CORBA::Double myParam;
2193   };
2194
2195   void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow,
2196                                    CORBA::Double theScale)
2197   {
2198     GetCamera(theViewWindow)->SetParallelScale(theScale);
2199   }
2200
2201   void View3D_i::SetParallelScale (CORBA::Double theScale)
2202   {
2203     if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
2204     SUIT_ViewWindow* aVW = GetViewWindow();
2205     if (aVW)
2206       ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale));
2207   }
2208
2209   CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
2210   {
2211     return GetCamera(theViewWindow)->GetParallelScale();
2212   }
2213
2214   CORBA::Double View3D_i::GetParallelScale()
2215   {
2216     if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
2217     SUIT_ViewWindow* aVW = GetViewWindow();
2218     if (aVW)
2219       return GetParallelScale(aVW);
2220     return 1.0;
2221   }
2222
2223   void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow,
2224                             VISU::View3D::Axis theAxis, CORBA::Double theParam)
2225   {
2226     SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
2227     double aScaleFactor[3];
2228     aViewWindow->GetScale(aScaleFactor);
2229     aScaleFactor[theAxis] = theParam;
2230     aViewWindow->SetScale(aScaleFactor);
2231   }
2232
2233   void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3])
2234   {
2235     double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2236     (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->SetScale(aScale);
2237   }
2238
2239   void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2240   {
2241     if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2242     SUIT_ViewWindow* aVW = GetViewWindow();
2243     if (aVW) {
2244       double aScale[3];
2245       (dynamic_cast<SVTK_ViewWindow*>(aVW))->GetScale(aScale);
2246       aScale[theAxis] = theParam;
2247       ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2248     }
2249   }
2250
2251   void View3D_i::RemoveScale()
2252   {
2253     if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2254     SUIT_ViewWindow* aVW = GetViewWindow();
2255     if (aVW) {
2256       double aScale[3] = {1.0, 1.0, 1.0};
2257       ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2258     }
2259   }
2260
2261   //================================================
2262   // Certain presentation view parameters management
2263   //================================================
2264   class TPrsManageEvent: public SALOME_Event
2265   {
2266   protected:
2267     View3D_i* myView3D;
2268     ScalarMap_ptr myPrs;
2269     string myError;
2270
2271     TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2272       myView3D(theView3D),
2273       myPrs(ScalarMap::_duplicate(thePrs)),
2274       myError("Unknown error occured")
2275     {}
2276     VISU_Actor* GetMyActor()
2277     {
2278       SUIT_ViewWindow* aVW = myView3D->GetViewWindow();
2279       SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aVW);
2280       if (!aVW) {
2281         myError = "Corrupted view window";
2282       } else {
2283         ScalarMap_i* aPrs = dynamic_cast<ScalarMap_i*>(VISU::GetServant(myPrs).in());
2284         if (!aPrs) {
2285           myError = "Corrupted presentation";
2286         } else {
2287           VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
2288           if (!anActor) {
2289             myError = "No actor found. Display the presentation at first.";
2290           } else {
2291             myError = "";
2292             return anActor;
2293           }
2294         }
2295       }
2296       return NULL;
2297     }
2298   };
2299
2300   // Get
2301   class TGetPrsTypeEvent: public TPrsManageEvent {
2302   public:
2303     typedef VISU::PresentationType TResult;
2304     TResult myResult;
2305     TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2306       TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {}
2307     virtual void Execute() {
2308       if (VISU_Actor* anActor = GetMyActor())
2309         myResult = (VISU::PresentationType)anActor->GetRepresentation();
2310     }
2311   };
2312
2313   class TGetShrinkedEvent: public TPrsManageEvent {
2314   public:
2315     typedef bool TResult;
2316     TResult myResult;
2317     TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2318       TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2319     virtual void Execute() {
2320       if (VISU_Actor* anActor = GetMyActor()) {
2321         if (anActor->IsShrunkable())
2322           myResult = anActor->IsShrunk();
2323         else
2324           myResult = false;
2325       }
2326     }
2327   };
2328
2329   class TGetShadedEvent: public TPrsManageEvent {
2330   public:
2331     typedef bool TResult;
2332     TResult myResult;
2333     TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2334       TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2335     virtual void Execute() {
2336       if (VISU_Actor* anActor = GetMyActor())
2337         if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor))
2338           myResult = aScalarMapActor->IsShading();
2339     }
2340   };
2341
2342   class TGetOpacityEvent: public TPrsManageEvent {
2343   public:
2344     typedef double TResult;
2345     TResult myResult;
2346     TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2347       TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2348     virtual void Execute() {
2349       if (VISU_Actor* anActor = GetMyActor()) {
2350         vtkFloatingPointType oldvalue = anActor->GetOpacity();
2351         myResult = (double)oldvalue;
2352       }
2353     }
2354   };
2355
2356   class TGetLineWidthEvent: public TPrsManageEvent {
2357   public:
2358     typedef double TResult;
2359     TResult myResult;
2360     TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2361       TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2362     virtual void Execute() {
2363       if (VISU_Actor* anActor = GetMyActor()) {
2364         vtkFloatingPointType oldvalue = anActor->GetLineWidth();
2365         myResult = (double)oldvalue;
2366       }
2367     }
2368   };
2369
2370   // Set
2371   class TSetPrsTypeEvent: public TPrsManageEvent {
2372   private:
2373     PresentationType myPrsType;
2374   public:
2375     typedef string TResult;
2376     TResult myResult;
2377     TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType):
2378       TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType),
2379       myResult("Unknown error occured")
2380     {}
2381     virtual void Execute() {
2382       VISU::VISUType aType = myPrs->GetType();
2383       switch (myPrsType) {
2384       case VISU::INSIDEFRAME:
2385         {
2386           if (aType != VISU::TSCALARMAP &&
2387               aType != VISU::TDEFORMEDSHAPE &&
2388               aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2389               aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2390             myResult = "Insideframe representation is not available for this type of presentations.";
2391             return;
2392           }
2393         }
2394         break;
2395       case VISU::SURFACEFRAME:
2396         {
2397           if (aType != VISU::TSCALARMAP &&
2398               aType != VISU::TDEFORMEDSHAPE &&
2399               aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2400               aType != VISU::TDEFORMEDSHAPEANDSCALARMAP &&
2401               aType != VISU::TCUTPLANES &&
2402               aType != VISU::TISOSURFACES &&
2403               aType != VISU::TPLOT3D) {
2404             myResult = "Surfaceframe representation is not available for this type of presentations.";
2405             return;
2406           }
2407         }
2408         break;
2409       case VISU::SHRINK:
2410         myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
2411         return;
2412       default:
2413         break;
2414       }
2415       if (VISU_Actor* anActor = GetMyActor()) {
2416         anActor->SetRepresentation((int)myPrsType);
2417         SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2418         vw->Repaint();
2419         myResult = "";
2420       } else {
2421         myResult = myError;
2422       }
2423     }
2424   };
2425
2426   class TSetShrinkedEvent: public TPrsManageEvent {
2427   private:
2428     bool myIsOn;
2429   public:
2430     typedef string TResult;
2431     TResult myResult;
2432     TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2433       TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2434       myResult("Unknown error occured")
2435     {}
2436     virtual void Execute() {
2437       VISU::VISUType aType = myPrs->GetType();
2438       if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2439         myResult = "Shrinked representation is not available for this type of presentations.";
2440       } else {
2441         if (VISU_Actor* anActor = GetMyActor()) {
2442           if (anActor->IsShrunkable()) {
2443             if (myIsOn) anActor->SetShrink();
2444             else        anActor->UnShrink();
2445             SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2446             vw->Repaint();
2447             myResult = "";
2448           } else {
2449             myResult = "This presentation is not shrunkable.";
2450           }
2451         } else {
2452           myResult = myError;
2453         }
2454       }
2455     }
2456   };
2457
2458   class TSetShadedEvent: public TPrsManageEvent {
2459   private:
2460     bool myIsOn;
2461   public:
2462     typedef string TResult;
2463     TResult myResult;
2464     TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2465       TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2466       myResult("Unknown error occured")
2467     {}
2468     virtual void Execute() {
2469       if (VISU_Actor* anActor = GetMyActor()) {
2470         if (VISU_ScalarMapAct* aScalarMapActor =
2471             dynamic_cast<VISU_ScalarMapAct*>(anActor)) {
2472           aScalarMapActor->SetShading(myIsOn);
2473           SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2474           vw->Repaint();
2475           myResult = "";
2476         } else {
2477           myResult = "Corrupted actor";
2478         }
2479       } else {
2480         myResult = myError;
2481       }
2482     }
2483   };
2484
2485   class TSetOpacityEvent: public TPrsManageEvent {
2486   private:
2487     double myOpacity;
2488   public:
2489     typedef string TResult;
2490     TResult myResult;
2491     TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity):
2492       TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity),
2493       myResult("Unknown error occured")
2494     {}
2495     virtual void Execute() {
2496       VISU::VISUType aType = myPrs->GetType();
2497       if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2498         myResult = "Opacity is meaningless for this type of presentations.";
2499         return;
2500       }
2501       if (VISU_Actor* anActor = GetMyActor()) {
2502         anActor->SetOpacity((vtkFloatingPointType)myOpacity);
2503         SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2504         vw->Repaint();
2505         myResult = "";
2506       } else {
2507         myResult = myError;
2508       }
2509     }
2510   };
2511
2512   class TSetLineWidthEvent: public TPrsManageEvent {
2513   private:
2514     double myLineWidth;
2515   public:
2516     typedef string TResult;
2517     TResult myResult;
2518     TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth):
2519       TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth),
2520       myResult("Unknown error occured")
2521     {}
2522     virtual void Execute() {
2523       if (myPrs->GetType() == VISU::TVECTORS) {
2524         myResult = "Line Width is meaningless for Vectors presentation.";
2525         return;
2526       }
2527       if (VISU_Actor* anActor = GetMyActor()) {
2528         anActor->SetLineWidth((vtkFloatingPointType)myLineWidth);
2529         SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2530         vw->Repaint();
2531         myResult = "";
2532       } else {
2533         myResult = myError;
2534       }
2535     }
2536   };
2537
2538   class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2539   private:
2540     Quadratic2DPresentationType myPrsType;
2541   public:
2542     typedef string TResult;
2543     TResult myResult;
2544     TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D,
2545                                          ScalarMap_ptr thePrs,
2546                                          Quadratic2DPresentationType theType):
2547       TPrsManageEvent(theView3D, thePrs), myPrsType(theType),
2548       myResult("Unknown error occured")
2549     {}
2550     virtual void Execute() 
2551     {
2552       VISU::VISUType aType = myPrs->GetType();
2553       if (aType != VISU::TSCALARMAP &&
2554           aType != VISU::TDEFORMEDSHAPE &&
2555           aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2556           aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2557         myResult = "2D Quadratic element representation is not available for this type of presentations.";
2558         return;
2559       }
2560       if (VISU_Actor* anActor = GetMyActor()) {
2561         if(myPrsType == VISU::LINES)
2562           anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
2563         else if(myPrsType == VISU::ARCS)
2564           anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
2565         
2566         SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2567         vw->Repaint();
2568         myResult = "";
2569       } else {
2570         myResult = myError;
2571       }
2572     }
2573   };
2574
2575   class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2576   public:
2577     typedef VISU::Quadratic2DPresentationType TResult;
2578     TResult myResult;
2579     TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2580       TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {}
2581     virtual void Execute() {
2582       if (VISU_Actor* anActor = GetMyActor()) {
2583         if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines)
2584           myResult = VISU::LINES;
2585         else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs)
2586           myResult = VISU::ARCS;
2587       }
2588     }
2589   };
2590
2591   PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
2592   {
2593     return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
2594   }
2595   CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs)
2596   {
2597     return ProcessEvent(new TGetShrinkedEvent(this,thePrs));
2598   }
2599   CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs)
2600   {
2601     return ProcessEvent(new TGetShadedEvent(this,thePrs));
2602   }
2603   CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs)
2604   {
2605     return ProcessEvent(new TGetOpacityEvent(this,thePrs));
2606   }
2607   CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs)
2608   {
2609     return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
2610   }
2611
2612   Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs)
2613   {
2614     return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs));
2615   }
2616   
2617   char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
2618   {
2619     string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
2620     return CORBA::string_dup(aRet.c_str());
2621   }
2622   char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked)
2623   {
2624     string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked));
2625     return CORBA::string_dup(aRet.c_str());
2626   }
2627   char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded)
2628   {
2629     string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded));
2630     return CORBA::string_dup(aRet.c_str());
2631   }
2632   char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity)
2633   {
2634     string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity));
2635     return CORBA::string_dup(aRet.c_str());
2636   }
2637   char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth)
2638   {
2639     string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
2640     return CORBA::string_dup(aRet.c_str());
2641   }
2642   
2643   char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType)
2644   {
2645     string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType));
2646     return CORBA::string_dup(aRet.c_str());
2647   }
2648 }
2649
2650