Salome HOME
b927adb1eacee9c19a4db41a8b025390a59c562d
[modules/visu.git] / src / VISU_I / VISU_View_i.cc
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //  File   : VISU_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_ViewManager_i.hh"
33
34 #include "VisuGUI_TableDlg.h"
35
36 #include "VISU_Actor.h"
37
38 #include "SALOME_Event.hxx"
39
40 #include "SUIT_ViewWindow.h"
41 #include "SUIT_ViewManager.h"
42 #include "SUIT_Tools.h"
43
44 #include "STD_MDIDesktop.h"
45 #include "STD_TabDesktop.h"
46
47 #include "SVTK_ViewWindow.h"
48 #include "SVTK_ViewModel.h"
49 #include "SVTK_RenderWindow.h"
50
51 #include "SPlot2d_ViewModel.h"
52 #include "Plot2d_ViewFrame.h"
53
54 #include "SalomeApp_Application.h"
55 #include "SalomeApp_Study.h"
56
57 #include <QtxWorkstack.h>
58
59 #include <qworkspace.h>
60
61 #include <vtkCamera.h>
62 #include <vtkRenderer.h>
63
64 using namespace std;
65
66 #ifdef _DEBUG_
67 static int MYDEBUG = 0;
68 #else
69 static int MYDEBUG = 0;
70 #endif
71
72 namespace VISU {
73
74   typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
75
76   struct TNewViewEvent: public SALOME_Event
77   {
78     SalomeApp_Application* myApplication;
79     typedef QWidget* TResult;
80     TResult myResult;
81
82     TNewViewEvent (SalomeApp_Application* theApplication):
83       myApplication(theApplication),
84       myResult(NULL)
85     {}
86
87     virtual
88     void
89     Execute()
90     {
91       if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
92         myResult = aDesktop->workspace();
93       }
94     }
95   };
96
97   View_i::
98   View_i (SalomeApp_Application *theApplication,
99           SUIT_ViewManager* theViewManager):
100     myApplication(theApplication),
101     myWorkspace(NULL),
102     myViewManager(theViewManager)
103   {
104     if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
105     myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
106   }
107
108   View_i::
109   ~View_i()
110   {
111     if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
112   }
113
114
115   struct TApplicationEvent: public SALOME_Event
116   {
117     SalomeApp_Application* myApplication;
118
119     TApplicationEvent(SalomeApp_Application* theApplication):
120       myApplication(theApplication)
121     {}
122   };
123
124   void
125   View_i::
126   ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
127             CORBA::Boolean theState)
128   {
129     struct TEvent: public TApplicationEvent
130     {
131       VISU::View::ViewRepresentation myViewRepresentation;
132       CORBA::Boolean myState;
133
134       TEvent(SalomeApp_Application* theApplication,
135              VISU::View::ViewRepresentation theViewRepresentation,
136              CORBA::Boolean theState):
137         TApplicationEvent(theApplication),
138         myViewRepresentation(theViewRepresentation),
139         myState(theState)
140       {}
141
142       virtual
143       void
144       Execute()
145       {
146         switch(myViewRepresentation){
147         case VISU::View::OBJECTBROWSER:
148           myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState);
149           break;
150         case VISU::View::PYTHON:
151           myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState);
152           break;
153         case VISU::View::MESSAGES:
154           myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState);
155           break;
156         case VISU::View::VIEWER:{
157           ViewManagerList aViewManagerList = myApplication->viewManagers();
158           // to do something
159           // ...
160           break;
161         }}
162       }
163     };
164
165     ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
166   }
167
168   struct TPartShownEvent: public TApplicationEvent
169   {
170     VISU::View::ViewRepresentation myViewRepresentation;
171     typedef bool TResult;
172     TResult myResult;
173
174     TPartShownEvent(SalomeApp_Application* theApplication,
175                     VISU::View::ViewRepresentation theViewRepresentation):
176       TApplicationEvent(theApplication),
177       myViewRepresentation(theViewRepresentation),
178       myResult(false)
179     {}
180
181     virtual
182     void
183     Execute()
184     {
185       switch(myViewRepresentation){
186       case VISU::View::OBJECTBROWSER:
187         myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser);
188         break;
189       case VISU::View::PYTHON:
190         myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole);
191         break;
192       case VISU::View::MESSAGES:
193         myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow);
194         break;
195       case VISU::View::VIEWER:{
196         ViewManagerList aViewManagerList = myApplication->viewManagers();
197         // to do something
198         // ...
199         break;
200       }}
201     }
202   };
203
204   CORBA::Boolean
205   View_i::
206   IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
207   {
208     return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
209   }
210
211   // Begin: New methods for view parameters management
212   struct TSplitEvent: public SALOME_Event
213   {
214     SalomeApp_Application * myApplication;
215     SUIT_ViewWindow       * myViewWindow;
216     Qt::Orientation         myOrientation;
217     QtxWorkstack::SplitType mySplitType;
218
219   public:
220     TSplitEvent (SalomeApp_Application * theApplication,
221                  SUIT_ViewWindow       * theViewWindow,
222                  Qt::Orientation         theOrientation,
223                  QtxWorkstack::SplitType theSplitType):
224       myApplication(theApplication),
225       myViewWindow(theViewWindow),
226       myOrientation(theOrientation),
227       mySplitType(theSplitType)
228     {}
229
230     virtual void Execute()
231     {
232       SUIT_Desktop* desk = myApplication->desktop();
233       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
234       if (tabDesk) {
235         QtxWorkstack* workstack = tabDesk->workstack();
236         if (workstack) {
237           workstack->Split(myViewWindow, myOrientation, mySplitType);
238         }
239       }
240     }
241   };
242
243   void
244   View_i::
245   SplitRight()
246   {
247     ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
248                                      Qt::Horizontal,QtxWorkstack::SPLIT_MOVE));
249   }
250
251   void
252   View_i::
253   SplitLeft()
254   {
255     ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
256                                      Qt::Horizontal,QtxWorkstack::SPLIT_STAY));
257   }
258
259   void
260   View_i::
261   SplitBottom()
262   {
263     ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
264                                      Qt::Vertical,QtxWorkstack::SPLIT_MOVE));
265   }
266
267   void
268   View_i::
269   SplitTop()
270   {
271     ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,
272                                      Qt::Vertical,QtxWorkstack::SPLIT_STAY));
273   }
274
275   void
276   View_i::
277   OnTop()
278   {
279     struct TOnTopEvent: public SALOME_Event
280     {
281       SUIT_ViewWindow * myViewWindow;
282
283     public:
284       TOnTopEvent (SUIT_ViewWindow * theViewWindow):
285         myViewWindow(theViewWindow)
286       {}
287
288       virtual void Execute()
289       {
290         if (myViewWindow) {
291           myViewWindow->setFocus();
292         }
293       }
294     };
295
296     ProcessVoidEvent(new TOnTopEvent(myViewWindow));
297   }
298
299   struct TAttractEvent: public SALOME_Event
300   {
301     SalomeApp_Application * myApplication;
302     SUIT_ViewWindow       * myViewWindow1;
303     SUIT_ViewWindow       * myViewWindow2;
304     bool                    myAttractAll;
305
306   public:
307     TAttractEvent (SalomeApp_Application * theApplication,
308                    SUIT_ViewWindow       * theViewWindow1,
309                    SUIT_ViewWindow       * theViewWindow2,
310                    bool                    theAttractAll):
311       myApplication(theApplication),
312       myViewWindow1(theViewWindow1),
313       myViewWindow2(theViewWindow2),
314       myAttractAll(theAttractAll)
315     {}
316
317     virtual void Execute()
318     {
319       SUIT_Desktop* desk = myApplication->desktop();
320       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
321       if (tabDesk) {
322         QtxWorkstack* workstack = tabDesk->workstack();
323         if (workstack) {
324           workstack->Attract(myViewWindow1, myViewWindow2, myAttractAll);
325         }
326       }
327     }
328   };
329
330   void
331   View_i::
332   Attract (VISU::View_ptr theView)
333   {
334     if (!CORBA::is_nil(theView)) {
335       if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
336         ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,false));
337       }
338     }
339   }
340
341   void
342   View_i::
343   AttractAll (VISU::View_ptr theView)
344   {
345     if (!CORBA::is_nil(theView)) {
346       if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
347         ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,true));
348       }
349     }
350   }
351
352   struct TSizePositionEvent: public SALOME_Event
353   {
354     SalomeApp_Application * myApplication;
355     SUIT_ViewWindow       * myViewWindow;
356     double                  myValue;
357     bool                    myIsSize;
358
359   public:
360     TSizePositionEvent (SalomeApp_Application * theApplication,
361                         SUIT_ViewWindow       * theViewWindow,
362                         double                  theValue,
363                         bool                    theIsSize):
364       myApplication(theApplication),
365       myViewWindow(theViewWindow),
366       myValue(theValue),
367       myIsSize(theIsSize)
368     {}
369
370     virtual void Execute()
371     {
372       MESSAGE("TSizePositionEvent::Execute()");
373       SUIT_Desktop* desk = myApplication->desktop();
374       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
375       if (tabDesk) {
376         QtxWorkstack* workstack = tabDesk->workstack();
377         if (workstack) {
378           if (myIsSize) {
379             //jfa to do:workstack->SetRelativeSizeInSplitter(myViewWindow, myValue);
380           } else {
381             workstack->SetRelativePositionInSplitter(myViewWindow, myValue);
382           }
383         }
384       }
385     }
386   };
387
388   void
389   View_i::
390   SetRelativePositionInSplitter (CORBA::Double thePosition)
391   {
392     if (thePosition < 0.0 || 1.0 < thePosition) {
393       return;
394     }
395     ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,thePosition,false));
396   }
397
398   void
399   View_i::
400   SetRelativeSizeInSplitter (CORBA::Double theSize)
401   {
402     if (theSize < 0.0 || 1.0 < theSize) {
403       return;
404     }
405     ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,theSize,true));
406   }
407
408   struct TWSSizePositionEvent: public SALOME_Event
409   {
410     SalomeApp_Application * myApplication;
411     SUIT_ViewWindow       * myViewWindow;
412     Qt::Orientation         myOrientation;
413     double                  myValue;
414     bool                    myIsSize;
415
416   public:
417     TWSSizePositionEvent (SalomeApp_Application * theApplication,
418                           SUIT_ViewWindow       * theViewWindow,
419                           Qt::Orientation         theOrientation,
420                           double                  theValue,
421                           bool                    theIsSize):
422       myApplication(theApplication),
423       myViewWindow(theViewWindow),
424       myOrientation(theOrientation),
425       myValue(theValue),
426       myIsSize(theIsSize)
427     {}
428
429     virtual void Execute()
430     {
431       MESSAGE("TWSSizePositionEvent::Execute()");
432       SUIT_Desktop* desk = myApplication->desktop();
433       STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
434       if (tabDesk) {
435         QtxWorkstack* workstack = tabDesk->workstack();
436         if (workstack) {
437           if (myIsSize) {
438             //jfa to do:workstack->SetRelativeSize(myViewWindow, myOrientation, myValue);
439           } else {
440             workstack->SetRelativePosition(myViewWindow, myOrientation, myValue);
441           }
442         }
443       }
444     }
445   };
446
447   void
448   View_i::
449   SetRelativePositionX (CORBA::Double thePosition)
450   {
451     if (thePosition < 0.0 || 1.0 < thePosition) {
452       return;
453     }
454     ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
455                                               Qt::Horizontal,thePosition,false));
456   }
457
458   void
459   View_i::
460   SetRelativePositionY (CORBA::Double thePosition)
461   {
462     if (thePosition < 0.0 || 1.0 < thePosition) {
463       return;
464     }
465     ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
466                                               Qt::Vertical,thePosition,false));
467   }
468
469   void
470   View_i::
471   SetRelativeSizeX (CORBA::Double theSize)
472   {
473     if (theSize < 0.0 || 1.0 < theSize) {
474       return;
475     }
476     ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
477                                               Qt::Horizontal,theSize,true));
478   }
479
480   void
481   View_i::
482   SetRelativeSizeY (CORBA::Double theSize)
483   {
484     if (theSize < 0.0 || 1.0 < theSize) {
485       return;
486     }
487     ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow,
488                                               Qt::Vertical,theSize,true));
489   }
490   // End: New methods for view parameters management
491
492   // Begin: Old methods for view parameters management, they don't work now
493   struct TSetViewSize: public SALOME_Event
494   {
495     SUIT_ViewWindow* myViewWindow;
496     typedef void (QRect::* TAction)(int);
497     TAction myAction;
498     CORBA::Long mySize;
499
500   public:
501     TSetViewSize(SUIT_ViewWindow* theViewWindow,
502                  TAction theAction,
503                  CORBA::Long theSize):
504       myViewWindow(theViewWindow),
505       myAction(theAction),
506       mySize(theSize)
507     {}
508
509     virtual
510     void
511     Execute()
512     {
513       if (QWidget* aParent = myViewWindow->parentWidget(true)) {
514         QRect aQRect = aParent->frameGeometry();
515         (aQRect.*myAction)(mySize);
516         aParent->setGeometry(aQRect);
517       }
518     }
519   };
520
521   void
522   View_i::
523   SetViewWidth(CORBA::Long theWidth)
524   {
525     ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
526   }
527
528   void
529   View_i::
530   SetViewHeight(CORBA::Long theHeight)
531   {
532     ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
533   }
534
535
536   struct TGetViewSize: public SALOME_Event
537   {
538     SUIT_ViewWindow* myViewWindow;
539
540     typedef int (QRect::* TAction)() const;
541     TAction myAction;
542
543     typedef CORBA::Long TResult;
544     TResult myResult;
545
546   public:
547     TGetViewSize(SUIT_ViewWindow* theViewWindow,
548                  TAction theAction):
549       myViewWindow(theViewWindow),
550       myAction(theAction)
551     {}
552
553     virtual
554     void
555     Execute()
556     {
557       if(QWidget* aParent = myViewWindow->parentWidget(true)){
558         QRect aQRect = aParent->frameGeometry();
559         myResult = (aQRect.*myAction)();
560       }
561     }
562   };
563
564
565   CORBA::Long
566   View_i::
567   GetViewWidth()
568   {
569     return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
570   }
571
572   CORBA::Long
573   View_i::
574   GetViewHeight()
575   {
576     return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
577   }
578
579
580   class TWorkspaceEvent: public SALOME_Event
581   {
582   protected:
583     QWidget* myViewWindow;
584     QWidget* myWorkspace;
585
586   public:
587     TWorkspaceEvent(QWidget* theViewWindow,
588                     QWidget* theWorkspace):
589       myViewWindow(theViewWindow),
590       myWorkspace(theWorkspace)
591     {}
592   };
593
594
595   class TAlignEvent: public TWorkspaceEvent
596   {
597   protected:
598     Qt::AlignmentFlags myAligment;
599
600   public:
601     TAlignEvent(QWidget* theViewWindow,
602                 QWidget* theWorkspace,
603                 Qt::AlignmentFlags theAligment):
604       TWorkspaceEvent(theViewWindow,theWorkspace),
605       myAligment(theAligment)
606     {}
607
608     virtual
609     void
610     Execute()
611     {
612       if(QWidget* aParent = myViewWindow->parentWidget(true))
613         SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
614     }
615   };
616
617
618   void
619   View_i::
620   SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
621   {
622     if (myWorkspace) {
623       switch (theViewPosition) {
624       case VISU::View::LEFT:
625         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
626         break;
627       case VISU::View::CENTER:
628         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
629         break;
630       case VISU::View::RIGHT:
631         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
632         break;
633       }
634     }
635   }
636
637
638   void
639   View_i::
640   SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
641   {
642     if (myWorkspace) {
643       switch (theViewPosition) {
644       case VISU::View::TOP:
645         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
646         break;
647       case VISU::View::CENTER:
648         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
649         break;
650       case VISU::View::BOTTOM:
651         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
652         break;
653       }
654     }
655   }
656
657
658   class TXYEvent: public TWorkspaceEvent
659   {
660   protected:
661     CORBA::Double myX, myY;
662
663   public:
664     TXYEvent(QWidget* theViewWindow,
665              QWidget* theWorkspace,
666              CORBA::Double theX,
667              CORBA::Double theY):
668       TWorkspaceEvent(theViewWindow,theWorkspace),
669       myX(theX),
670       myY(theY)
671     {}
672   };
673
674
675   void
676   View_i::
677   SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
678   {
679     struct TEvent: public TXYEvent
680     {
681     public:
682       TEvent(QWidget* theViewWindow,
683              QWidget* theWorkspace,
684              CORBA::Double theX,
685              CORBA::Double theY):
686         TXYEvent(theViewWindow,theWorkspace,theX,theY)
687       {}
688
689       virtual
690       void
691       Execute()
692       {
693         if(QWidget* aParent = myViewWindow->parentWidget(true))
694           aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
695       }
696     };
697
698     if (myWorkspace)
699       ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
700   }
701
702   void
703   View_i::
704   SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
705   {
706     struct TEvent: public TXYEvent
707     {
708     public:
709       TEvent(QWidget* theViewWindow,
710              QWidget* theWorkspace,
711              CORBA::Double theX,
712              CORBA::Double theY):
713         TXYEvent(theViewWindow,theWorkspace,theX,theY)
714       {}
715
716       virtual
717       void
718       Execute()
719       {
720         if(QWidget* aParent = myViewWindow->parentWidget(true))
721           aParent->setGeometry(aParent->x(),
722                                aParent->y(),
723                                int(myX*myWorkspace->width()),
724                                int(myY*myWorkspace->height()));
725       }
726     };
727
728     if (myWorkspace)
729       ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
730   }
731   // End: Old methods for view parameters management, they don't work now
732
733   void
734   View_i::
735   SetBackground (const SALOMEDS::Color& theColor)
736   {
737     struct TEvent: public SALOME_Event
738     {
739       QWidget* myWidget;
740       SALOMEDS::Color myColor;
741     public:
742       TEvent(QWidget* theWidget,
743              const SALOMEDS::Color& theColor):
744         myWidget(theWidget),
745         myColor(theColor)
746       {}
747       virtual void Execute(){
748         int aColor[3];
749         aColor[0] = int(255.0*myColor.R);
750         aColor[1] = int(255.0*myColor.G);
751         aColor[2] = int(255.0*myColor.B);
752         myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2]));
753       }
754     };
755
756     ProcessVoidEvent(new TEvent(myViewWindow,theColor));
757   }
758
759
760   struct TBackgroundEvent: public SALOME_Event
761   {
762     QWidget* myWidget;
763     typedef SALOMEDS::Color TResult;
764     TResult myResult;
765
766     TBackgroundEvent(QWidget* theWidget):
767       myWidget(theWidget)
768     {}
769
770     virtual
771     void
772     Execute()
773     {
774       const QColor& aColor = myWidget->backgroundColor();
775       myResult.R = aColor.red()/255.0;
776       myResult.G = aColor.green()/255.0;
777       myResult.B = aColor.blue()/255.0;
778     }
779   };
780
781   SALOMEDS::Color
782   View_i::
783   GetBackground()
784   {
785     return ProcessEvent(new TBackgroundEvent(myViewWindow));
786   }
787
788   void
789   View_i::
790   Minimize()
791   {
792     ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMinimized));
793   }
794
795   void
796   View_i::
797   Restore()
798   {
799     ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showNormal));
800   }
801
802   void
803   View_i::
804   Maximize()
805   {
806     ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMaximized));
807   }
808
809   void
810   View_i::
811   EraseAll()
812   {}
813
814   void
815   View_i::
816   DisplayAll()
817   {}
818
819   void
820   View_i::
821   Erase (PrsObject_ptr thePrsObj)
822   {}
823
824   void
825   View_i::
826   Display (PrsObject_ptr thePrsObj)
827   {}
828
829   void
830   View_i::
831   DisplayOnly (PrsObject_ptr thePrsObj)
832   {}
833
834   void
835   View_i::
836   Update()
837   {}
838
839   class TSavePictureEvent: public SALOME_Event
840   {
841     SUIT_ViewWindow * myViewWindow;
842     const char      * myFileName;
843   public:
844     typedef CORBA::Boolean TResult;
845     TResult myResult;
846     TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
847       : myViewWindow(theViewWindow),
848         myFileName(theFileName),
849         myResult(false)
850     {
851     }
852
853     virtual void Execute()
854     {
855       if (myViewWindow) {
856         QImage img = myViewWindow->dumpView();
857         if (!img.isNull()) {
858           QString fileName (myFileName);
859           if (!fileName.isEmpty()) {
860             QString fmt = SUIT_Tools::extension(fileName).upper();
861             if (fmt.isEmpty()) fmt = QString("BMP"); // default format
862             if (fmt == "JPG" ) fmt = "JPEG";
863             //QApplication::setOverrideCursor(Qt::waitCursor);
864             img.save(fileName, fmt.latin1());
865             //QApplication::restoreOverrideCursor();
866           }
867         }
868       }
869     }
870   };
871
872   CORBA::Boolean
873   View_i::SavePicture(const char* theFileName)
874   {
875     return ProcessEvent(new TSavePictureEvent (myViewWindow,theFileName));
876   }
877
878   const char*
879   View_i::
880   GetComment() const
881   {
882     return "";
883   }
884
885   void
886   View_i::
887   ToStream (std::ostringstream& theStr)
888   {
889   }
890
891
892   //================= OLD CODE ===================
893
894   //QAD_Study* CheckStudy (SALOMEDS::Study_ptr theStudy)
895   //{
896   //  //QAD_Desktop* aDesktop = QAD_Application::getDesktop();
897   //  //QAD_Study* aStudy = aDesktop->findStudy(theStudy);
898   //  if (!aStudy) {
899   //    CORBA::String_var aName = theStudy->Name();
900   //    aFileInfo.setFile(aName.in());
901   //    if (aFileInfo.exists())
902   //      aStudy = aDesktop->loadStudy(aFileInfo.baseName());
903   //    else
904   //      aStudy = aDesktop->loadStudy(aName.in());
905   //    if (!aStudy) {
906   //      MESSAGE("CheckStudy()::ERROR: Can't load study");
907   //    }
908   //  }
909   //  return aStudy;
910   //}
911
912   template<class TViewer>
913   struct TNewSpecViewEvent: public SALOME_Event
914   {
915     SalomeApp_Application* myApplication;
916
917     typedef SUIT_ViewManager* TResult;
918     TResult myResult;
919
920     TNewSpecViewEvent (SalomeApp_Application* theApplication):
921       myApplication(theApplication),
922       myResult(NULL)
923     {}
924
925     virtual
926     void
927     Execute()
928     {
929       myResult = myApplication->getViewManager(TViewer::Type(), false);
930       if (!myResult) {
931         myResult = myApplication->getViewManager(TViewer::Type(), true);
932         myResult->closeAllViews();
933       }
934     }
935   };
936
937   //===========================================================================
938   XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
939     : View_i(theApplication, NULL)
940   {
941     if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
942     if (theApplication) {
943       myViewManager = ProcessEvent(new TNewSpecViewEvent<SPlot2d_Viewer>(theApplication));
944     }
945   }
946
947
948   struct TCreatePlot2dViewEvent: public SALOME_Event
949   {
950     SUIT_ViewManager* myViewManager;
951     XYPlot_i        * myPlot2dView;
952     int               myNew;
953
954     typedef Plot2d_ViewFrame* TResult;
955     TResult myResult;
956
957     TCreatePlot2dViewEvent (SUIT_ViewManager* theViewManager,
958                             XYPlot_i        * thePlot2dView,
959                             const int         theNew):
960       myViewManager(theViewManager),
961       myPlot2dView(thePlot2dView),
962       myNew(theNew),
963       myResult(NULL)
964     {}
965
966     virtual
967     void
968     Execute()
969     {
970       if (myNew) {
971         myPlot2dView->myViewWindow = myViewManager->createViewWindow();
972       } else {
973         myPlot2dView->myViewWindow = myViewManager->getActiveView();
974       }
975       if (myPlot2dView->myViewWindow) {
976         Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myPlot2dView->myViewWindow);
977         if (aPlot2dVW) {
978           myResult = aPlot2dVW->getViewFrame();
979           if (myResult) {
980             myResult->Repaint();
981           }
982         }
983       }
984     }
985   };
986
987   Storable* XYPlot_i::Create (int theNew)
988   {
989     myView = ProcessEvent(new TCreatePlot2dViewEvent(myViewManager, this, theNew));
990     return this;
991   }
992
993   void XYPlot_i::Update()
994   {
995     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
996   }
997
998   void XYPlot_i::Close()
999   {
1000     //jfa: may be need to be enclosed in SALOME_Event?
1001     myViewWindow->close();
1002   }
1003
1004   XYPlot_i::~XYPlot_i() {
1005     if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1006   }
1007
1008   void XYPlot_i::SetTitle (const char* theTitle)
1009   {
1010     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1011                      (myViewWindow, &SUIT_ViewWindow::setCaption, QString(theTitle)));
1012   }
1013   char* XYPlot_i::GetTitle()
1014   {
1015     //jfa: may be need to be enclosed in SALOME_Event?
1016     return CORBA::string_dup(myViewWindow->caption().latin1());
1017   }
1018
1019   void XYPlot_i::SetSubTitle (const char* theTitle)
1020   {
1021     ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1022                      (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1023   }
1024
1025   char* XYPlot_i::GetSubTitle()
1026   {
1027     //jfa: may be need to be enclosed in SALOME_Event?
1028     return CORBA::string_dup(myView->getTitle());
1029   }
1030
1031   void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1032   {
1033     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1034                      (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1035   }
1036
1037   VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1038   {
1039     //jfa: may be need to be enclosed in SALOME_Event?
1040     return (VISU::XYPlot::CurveType)myView->getCurveType();
1041   }
1042
1043   void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1044   {
1045     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1046                      (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1047   }
1048
1049   CORBA::Long XYPlot_i::GetMarkerSize()
1050   {
1051     //jfa: may be need to be enclosed in SALOME_Event?
1052     return myView->getMarkerSize();
1053   }
1054
1055   class TEnableGridEvent: public SALOME_Event
1056   {
1057   public:
1058     typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
1059     TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun,
1060                       CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1061                       CORBA::Boolean theMinor, CORBA::Long theNumMinor):
1062       myView(theView), myFun(theFun),
1063       myMajor(theMajor), myNumMajor(theNumMajor),
1064       myMinor(theMinor), myNumMinor(theNumMinor)
1065     {}
1066
1067     virtual void Execute()
1068     {
1069       (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true);
1070     }
1071   protected:
1072     Plot2d_ViewFrame* myView;
1073     TFun myFun;
1074     CORBA::Boolean myMajor, myMinor;
1075     CORBA::Long myNumMajor, myNumMinor;
1076   };
1077
1078   void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1079                               CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1080   {
1081     ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
1082                                           theMajor,theNumMajor,theMinor,theNumMinor));
1083   }
1084   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1085                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1086   {
1087     //asl: Plot2d_ViewFrame::setYGrid has more parameters
1088     //ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
1089     //                 theMajor,theNumMajor,theMinor,theNumMinor));
1090   }
1091
1092   class TSetScaleModeEvent: public SALOME_Event
1093   {
1094   public:
1095     typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1096     TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1097       myView(theView), myFun(theFun), myScaling(theScaling)
1098     {}
1099
1100     virtual void Execute()
1101     {
1102       (myView->*myFun)(myScaling,true);
1103     }
1104   protected:
1105     Plot2d_ViewFrame* myView;
1106     TFun myFun;
1107     int myScaling;
1108   };
1109
1110   void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1111   {
1112     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1113                                             theScaling == VISU::LOGARITHMIC));
1114   }
1115
1116   VISU::Scaling XYPlot_i::GetHorScaling()
1117   {
1118     //jfa: may be need to be enclosed in SALOME_Event?
1119     return (VISU::Scaling)myView->getHorScaleMode();
1120   }
1121
1122   void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1123   {
1124     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1125                                             theScaling == VISU::LOGARITHMIC));
1126   }
1127
1128   VISU::Scaling XYPlot_i::GetVerScaling()
1129   {
1130     //jfa: may be need to be enclosed in SALOME_Event?
1131     return (VISU::Scaling)myView->getVerScaleMode();
1132   }
1133
1134   class TSetTitleEvent: public SALOME_Event
1135   {
1136   public:
1137     TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1138       myView(theView), myType(theType), myTitle(theTitle)
1139     {}
1140     virtual void Execute()
1141     {
1142       myView->setTitle(true,myTitle,myType);
1143     }
1144   protected:
1145     Plot2d_ViewFrame* myView;
1146     Plot2d_ViewFrame::ObjectType myType;
1147     const char* myTitle;
1148   };
1149
1150   void XYPlot_i::SetXTitle (const char* theTitle)
1151   {
1152     ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1153   }
1154   char* XYPlot_i::GetXTitle()
1155   {
1156     //jfa: may be need to be enclosed in SALOME_Event?
1157     return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
1158   }
1159
1160   void XYPlot_i::SetYTitle (const char* theTitle)
1161   {
1162     ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1163   }
1164   char* XYPlot_i::GetYTitle()
1165   {
1166     //jfa: may be need to be enclosed in SALOME_Event?
1167     return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
1168   }
1169
1170   void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1171   {
1172     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1173                      (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1174   }
1175
1176   class TXYPlotViewEvent: public SALOME_Event
1177   {
1178     SalomeApp_Application* myApplication;
1179     Plot2d_ViewFrame*      myView;
1180     PrsObject_ptr          myPrsObj;
1181     int                    myDisplaing;
1182
1183   public:
1184     TXYPlotViewEvent(SalomeApp_Application* theApplication,
1185                      Plot2d_ViewFrame*      theView,
1186                      PrsObject_ptr          thePrsObj,
1187                      int                    theDisplaing)
1188       : myApplication(theApplication),
1189       myView(theView),
1190       myPrsObj(thePrsObj),
1191       myDisplaing(theDisplaing)
1192     {
1193     }
1194
1195     virtual void Execute()
1196     {
1197       // is it Curve ?
1198       if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1199         UpdatePlot2d(myView,myDisplaing,aCurve);
1200       }
1201       // is it Container ?
1202       if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1203         int nbCurves = aContainer->GetNbCurves();
1204         for ( int i = 1; i <= nbCurves; i++ ) {
1205           VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1206           if ( aCurve && aCurve->IsValid() ) {
1207             UpdatePlot2d(myView,myDisplaing,aCurve);
1208           }
1209         }
1210         myView->Repaint();
1211       }
1212       // is it Table ?
1213       if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1214         _PTR(Study) aCStudy;
1215         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1216           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1217             aCStudy = aStudy->studyDS();
1218           }
1219         }
1220         if (!aCStudy) return;
1221         _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
1222         if (TableSO) {
1223           _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1224           for (; Iter->More(); Iter->Next()) {
1225             CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1226             if (!CORBA::is_nil(childObject)) {
1227               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1228               if (!CORBA::is_nil(aCurve))
1229                 UpdatePlot2d(myView, myDisplaing,
1230                              dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
1231             }
1232           }
1233           myView->Repaint();
1234         }
1235       }
1236     }
1237   };
1238
1239   void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1240   {
1241     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1242   }
1243
1244   void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1245   {
1246     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1247   }
1248
1249   void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1250   {
1251     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1252   }
1253
1254   void XYPlot_i::EraseAll()
1255   {
1256     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1257   }
1258
1259   void XYPlot_i::FitAll()
1260   {
1261     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1262   }
1263
1264   class TFitRangeEvent: public SALOME_Event
1265   {
1266   public:
1267     TFitRangeEvent (Plot2d_ViewFrame* theView,
1268                     const int mode,
1269                     const double xMin, const double xMax,
1270                     const double yMin, const double yMax):
1271       myView(theView), 
1272       myMode(mode),
1273       myXMin(xMin),myXMax(xMax),
1274       myYMin(yMin),myYMax(yMax)
1275     {}
1276     virtual void Execute()
1277     {
1278       myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax);
1279     }
1280   protected:
1281     const int myMode;
1282     const double myXMin;
1283     const double myXMax;
1284     const double myYMin;
1285     const double myYMax;
1286     Plot2d_ViewFrame* myView;
1287   };
1288   
1289   void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax)
1290   {
1291     const CORBA::Long mode = 1;
1292     const CORBA::Double yMin = 0.0;
1293     const CORBA::Double yMax = 0.0;
1294     ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1295   }
1296
1297   void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax)
1298   {
1299     const CORBA::Long mode = 2;
1300     const CORBA::Double xMin = 0.0;
1301     const CORBA::Double xMax = 0.0;
1302     ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1303   }
1304
1305   void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
1306                           const CORBA::Double yMin,const CORBA::Double yMax)
1307   {
1308     const CORBA::Long mode = 0;
1309     ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1310   }
1311   
1312   void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax)
1313   {
1314     double y2Min,y2Max;
1315     myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1316   }
1317
1318   //===========================================================================
1319   TableView_i::TableView_i (SalomeApp_Application* theApplication)
1320     : View_i(theApplication, NULL)
1321   {
1322   }
1323
1324   struct TCreateTableViewEvent: public SALOME_Event
1325   {
1326     SalomeApp_Application* myApplication;
1327     VISU::Table_i*         myTable;
1328
1329     typedef VisuGUI_TableDlg* TResult;
1330     TResult myResult;
1331
1332     TCreateTableViewEvent (SalomeApp_Application* theApplication,
1333                            VISU::Table_i*         theTable):
1334       myApplication(theApplication),
1335       myTable(theTable),
1336       myResult(NULL)
1337     {}
1338
1339     virtual
1340     void
1341     Execute()
1342     {
1343       if (myTable != NULL) {
1344         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1345           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1346             if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1347               _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1348               if (aSObject) {
1349                 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1350                                                  aSObject,
1351                                                  false,
1352                                                  VisuGUI_TableDlg::ttAuto,
1353                                                  Qt::Vertical);
1354                 myResult->show();
1355               }
1356             }
1357           }
1358         }
1359       }
1360     }
1361   };
1362
1363   Storable* TableView_i::Create (VISU::Table_ptr theTable)
1364   {
1365     if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1366     if (!theTable->_is_nil()) {
1367       VISU::Table_i* table =
1368         dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1369       if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1370
1371       myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1372       if (myView)
1373         return this;
1374     }
1375     return NULL;
1376   }
1377
1378   TableView_i::~TableView_i()
1379   {
1380     if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1381     delete myView;
1382   }
1383
1384   void TableView_i::SetTitle (const char* theTitle)
1385   {
1386     ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1387                      (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
1388   }
1389
1390   char* TableView_i::GetTitle()
1391   {
1392     //jfa: may be need to be enclosed in SALOME_Event?
1393     return CORBA::string_dup(myView->caption().latin1());
1394   }
1395
1396   void TableView_i::Close()
1397   {
1398     //jfa: may be need to be enclosed in SALOME_Event?
1399     myView->close();
1400   }
1401
1402
1403   //===========================================================================
1404   int View3D_i::myNbViewParams = 0;
1405   const string View3D_i::myComment = "VIEW3D";
1406   const char* View3D_i::GetComment() const { return myComment.c_str();}
1407
1408   QString View3D_i::GenerateViewParamsName()
1409   {
1410     return VISU::GenerateName("ViewParams", ++myNbViewParams);
1411   }
1412
1413   View3D_i::View3D_i (SalomeApp_Application* theApplication)
1414     : View_i(theApplication, NULL)
1415   {
1416     if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1417     if (theApplication) {
1418       myViewManager = ProcessEvent(new TNewSpecViewEvent<SVTK_Viewer>(theApplication));
1419     }
1420   }
1421
1422   struct TCreateView3dEvent: public SALOME_Event
1423   {
1424     SUIT_ViewManager* myViewManager;
1425     int               myNew;
1426
1427     typedef SUIT_ViewWindow* TResult;
1428     TResult myResult;
1429
1430     TCreateView3dEvent (SUIT_ViewManager* theViewManager,
1431                         const int         theNew):
1432       myViewManager(theViewManager),
1433       myNew(theNew),
1434       myResult(NULL)
1435     {}
1436
1437     virtual
1438     void
1439     Execute()
1440     {
1441       if (myNew) {
1442         myResult = myViewManager->createViewWindow();
1443       } else {
1444         myResult = myViewManager->getActiveView();
1445       }
1446     }
1447   };
1448
1449   Storable* View3D_i::Create (int theNew)
1450   {
1451     if (MYDEBUG) MESSAGE("View3D_i::Create");
1452     myViewWindow = ProcessEvent(new TCreateView3dEvent(myViewManager, theNew));
1453     return this;
1454   }
1455
1456   void View3D_i::Update()
1457   {
1458     class TEvent: public SALOME_Event
1459     {
1460       SUIT_ViewWindow* myViewWindow;
1461     public:
1462       TEvent(SUIT_ViewWindow* theStudyFrame):
1463         myViewWindow(theStudyFrame)
1464       {}
1465       virtual void Execute()
1466       {
1467         SVTK_ViewWindow* vf = GetViewWindow(myViewWindow);
1468         vtkRenderer* Renderer = vf->getRenderer();
1469         vtkActorCollection* theActors = Renderer->GetActors();
1470         theActors->InitTraversal();
1471         while (vtkActor *anAct = theActors->GetNextActor()) {
1472           if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
1473             VISU::Prs3d_i* aPrs3d  = anActor->GetPrs3d();
1474             if (anActor->GetVisibility() && aPrs3d) {
1475               aPrs3d->Update();
1476               aPrs3d->UpdateActor(anActor);
1477             }
1478           }
1479         }
1480         RepaintView(myViewWindow);
1481       }
1482     };
1483     ProcessVoidEvent(new TEvent(myViewWindow));
1484   }
1485
1486   bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1487   {
1488     MESSAGE("View3D_i::SaveViewParams()");
1489     _PTR(Study) aCStudy;
1490     if (SUIT_Study* aSStudy = theViewManager->study()) {
1491       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1492         aCStudy = aStudy->studyDS();
1493       }
1494     }
1495     if (!aCStudy)
1496       return false;
1497
1498     if (theName) {
1499       std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1500       _PTR(GenericAttribute) anAttr;
1501       int iEnd = aList.size();
1502       for (int i = 0; i < iEnd; i++) {
1503         _PTR(SObject) anObj = aList[i];
1504         string anEntry = anObj->GetID();
1505         if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1506         if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1507           _PTR(AttributeComment) aCmnt (anAttr);
1508           string aComm (aCmnt->Value());
1509           if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1510           if (aComm.compare(View3D_i::myComment) >= 0) {
1511             aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1512             return true;
1513           }
1514         }
1515       }
1516     }
1517     _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1518     string aSComponentEntry = aSComponent->GetID();
1519     string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
1520                                       ToString(theViewManager->getActiveView()).c_str());
1521     return true;
1522   }
1523
1524   class TSaveViewParamsEvent: public SALOME_Event
1525   {
1526     SUIT_ViewManager* myViewManager;
1527     const char*       myName;
1528   public:
1529     TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1530                           const char*       theName):
1531       myViewManager(theViewManager),
1532       myName(theName)
1533     {}
1534
1535     virtual void Execute()
1536     {
1537       myResult = View3D_i::SaveViewParams(myViewManager, myName);
1538     }
1539     typedef CORBA::Boolean TResult;
1540     TResult myResult;
1541   };
1542
1543   CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
1544   {
1545     return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
1546   }
1547
1548   bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1549   {
1550     _PTR(Study) aCStudy;
1551     if (SUIT_Study* aSStudy = theViewManager->study()) {
1552       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1553         aCStudy = aStudy->studyDS();
1554       }
1555     }
1556     if (!aCStudy)
1557       return false;
1558
1559     std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1560     _PTR(GenericAttribute) anAttr;
1561     int iEnd = aList.size();
1562     if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1563     for (int i = 0; i < iEnd; i++) {
1564       _PTR(SObject) anObj = aList[i];
1565       string anEntry = anObj->GetID();
1566       if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1567       if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1568         _PTR(AttributeComment) aCmnt (anAttr);
1569         QString strIn(aCmnt->Value().c_str());
1570         Storable::TRestoringMap aMap;
1571         Storable::StrToMap(strIn, aMap);
1572         if (Storable::FindValue(aMap, "myComment").compare
1573             (View3D_i::myComment.c_str()) >= 0) {
1574           if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
1575           Restore(theViewManager->getActiveView(), aMap);
1576           return true;
1577         }
1578       }
1579     }
1580     return false;
1581   }
1582
1583   class TRestoreViewParamsEvent: public SALOME_Event
1584   {
1585     SUIT_ViewManager* myViewManager;
1586     const char*       myName;
1587   public:
1588     TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1589                              const char*       theName):
1590       myViewManager(theViewManager),
1591       myName(theName)
1592     {}
1593
1594     virtual void Execute()
1595     {
1596       myResult = View3D_i::RestoreViewParams(myViewManager, myName);
1597     }
1598     typedef CORBA::Boolean TResult;
1599     TResult myResult;
1600   };
1601
1602   CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
1603   {
1604     return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
1605   }
1606
1607   void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame,
1608                           const Storable::TRestoringMap& theMap)
1609   {
1610     SALOMEDS::Color aColor;
1611     aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1612     aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1613     aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1614
1615     double aPosition[3];
1616     aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1617     aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1618     aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1619
1620     double aFocalPnt[3];
1621     aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1622     aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1623     aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1624
1625     double aViewUp[3];
1626     aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1627     aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1628     aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1629
1630     double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1631
1632     double aScaleFactor[3];
1633     aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1634     aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1635     aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1636
1637     SetBackground(theStudyFrame,aColor);
1638     SetPointOfView(theStudyFrame,aPosition);
1639     SetViewUp(theStudyFrame,aViewUp);
1640     SetFocalPoint(theStudyFrame,aFocalPnt);
1641     SetParallelScale(theStudyFrame,aParallelScale);
1642     ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1643     ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1644     ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1645   }
1646
1647
1648   string View3D_i::ToString (SUIT_ViewWindow* theStudyFrame)
1649   {
1650     ostringstream strOut;
1651     Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1652     ToStream(theStudyFrame,strOut);
1653     strOut<<ends;
1654     if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1655     return strOut.str();
1656   }
1657
1658   void View3D_i::ToStream (SUIT_ViewWindow* theStudyFrame, std::ostringstream& theStr)
1659   {
1660     Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1661
1662     float backint[3];
1663     GetRenderer(theStudyFrame)->GetBackground(backint);
1664     Storable::DataToStream(theStr,"myColor.R",backint[0]);
1665     Storable::DataToStream(theStr,"myColor.G",backint[1]);
1666     Storable::DataToStream(theStr,"myColor.B",backint[2]);
1667
1668     double aPosition[3];
1669     GetPointOfView(theStudyFrame,aPosition);
1670     Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1671     Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1672     Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1673
1674     double aFocalPnt[3];
1675     GetFocalPoint(theStudyFrame,aFocalPnt);
1676     Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1677     Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1678     Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1679
1680     double aViewUp[3];
1681     GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1682     Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1683     Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1684     Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1685
1686     Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1687
1688     double aScaleFactor[3];
1689     GetViewWindow(theStudyFrame)->GetScale(aScaleFactor);
1690     Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1691     Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1692     Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1693   }
1694
1695   void View3D_i::ToStream(std::ostringstream& theStr)
1696   {
1697     ToStream(myViewWindow,theStr);
1698   }
1699
1700   void View3D_i::Close()
1701   {
1702     //jfa: may be need to be enclosed in SALOME_Event?
1703     myViewWindow->close();
1704   }
1705
1706   View3D_i::~View3D_i()
1707   {
1708     if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1709   }
1710
1711   void View3D_i::SetTitle (const char* theTitle)
1712   {
1713     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1714                      (myViewWindow,&SUIT_ViewWindow::setCaption,QString(theTitle)));
1715   }
1716
1717   char* View3D_i::GetTitle()
1718   {
1719     //jfa: may be need to be enclosed in SALOME_Event?
1720     return CORBA::string_dup(myViewWindow->caption().latin1());
1721   }
1722
1723   void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame,
1724                                 const SALOMEDS::Color& theColor)
1725   {
1726     //jfa: may be need to be enclosed in SALOME_Event?
1727     int aColor[3];
1728     aColor[0] = int(255.0*theColor.R);
1729     aColor[1] = int(255.0*theColor.G);
1730     aColor[2] = int(255.0*theColor.B);
1731     QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1732     GetViewWindow(theStudyFrame)->setBackgroundColor(aNewColor);
1733   }
1734
1735   SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame)
1736   {
1737     //jfa: may be need to be enclosed in SALOME_Event?
1738     SALOMEDS::Color aColor;
1739     float backint[3];
1740     GetRenderer(theStudyFrame)->GetBackground(backint);
1741     aColor.R = backint[0];  aColor.G = backint[1];  aColor.B = backint[2];
1742     return aColor;
1743   }
1744
1745   class TUpdateViewerEvent: public SALOME_Event
1746   {
1747     SUIT_ViewWindow* myViewWindow;
1748     Prs3d_i* myPrs3d;
1749     int myDisplaing;
1750   public:
1751     TUpdateViewerEvent(SUIT_ViewWindow* theStudyFrame,
1752                        Prs3d_i* thePrs3d,
1753                        int theDisplaing):
1754       myViewWindow(theStudyFrame),
1755       myPrs3d(thePrs3d),
1756       myDisplaing(theDisplaing)
1757     {}
1758     virtual void Execute(){
1759       UpdateViewer(myViewWindow,myDisplaing,myPrs3d);
1760     }
1761   };
1762
1763   void View3D_i::EraseAll()
1764   {
1765     if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1766     ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eEraseAll));
1767   }
1768
1769   void View3D_i::DisplayAll()
1770   {
1771     if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1772     ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eDisplayAll));
1773   }
1774
1775   void View3D_i::Erase (PrsObject_ptr thePrsObj)
1776   {
1777     if(MYDEBUG) MESSAGE("View3D_i::Erase");
1778     CORBA::Object_ptr anObj = thePrsObj;
1779     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1780       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eErase));
1781     }
1782   }
1783
1784   void View3D_i::Display (PrsObject_ptr thePrsObj)
1785   {
1786     if(MYDEBUG) MESSAGE("View3D_i::Display");
1787     CORBA::Object_ptr anObj = thePrsObj;
1788     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1789       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplay));
1790     }
1791   }
1792
1793   void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
1794   {
1795     if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1796     CORBA::Object_ptr anObj = thePrsObj;
1797     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1798       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplayOnly));
1799     }
1800   }
1801
1802   void View3D_i::FitAll()
1803   {
1804     ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1805                      (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll));
1806     Update();
1807   }
1808
1809   void View3D_i::SetView (VISU::View3D::ViewType theType)
1810   {
1811     switch (theType) {
1812     case VISU::View3D::FRONT :
1813       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1814                        (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFrontView));
1815       break;
1816     case VISU::View3D::BACK :
1817       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1818                        (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView));
1819       break;
1820     case VISU::View3D::LEFT :
1821       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1822                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView));
1823       break;
1824     case VISU::View3D::RIGHT :
1825       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1826                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView));
1827       break;
1828     case VISU::View3D::TOP :
1829       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1830                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView));
1831       break;
1832     case VISU::View3D::BOTTOM :
1833       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1834                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView));
1835       break;
1836     }
1837     Update();
1838   }
1839
1840   class TSet3DViewParamEvent: public SALOME_Event
1841   {
1842   public:
1843     typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, const CORBA::Double theParam[3]);
1844     TSet3DViewParamEvent (TFun theFun,
1845                           SUIT_ViewWindow* theStudyFrame,
1846                           const CORBA::Double theParam[3]):
1847       myFun(theFun),
1848       myViewWindow(theStudyFrame),
1849       myParam(theParam)
1850     {}
1851     virtual void Execute(){
1852       myFun(myViewWindow,myParam);
1853     }
1854   private:
1855     TFun myFun;
1856     SUIT_ViewWindow* myViewWindow;
1857     const CORBA::Double* myParam;
1858   };
1859
1860   void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame,
1861                                  const CORBA::Double thePosition[3])
1862   {
1863     //jfa: may be need to be enclosed in SALOME_Event?
1864     GetCamera(theStudyFrame)->SetPosition(thePosition);
1865   }
1866
1867   void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
1868   {
1869     if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1870     ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myViewWindow,thePosition));
1871   }
1872
1873   void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame,
1874                                  CORBA::Double thePosition[3])
1875   {
1876     //jfa: may be need to be enclosed in SALOME_Event?
1877     GetCamera(theStudyFrame)->GetPosition(thePosition);
1878   }
1879
1880   VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
1881   {
1882     //jfa: may be need to be enclosed in SALOME_Event?
1883     if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1884     CORBA::Double aPosition[3];
1885     GetPointOfView(myViewWindow,aPosition);
1886     return VISU::View3D::XYZ_dup(aPosition);
1887   }
1888
1889   void View3D_i::SetViewUp (SUIT_ViewWindow* theStudyFrame,
1890                             const CORBA::Double theViewUp[3])
1891   {
1892     GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1893   }
1894
1895   void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
1896   {
1897     if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1898     ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myViewWindow,theViewUp));
1899   }
1900
1901   void View3D_i::GetViewUp (SUIT_ViewWindow* theStudyFrame,
1902                             CORBA::Double theViewUp[3])
1903   {
1904     GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1905   }
1906
1907   VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
1908   {
1909     //jfa: may be need to be enclosed in SALOME_Event?
1910     if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1911     CORBA::Double aViewUp[3];
1912     GetCamera(myViewWindow)->GetViewUp(aViewUp);
1913     return VISU::View3D::XYZ_dup(aViewUp);
1914   }
1915
1916   void View3D_i::SetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1917                                 const CORBA::Double theFocalPnt[3])
1918   {
1919     GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1920   }
1921
1922   void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
1923   {
1924     if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1925     ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myViewWindow,theCoord));
1926   }
1927
1928
1929   void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1930                                 CORBA::Double theFocalPnt[3])
1931   {
1932     GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1933   }
1934
1935   VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
1936   {
1937     //jfa: may be need to be enclosed in SALOME_Event?
1938     if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1939     CORBA::Double aFocalPnt[3];
1940     GetFocalPoint(myViewWindow,aFocalPnt);
1941     return VISU::View3D::XYZ_dup(aFocalPnt);
1942   }
1943
1944   class TSetViewParamEvent: public SALOME_Event
1945   {
1946   public:
1947     typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, CORBA::Double theParam);
1948     TSetViewParamEvent (TFun theFun,
1949                         SUIT_ViewWindow* theStudyFrame,
1950                         CORBA::Double theParam):
1951       myFun(theFun),
1952       myViewWindow(theStudyFrame),
1953       myParam(theParam)
1954     {}
1955     virtual void Execute()
1956     {
1957       myFun(myViewWindow,myParam);
1958     }
1959   private:
1960     TFun myFun;
1961     SUIT_ViewWindow* myViewWindow;
1962     CORBA::Double myParam;
1963   };
1964
1965   void View3D_i::SetParallelScale (SUIT_ViewWindow* theStudyFrame,
1966                                    CORBA::Double theScale)
1967   {
1968     GetCamera(theStudyFrame)->SetParallelScale(theScale);
1969   }
1970
1971   void View3D_i::SetParallelScale (CORBA::Double theScale)
1972   {
1973     if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1974     ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myViewWindow,theScale));
1975   }
1976
1977   CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theStudyFrame)
1978   {
1979     return GetCamera(theStudyFrame)->GetParallelScale();
1980   }
1981
1982   CORBA::Double View3D_i::GetParallelScale()
1983   {
1984     //jfa: may be need to be enclosed in SALOME_Event?
1985     if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1986     return GetParallelScale(myViewWindow);
1987   }
1988
1989   void View3D_i::ScaleView (SUIT_ViewWindow* theStudyFrame,
1990                             VISU::View3D::Axis theAxis, CORBA::Double theParam)
1991   {
1992     SVTK_ViewWindow* aViewFrame = GetViewWindow(theStudyFrame);
1993     double aScaleFactor[3];
1994     aViewFrame->GetScale(aScaleFactor);
1995     aScaleFactor[theAxis] = theParam;
1996     aViewFrame->SetScale(aScaleFactor);
1997   }
1998
1999   void SetScaleView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theScale[3])
2000   {
2001     double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2002     GetViewWindow(theStudyFrame)->SetScale(aScale);
2003   }
2004
2005   void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2006   {
2007     if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2008     double aScale[3];
2009     GetViewWindow(myViewWindow)->GetScale(aScale);
2010     aScale[theAxis] = theParam;
2011     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
2012   }
2013
2014   void View3D_i::RemoveScale()
2015   {
2016     if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2017     double aScale[3] = {1.0, 1.0, 1.0};
2018     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
2019   }
2020 }