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