]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_View_i.cc
Salome HOME
73b1d60b287d1c5e534b213844544b6044e16198
[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
46 #include "SVTK_ViewWindow.h"
47 #include "SVTK_ViewModel.h"
48 #include "SPlot2d_ViewModel.h"
49
50 #include "Plot2d_ViewFrame.h"
51 #include "Plot2d_ViewModel.h"
52
53 #include "SalomeApp_Application.h"
54 #include "SalomeApp_Study.h"
55
56 #include <qworkspace.h>
57
58 #include <vtkCamera.h>
59 #include <vtkRenderer.h>
60
61 using namespace std;
62
63 #ifdef _DEBUG_
64 static int MYDEBUG = 0;
65 #else
66 static int MYDEBUG = 0;
67 #endif
68
69 namespace VISU{
70
71   typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
72
73   View_i::
74   View_i(SalomeApp_Application *theApplication,
75          SUIT_ViewManager* theViewManager):
76     myApplication(theApplication),
77     myWorkspace(NULL),
78     myViewManager(theViewManager)
79   {
80     if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
81     if(STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())){
82       myWorkspace = aDesktop->workspace();
83     }
84   }
85
86   View_i::
87   ~View_i()
88   {
89     if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
90   }
91
92
93   struct TApplicationEvent: public SALOME_Event
94   {
95     SalomeApp_Application* myApplication;
96
97     TApplicationEvent(SalomeApp_Application* theApplication):
98       myApplication(theApplication)
99     {}
100   };
101
102
103   void
104   View_i::
105   ShowPart(VISU::View::ViewRepresentation theViewRepresentation,
106            CORBA::Boolean theState)
107   {
108     struct TEvent: public TApplicationEvent
109     {
110       VISU::View::ViewRepresentation myViewRepresentation;
111       CORBA::Boolean myState;
112
113       TEvent(SalomeApp_Application* theApplication,
114              VISU::View::ViewRepresentation theViewRepresentation,
115              CORBA::Boolean theState):
116         TApplicationEvent(theApplication),
117         myViewRepresentation(theViewRepresentation),
118         myState(theState)
119       {}
120
121       virtual
122       void
123       Execute()
124       {
125         switch(myViewRepresentation){
126         case VISU::View::OBJECTBROWSER:
127           myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState);
128           break;
129         case VISU::View::PYTHON:
130           myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState);
131           break;
132         case VISU::View::MESSAGES:
133           myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState);
134           break;
135         case VISU::View::VIEWER:{
136           ViewManagerList aViewManagerList = myApplication->viewManagers();
137           // to do something
138           // ...
139           break;
140         }}
141       }
142     };
143
144     ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
145   }
146
147
148   struct TPartShownEvent: public TApplicationEvent
149   {
150     VISU::View::ViewRepresentation myViewRepresentation;
151     typedef bool TResult;
152     TResult myResult;
153
154     TPartShownEvent(SalomeApp_Application* theApplication,
155                     VISU::View::ViewRepresentation theViewRepresentation):
156       TApplicationEvent(theApplication),
157       myViewRepresentation(theViewRepresentation),
158       myResult(false)
159     {}
160
161     virtual
162     void
163     Execute()
164     {
165       switch(myViewRepresentation){
166       case VISU::View::OBJECTBROWSER:
167         myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser);
168         break;
169       case VISU::View::PYTHON:
170         myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole);
171         break;
172       case VISU::View::MESSAGES:
173         myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow);
174         break;
175       case VISU::View::VIEWER:{
176         ViewManagerList aViewManagerList = myApplication->viewManagers();
177         // to do something
178         // ...
179         break;
180       }}
181     }
182   };
183
184
185   CORBA::Boolean
186   View_i::
187   IsPartShown(VISU::View::ViewRepresentation theViewRepresentation)
188   {
189     return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
190   }
191
192
193   struct TSetViewSize: public SALOME_Event
194   {
195     SUIT_ViewWindow* myViewWindow;
196     typedef void (QRect::* TAction)(int);
197     TAction myAction;
198     CORBA::Long mySize;
199
200   public:
201     TSetViewSize(SUIT_ViewWindow* theViewWindow,
202                  TAction theAction,
203                  CORBA::Long theSize):
204       myViewWindow(theViewWindow),
205       myAction(theAction),
206       mySize(theSize)
207     {}
208
209     virtual
210     void
211     Execute()
212     {
213       if (QWidget* aParent = myViewWindow->parentWidget(true)) {
214         QRect aQRect = aParent->frameGeometry();
215         (aQRect.*myAction)(mySize);
216         aParent->setGeometry(aQRect);
217       }
218     }
219   };
220
221
222   void
223   View_i::
224   SetViewWidth(CORBA::Long theWidth)
225   {
226     ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
227   }
228
229
230   void
231   View_i::
232   SetViewHeight(CORBA::Long theHeight)
233   {
234     ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
235   }
236
237
238   struct TGetViewSize: public SALOME_Event
239   {
240     SUIT_ViewWindow* myViewWindow;
241
242     typedef int (QRect::* TAction)() const;
243     TAction myAction;
244
245     typedef CORBA::Long TResult;
246     TResult myResult;
247
248   public:
249     TGetViewSize(SUIT_ViewWindow* theViewWindow,
250                  TAction theAction):
251       myViewWindow(theViewWindow),
252       myAction(theAction)
253     {}
254
255     virtual
256     void
257     Execute()
258     {
259       if(QWidget* aParent = myViewWindow->parentWidget(true)){
260         QRect aQRect = aParent->frameGeometry();
261         myResult = (aQRect.*myAction)();
262       }
263     }
264   };
265
266
267   CORBA::Long
268   View_i::
269   GetViewWidth()
270   {
271     return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
272   }
273
274   CORBA::Long
275   View_i::
276   GetViewHeight()
277   {
278     return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
279   }
280
281
282   class TWorkspaceEvent: public SALOME_Event
283   {
284   protected:
285     QWidget* myViewWindow;
286     QWidget* myWorkspace;
287
288   public:
289     TWorkspaceEvent(QWidget* theViewWindow,
290                     QWidget* theWorkspace):
291       myViewWindow(theViewWindow),
292       myWorkspace(theWorkspace)
293     {}
294   };
295
296
297   class TAlignEvent: public TWorkspaceEvent
298   {
299   protected:
300     Qt::AlignmentFlags myAligment;
301
302   public:
303     TAlignEvent(QWidget* theViewWindow,
304                 QWidget* theWorkspace,
305                 Qt::AlignmentFlags theAligment):
306       TWorkspaceEvent(theViewWindow,theWorkspace),
307       myAligment(theAligment)
308     {}
309
310     virtual
311     void
312     Execute()
313     {
314       if(QWidget* aParent = myViewWindow->parentWidget(true))
315         SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
316     }
317   };
318
319
320   void
321   View_i::
322   SetViewPositionHorizontal(VISU::View::ViewPosition theViewPosition)
323   {
324     if(myWorkspace){
325       switch(theViewPosition){
326       case VISU::View::LEFT:
327         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
328         break;
329       case VISU::View::CENTER:
330         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
331         break;
332       case VISU::View::RIGHT:
333         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
334         break;
335       }
336     }
337   }
338
339
340   void
341   View_i::
342   SetViewPositionVertical(VISU::View::ViewPosition theViewPosition)
343   {
344     if(myWorkspace){
345       switch(theViewPosition){
346       case VISU::View::TOP:
347         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
348         break;
349       case VISU::View::CENTER:
350         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
351         break;
352       case VISU::View::BOTTOM:
353         ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
354         break;
355       }
356     }
357   }
358
359
360   class TXYEvent: public TWorkspaceEvent
361   {
362   protected:
363     CORBA::Double myX, myY;
364
365   public:
366     TXYEvent(QWidget* theViewWindow,
367              QWidget* theWorkspace,
368              CORBA::Double theX,
369              CORBA::Double theY):
370       TWorkspaceEvent(theViewWindow,theWorkspace),
371       myX(theX),
372       myY(theY)
373     {}
374   };
375
376
377   void
378   View_i::
379   SetRelativePosition(CORBA::Double theX, CORBA::Double theY)
380   {
381     struct TEvent: public TXYEvent
382     {
383     public:
384       TEvent(QWidget* theViewWindow,
385              QWidget* theWorkspace,
386              CORBA::Double theX,
387              CORBA::Double theY):
388         TXYEvent(theViewWindow,theWorkspace,theX,theY)
389       {}
390
391       virtual
392       void
393       Execute()
394       {
395         if(QWidget* aParent = myViewWindow->parentWidget(true))
396           aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
397       }
398     };
399
400     if(myWorkspace)
401       ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
402   }
403
404   void
405   View_i::
406   SetRelativeSize(CORBA::Double theX, CORBA::Double theY)
407   {
408     struct TEvent: public TXYEvent
409     {
410     public:
411       TEvent(QWidget* theViewWindow,
412              QWidget* theWorkspace,
413              CORBA::Double theX,
414              CORBA::Double theY):
415         TXYEvent(theViewWindow,theWorkspace,theX,theY)
416       {}
417
418       virtual
419       void
420       Execute()
421       {
422         if(QWidget* aParent = myViewWindow->parentWidget(true))
423           aParent->setGeometry(aParent->x(),
424                                aParent->y(),
425                                int(myX*myWorkspace->width()),
426                                int(myY*myWorkspace->height()));
427       }
428     };
429
430     if(myWorkspace)
431       ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
432   }
433
434   void
435   View_i::
436   SetBackground(const SALOMEDS::Color& theColor)
437   {
438     struct TEvent: public SALOME_Event
439     {
440       QWidget* myWidget;
441       SALOMEDS::Color myColor;
442     public:
443       TEvent(QWidget* theWidget,
444              const SALOMEDS::Color& theColor):
445         myWidget(theWidget),
446         myColor(theColor)
447       {}
448       virtual void Execute(){
449         int aColor[3];
450         aColor[0] = int(255.0*myColor.R);
451         aColor[1] = int(255.0*myColor.G);
452         aColor[2] = int(255.0*myColor.B);
453         myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2]));
454       }
455     };
456
457     ProcessVoidEvent(new TEvent(myViewWindow,theColor));
458   }
459
460
461   struct TBackgroundEvent: public SALOME_Event
462   {
463     QWidget* myWidget;
464     typedef SALOMEDS::Color TResult;
465     TResult myResult;
466
467     TBackgroundEvent(QWidget* theWidget):
468       myWidget(theWidget)
469     {}
470
471     virtual
472     void
473     Execute()
474     {
475       const QColor& aColor = myWidget->backgroundColor();
476       myResult.R = aColor.red()/255.0;
477       myResult.G = aColor.green()/255.0;
478       myResult.B = aColor.blue()/255.0;
479     }
480   };
481
482   SALOMEDS::Color
483   View_i::
484   GetBackground()
485   {
486     return ProcessEvent(new TBackgroundEvent(myViewWindow));
487   }
488
489   void
490   View_i::
491   Minimize()
492   {
493     ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMinimized));
494   }
495
496   void
497   View_i::
498   Restore()
499   {
500     ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showNormal));
501   }
502
503   void
504   View_i::
505   Maximize()
506   {
507     ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMaximized));
508   }
509
510   void
511   View_i::
512   EraseAll()
513   {}
514
515   void
516   View_i::
517   DisplayAll()
518   {}
519
520   void
521   View_i::
522   Erase(PrsObject_ptr thePrsObj)
523   {}
524
525   void
526   View_i::
527   Display(PrsObject_ptr thePrsObj)
528   {}
529
530   void
531   View_i::
532   DisplayOnly(PrsObject_ptr thePrsObj)
533   {}
534
535   void
536   View_i::
537   Update()
538   {}
539
540   CORBA::Boolean
541   View_i::SavePicture(const char* theFileName)
542   {
543     return false;
544   }
545
546   const char*
547   View_i::
548   GetComment() const
549   {
550     return "";
551   }
552   void
553   View_i::
554   ToStream(std::ostringstream& theStr)
555   {}
556
557
558   //================= OLD CODE ===================
559
560   //QAD_Study* CheckStudy (SALOMEDS::Study_ptr theStudy)
561   //{
562   //  //QAD_Desktop* aDesktop = QAD_Application::getDesktop();
563   //  //QAD_Study* aStudy = aDesktop->findStudy(theStudy);
564   //  if (!aStudy) {
565   //    CORBA::String_var aName = theStudy->Name();
566   //    aFileInfo.setFile(aName.in());
567   //    if (aFileInfo.exists())
568   //      aStudy = aDesktop->loadStudy(aFileInfo.baseName());
569   //    else
570   //      aStudy = aDesktop->loadStudy(aName.in());
571   //    if (!aStudy) {
572   //      MESSAGE("CheckStudy()::ERROR: Can't load study");
573   //    }
574   //  }
575   //  return aStudy;
576   //}
577
578   class TSavePictureEvent: public SALOME_Event
579   {
580     QWidget* myWidget;
581     const char* myFileName;
582   public:
583     typedef CORBA::Boolean TResult;
584     TResult myResult;
585     TSavePictureEvent (QWidget* theWidget, const char* theFileName)
586       : myWidget(theWidget),
587         myFileName(theFileName),
588         myResult(false)
589     {
590     }
591
592     virtual void Execute()
593     {
594       if (myWidget) {
595         QPixmap px = QPixmap::grabWindow(myWidget->winId());
596         if (!QString(myFileName).isNull()) {
597           QString fmt = SUIT_Tools::extension(myFileName).upper();
598           if (fmt.isEmpty())
599             fmt = QString("BMP"); // default format
600           if (fmt == "JPG")
601             fmt = "JPEG";
602           myResult = px.save(myFileName, fmt.latin1());
603         }
604       }
605     }
606   };
607
608
609   //===========================================================================
610   XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
611     : View_i(theApplication, NULL)
612   {
613     if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
614     if (theApplication) {
615       myViewManager = theApplication->getViewManager(Plot2d_Viewer::Type(), true);
616     }
617   }
618
619   Storable* XYPlot_i::Create (int theNew)
620   {
621     if (theNew) {
622       myViewWindow = myViewManager->createViewWindow();
623     } else {
624       myViewWindow = myViewManager->getActiveView();
625     }
626     ////myView = dynamic_cast<Plot2d_ViewFrame*>(myViewWindow->getRightFrame()->getViewFrame());
627     //SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(myViewManager->getViewModel());
628     //myView = aView->getActiveViewFrame();
629     if (myViewWindow) {
630       Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myViewWindow);
631       if (aPlot2dVW) {
632         myView = aPlot2dVW->getViewFrame();
633         if (myView) {
634           myView->Repaint();
635         }
636       }
637     }
638     return this;
639   }
640
641   void XYPlot_i::Update()
642   {
643     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
644   }
645
646   void XYPlot_i::Close()
647   {
648     myViewWindow->close();
649   }
650
651   XYPlot_i::~XYPlot_i() {
652     if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
653   }
654
655   void XYPlot_i::SetTitle (const char* theTitle)
656   {
657     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
658                      (myViewWindow, &SUIT_ViewWindow::setCaption, QString(theTitle)));
659   }
660   char* XYPlot_i::GetTitle()
661   {
662     return CORBA::string_dup(myViewWindow->caption().latin1());
663   }
664
665   void XYPlot_i::SetSubTitle (const char* theTitle)
666   {
667     ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
668                      (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
669   }
670
671   char* XYPlot_i::GetSubTitle()
672   {
673     return CORBA::string_dup(myView->getTitle());
674   }
675
676   void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
677   {
678     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
679                      (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
680   }
681
682   VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
683   {
684     return (VISU::XYPlot::CurveType)myView->getCurveType();
685   }
686
687   void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
688   {
689     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
690                      (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
691   }
692
693   CORBA::Long XYPlot_i::GetMarkerSize()
694   {
695     return myView->getMarkerSize();
696   }
697
698   class TEnableGridEvent: public SALOME_Event
699   {
700   public:
701     typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
702     TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun,
703                       CORBA::Boolean theMajor, CORBA::Long theNumMajor,
704                       CORBA::Boolean theMinor, CORBA::Long theNumMinor):
705       myView(theView), myFun(theFun),
706       myMajor(theMajor), myNumMajor(theNumMajor),
707       myMinor(theMinor), myNumMinor(theNumMinor)
708     {}
709
710     virtual void Execute()
711     {
712       (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true);
713     }
714   protected:
715     Plot2d_ViewFrame* myView;
716     TFun myFun;
717     CORBA::Boolean myMajor, myNumMajor;
718     CORBA::Boolean myMinor, myNumMinor;
719   };
720
721   void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
722                               CORBA::Boolean theMinor, CORBA::Long theNumMinor)
723   {
724     ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
725                                           theMajor,theNumMajor,theMinor,theNumMinor));
726   }
727   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
728                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
729   {
730     //jfa tmp:ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
731     //jfa tmp:                                      theMajor,theNumMajor,theMinor,theNumMinor));
732   }
733
734   class TSetScaleModeEvent: public SALOME_Event
735   {
736   public:
737     typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
738     TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
739       myView(theView), myFun(theFun), myScaling(theScaling)
740     {}
741
742     virtual void Execute()
743     {
744       (myView->*myFun)(myScaling,true);
745     }
746   protected:
747     Plot2d_ViewFrame* myView;
748     TFun myFun;
749     int myScaling;
750   };
751
752   void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
753   {
754     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
755                                             theScaling == VISU::LOGARITHMIC));
756   }
757
758   VISU::Scaling XYPlot_i::GetHorScaling()
759   {
760     return (VISU::Scaling)myView->getHorScaleMode();
761   }
762
763   void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
764   {
765     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
766                                             theScaling == VISU::LOGARITHMIC));
767   }
768
769   VISU::Scaling XYPlot_i::GetVerScaling()
770   {
771     return (VISU::Scaling)myView->getVerScaleMode();
772   }
773
774   class TSetTitleEvent: public SALOME_Event
775   {
776   public:
777     //typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
778     typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, Plot2d_ViewFrame::ObjectType, bool = true);
779     //TSetTitleEvent (Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
780     TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
781       //myView(theView), myFun(theFun), myTitle(theTitle)
782       myView(theView), myType(theType), myTitle(theTitle)
783     {}
784     virtual void Execute()
785     {
786       //(myView->*myFun)(true,myTitle,myType);
787       myView->setTitle(true,myTitle,myType);
788     }
789   protected:
790     Plot2d_ViewFrame* myView;
791     //TFun myFun;
792     Plot2d_ViewFrame::ObjectType myType;
793     const char* myTitle;
794   };
795
796   void XYPlot_i::SetXTitle (const char* theTitle)
797   {
798     //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setXTitle, theTitle));
799     ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
800   }
801   char* XYPlot_i::GetXTitle()
802   {
803     //return CORBA::string_dup(myView->getXTitle());
804     return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
805   }
806
807   void XYPlot_i::SetYTitle (const char* theTitle)
808   {
809     //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setYTitle, theTitle));
810     ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
811   }
812   char* XYPlot_i::GetYTitle()
813   {
814     //return CORBA::string_dup(myView->getYTitle());
815     return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
816   }
817
818   void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
819   {
820     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
821                      (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
822   }
823
824   class TXYPlotViewEvent: public SALOME_Event
825   {
826     SalomeApp_Application* myApplication;
827     Plot2d_ViewFrame*      myView;
828     PrsObject_ptr          myPrsObj;
829     int                    myDisplaing;
830
831   public:
832     TXYPlotViewEvent(SalomeApp_Application* theApplication,
833                      Plot2d_ViewFrame*      theView,
834                      PrsObject_ptr          thePrsObj,
835                      int                    theDisplaing)
836       : myApplication(theApplication),
837       myView(theView),
838       myPrsObj(thePrsObj),
839       myDisplaing(theDisplaing)
840     {
841     }
842
843     virtual void Execute()
844     {
845       // is it Curve ?
846       if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
847         UpdatePlot2d(myView,myDisplaing,aCurve);
848       }
849       // is it Container ?
850       if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
851         int nbCurves = aContainer->GetNbCurves();
852         for ( int i = 1; i <= nbCurves; i++ ) {
853           VISU::Curve_i* aCurve = aContainer->GetCurve( i );
854           if ( aCurve && aCurve->IsValid() ) {
855             UpdatePlot2d(myView,myDisplaing,aCurve);
856           }
857         }
858         myView->Repaint();
859       }
860       // is it Table ?
861       if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
862         _PTR(Study) aCStudy;
863         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
864           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
865             aCStudy = aStudy->studyDS();
866           }
867         }
868         if (!aCStudy) return;
869         _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
870         if (TableSO) {
871           _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
872           for (; Iter->More(); Iter->Next()) {
873             CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
874             if (!CORBA::is_nil(childObject)) {
875               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
876               if (!CORBA::is_nil(aCurve))
877                 UpdatePlot2d(myView, myDisplaing,
878                              dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
879             }
880           }
881           myView->Repaint();
882         }
883       }
884     }
885   };
886
887   void XYPlot_i::Display (PrsObject_ptr thePrsObj)
888   {
889     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
890   }
891
892   void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
893   {
894     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
895   }
896
897   void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
898   {
899     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
900   }
901
902   void XYPlot_i::EraseAll()
903   {
904     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
905   }
906
907   void XYPlot_i::FitAll()
908   {
909     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
910   }
911
912   CORBA::Boolean XYPlot_i::SavePicture (const char* theFileName)
913   {
914     return ProcessEvent(new TSavePictureEvent (myView->getViewWidget(),theFileName));
915   }
916
917
918   //===========================================================================
919   TableView_i::TableView_i (SalomeApp_Application* theApplication)
920     : View_i(theApplication, NULL)
921   {
922   }
923
924   Storable* TableView_i::Create (VISU::Table_ptr theTable)
925   {
926     if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
927     if (!theTable->_is_nil()) {
928       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
929       if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
930       if (table != NULL) {
931         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
932           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
933             if (_PTR(Study) aCStudy = aStudy->studyDS()) {
934               _PTR(SObject) aSObject = aCStudy->FindObjectID(table->GetObjectEntry());
935               if (aSObject) {
936                 myView = new VisuGUI_TableDlg (myApplication->desktop(),
937                                                aSObject,
938                                                false,
939                                                VisuGUI_TableDlg::ttAuto,
940                                                Qt::Vertical);
941                 myView->show();
942                 return this;
943               }
944             }
945           }
946         }
947       }
948     }
949     return NULL;
950   }
951
952   TableView_i::~TableView_i()
953   {
954     if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
955     delete myView;
956   }
957
958   void TableView_i::SetTitle (const char* theTitle)
959   {
960     ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
961                      (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
962   }
963
964   char* TableView_i::GetTitle()
965   {
966     return CORBA::string_dup(myView->caption().latin1());
967     return "";
968   }
969
970   void TableView_i::Close()
971   {
972     myView->close();
973   }
974
975
976   //===========================================================================
977   int View3D_i::myNbViewParams = 0;
978   const string View3D_i::myComment = "VIEW3D";
979   const char* View3D_i::GetComment() const { return myComment.c_str();}
980
981   QString View3D_i::GenerateViewParamsName()
982   {
983     return VISU::GenerateName("ViewParams", ++myNbViewParams);
984   }
985
986   View3D_i::View3D_i (SalomeApp_Application* theApplication)
987     : View_i(theApplication, NULL)
988   {
989     if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
990     if (theApplication) {
991       myViewManager = theApplication->getViewManager(SVTK_Viewer::Type(), true);
992     }
993   }
994
995   Storable* View3D_i::Create (int theNew)
996   {
997     if (MYDEBUG) MESSAGE("View3D_i::Create");
998     if (theNew) {
999       myViewWindow = myViewManager->createViewWindow();
1000     } else {
1001       myViewWindow = myViewManager->getActiveView();
1002     }
1003     return this;
1004   }
1005
1006   void View3D_i::Update()
1007   {
1008     class TEvent: public SALOME_Event
1009     {
1010       SUIT_ViewWindow* myViewWindow;
1011     public:
1012       TEvent(SUIT_ViewWindow* theStudyFrame):
1013         myViewWindow(theStudyFrame)
1014       {}
1015       virtual void Execute()
1016       {
1017         SVTK_ViewWindow* vf = GetViewWindow(myViewWindow);
1018         vtkRenderer* Renderer = vf->getRenderer();
1019         vtkActorCollection* theActors = Renderer->GetActors();
1020         theActors->InitTraversal();
1021         while (vtkActor *anAct = theActors->GetNextActor()) {
1022           if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
1023             VISU::Prs3d_i* aPrs3d  = anActor->GetPrs3d();
1024             if (anActor->GetVisibility() && aPrs3d) {
1025               aPrs3d->Update();
1026               aPrs3d->UpdateActor(anActor);
1027             }
1028           }
1029         }
1030         RepaintView(myViewWindow);
1031       }
1032     };
1033     ProcessVoidEvent(new TEvent(myViewWindow));
1034   }
1035
1036   CORBA::Boolean View3D_i::SavePicture (const char* theFileName)
1037   {
1038     //jfa tmp:return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(), theFileName));
1039     return false;
1040   }
1041
1042   bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1043   {
1044     _PTR(Study) aCStudy;
1045     if (SUIT_Study* aSStudy = theViewManager->study()) {
1046       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1047         aCStudy = aStudy->studyDS();
1048       }
1049     }
1050     if (!aCStudy)
1051       return false;
1052
1053     if (theName) {
1054       std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1055       _PTR(GenericAttribute) anAttr;
1056       int iEnd = aList.size();
1057       for (int i = 0; i < iEnd; i++) {
1058         _PTR(SObject) anObj = aList[i];
1059         string anEntry = anObj->GetID();
1060         if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1061         if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1062           _PTR(AttributeComment) aCmnt (anAttr);
1063           string aComm (aCmnt->Value());
1064           if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1065           if (aComm.compare(View3D_i::myComment) >= 0) {
1066             aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1067             return true;
1068           }
1069         }
1070       }
1071     }
1072     _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1073     string aSComponentEntry = aSComponent->GetID();
1074     string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
1075                                       ToString(theViewManager->getActiveView()).c_str());
1076     return true;
1077   }
1078
1079   CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
1080   {
1081     return SaveViewParams(myViewManager, theName);
1082   }
1083
1084   bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1085   {
1086     _PTR(Study) aCStudy;
1087     if (SUIT_Study* aSStudy = theViewManager->study()) {
1088       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1089         aCStudy = aStudy->studyDS();
1090       }
1091     }
1092     if (!aCStudy)
1093       return false;
1094
1095     std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1096     _PTR(GenericAttribute) anAttr;
1097     int iEnd = aList.size();
1098     if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1099     for (int i = 0; i < iEnd; i++) {
1100       _PTR(SObject) anObj = aList[i];
1101       string anEntry = anObj->GetID();
1102       if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1103       if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1104         _PTR(AttributeComment) aCmnt (anAttr);
1105         QString strIn(aCmnt->Value().c_str());
1106         Storable::TRestoringMap aMap;
1107         Storable::StrToMap(strIn, aMap);
1108         if (Storable::FindValue(aMap, "myComment").compare
1109             (View3D_i::myComment.c_str()) >= 0) {
1110           if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
1111           Restore(theViewManager->getActiveView(), aMap);
1112           return true;
1113         }
1114       }
1115     }
1116     return false;
1117   }
1118
1119   class TRestoreViewParamsEvent: public SALOME_Event
1120   {
1121     SUIT_ViewManager* myViewManager;
1122     const char*       myName;
1123   public:
1124     TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1125                              const char*       theName):
1126       myViewManager(theViewManager),
1127       myName(theName)
1128     {}
1129
1130     virtual void Execute()
1131     {
1132       myResult = View3D_i::RestoreViewParams(myViewManager, myName);
1133     }
1134     typedef CORBA::Boolean TResult;
1135     TResult myResult;
1136   };
1137
1138   CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
1139   {
1140     return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
1141   }
1142
1143   void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame,
1144                           const Storable::TRestoringMap& theMap)
1145   {
1146     SALOMEDS::Color aColor;
1147     aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1148     aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1149     aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1150
1151     double aPosition[3];
1152     aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1153     aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1154     aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1155
1156     double aFocalPnt[3];
1157     aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1158     aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1159     aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1160
1161     double aViewUp[3];
1162     aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1163     aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1164     aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1165
1166     double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1167
1168     double aScaleFactor[3];
1169     aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1170     aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1171     aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1172
1173     SetBackground(theStudyFrame,aColor);
1174     SetPointOfView(theStudyFrame,aPosition);
1175     SetViewUp(theStudyFrame,aViewUp);
1176     SetFocalPoint(theStudyFrame,aFocalPnt);
1177     SetParallelScale(theStudyFrame,aParallelScale);
1178     ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1179     ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1180     ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1181   }
1182
1183
1184   string View3D_i::ToString (SUIT_ViewWindow* theStudyFrame)
1185   {
1186     ostringstream strOut;
1187     Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1188     ToStream(theStudyFrame,strOut);
1189     strOut<<ends;
1190     if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1191     return strOut.str();
1192   }
1193
1194   void View3D_i::ToStream (SUIT_ViewWindow* theStudyFrame, std::ostringstream& theStr)
1195   {
1196     Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1197
1198     float backint[3];
1199     GetRenderer(theStudyFrame)->GetBackground(backint);
1200     Storable::DataToStream(theStr,"myColor.R",backint[0]);
1201     Storable::DataToStream(theStr,"myColor.G",backint[1]);
1202     Storable::DataToStream(theStr,"myColor.B",backint[2]);
1203
1204     double aPosition[3];
1205     GetPointOfView(theStudyFrame,aPosition);
1206     Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1207     Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1208     Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1209
1210     double aFocalPnt[3];
1211     GetFocalPoint(theStudyFrame,aFocalPnt);
1212     Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1213     Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1214     Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1215
1216     double aViewUp[3];
1217     GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1218     Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1219     Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1220     Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1221
1222     Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1223
1224     double aScaleFactor[3];
1225     GetViewWindow(theStudyFrame)->GetScale(aScaleFactor);
1226     Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1227     Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1228     Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1229   }
1230
1231   void View3D_i::ToStream(std::ostringstream& theStr)
1232   {
1233     ToStream(myViewWindow,theStr);
1234   }
1235
1236   void View3D_i::Close()
1237   {
1238     myViewWindow->close();
1239   }
1240
1241   View3D_i::~View3D_i()
1242   {
1243     if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1244   }
1245
1246   void View3D_i::SetTitle (const char* theTitle)
1247   {
1248     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1249                      (myViewWindow,&SUIT_ViewWindow::setCaption,QString(theTitle)));
1250   }
1251
1252   char* View3D_i::GetTitle()
1253   {
1254     return CORBA::string_dup(myViewWindow->caption().latin1());
1255   }
1256
1257   void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame,
1258                                 const SALOMEDS::Color& theColor)
1259   {
1260     int aColor[3];
1261     aColor[0] = int(255.0*theColor.R);
1262     aColor[1] = int(255.0*theColor.G);
1263     aColor[2] = int(255.0*theColor.B);
1264     QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1265     GetViewWindow(theStudyFrame)->setBackgroundColor(aNewColor);
1266   }
1267
1268   SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame)
1269   {
1270     SALOMEDS::Color aColor;
1271     float backint[3];
1272     GetRenderer(theStudyFrame)->GetBackground(backint);
1273     aColor.R = backint[0];  aColor.G = backint[1];  aColor.B = backint[2];
1274     return aColor;
1275   }
1276
1277   class TUpdateViewerEvent: public SALOME_Event
1278   {
1279     SUIT_ViewWindow* myViewWindow;
1280     Prs3d_i* myPrs3d;
1281     int myDisplaing;
1282   public:
1283     TUpdateViewerEvent(SUIT_ViewWindow* theStudyFrame,
1284                        Prs3d_i* thePrs3d,
1285                        int theDisplaing):
1286       myViewWindow(theStudyFrame),
1287       myPrs3d(thePrs3d),
1288       myDisplaing(theDisplaing)
1289     {}
1290     virtual void Execute(){
1291       UpdateViewer(myViewWindow,myDisplaing,myPrs3d);
1292     }
1293   };
1294
1295   void View3D_i::EraseAll()
1296   {
1297     if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1298     ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eEraseAll));
1299   }
1300
1301   void View3D_i::DisplayAll()
1302   {
1303     if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1304     ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eDisplayAll));
1305   }
1306
1307   void View3D_i::Erase (PrsObject_ptr thePrsObj)
1308   {
1309     if(MYDEBUG) MESSAGE("View3D_i::Erase");
1310     CORBA::Object_ptr anObj = thePrsObj;
1311     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1312       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eErase));
1313     }
1314   }
1315
1316   void View3D_i::Display (PrsObject_ptr thePrsObj)
1317   {
1318     if(MYDEBUG) MESSAGE("View3D_i::Display");
1319     CORBA::Object_ptr anObj = thePrsObj;
1320     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1321       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplay));
1322     }
1323   }
1324
1325   void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
1326   {
1327     if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1328     CORBA::Object_ptr anObj = thePrsObj;
1329     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1330       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplayOnly));
1331     }
1332   }
1333
1334   void View3D_i::FitAll()
1335   {
1336     ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1337                      (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll));
1338     Update();
1339   }
1340
1341   void View3D_i::SetView (VISU::View3D::ViewType theType)
1342   {
1343     switch (theType) {
1344     case VISU::View3D::FRONT :
1345       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1346                        (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFrontView));
1347       break;
1348     case VISU::View3D::BACK :
1349       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1350                        (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView));
1351       break;
1352     case VISU::View3D::LEFT :
1353       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1354                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView));
1355       break;
1356     case VISU::View3D::RIGHT :
1357       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1358                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView));
1359       break;
1360     case VISU::View3D::TOP :
1361       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1362                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView));
1363       break;
1364     case VISU::View3D::BOTTOM :
1365       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1366                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView));
1367       break;
1368     }
1369     Update();
1370   }
1371
1372   class TSet3DViewParamEvent: public SALOME_Event
1373   {
1374   public:
1375     typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, const CORBA::Double theParam[3]);
1376     TSet3DViewParamEvent (TFun theFun,
1377                           SUIT_ViewWindow* theStudyFrame,
1378                           const CORBA::Double theParam[3]):
1379       myFun(theFun),
1380       myViewWindow(theStudyFrame),
1381       myParam(theParam)
1382     {}
1383     virtual void Execute(){
1384       myFun(myViewWindow,myParam);
1385     }
1386   private:
1387     TFun myFun;
1388     SUIT_ViewWindow* myViewWindow;
1389     const CORBA::Double* myParam;
1390   };
1391
1392   void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame,
1393                                  const CORBA::Double thePosition[3])
1394   {
1395     GetCamera(theStudyFrame)->SetPosition(thePosition);
1396   }
1397
1398   void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
1399   {
1400     if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1401     ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myViewWindow,thePosition));
1402   }
1403
1404   void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame,
1405                                  CORBA::Double thePosition[3])
1406   {
1407     GetCamera(theStudyFrame)->GetPosition(thePosition);
1408   }
1409
1410   VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
1411   {
1412     if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1413     CORBA::Double aPosition[3];
1414     GetPointOfView(myViewWindow,aPosition);
1415     return VISU::View3D::XYZ_dup(aPosition);
1416   }
1417
1418   void View3D_i::SetViewUp (SUIT_ViewWindow* theStudyFrame,
1419                             const CORBA::Double theViewUp[3])
1420   {
1421     GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1422   }
1423
1424   void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
1425   {
1426     if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1427     ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myViewWindow,theViewUp));
1428   }
1429
1430   void View3D_i::GetViewUp (SUIT_ViewWindow* theStudyFrame,
1431                             CORBA::Double theViewUp[3])
1432   {
1433     GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1434   }
1435
1436   VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
1437   {
1438     if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1439     CORBA::Double aViewUp[3];
1440     GetCamera(myViewWindow)->GetViewUp(aViewUp);
1441     return VISU::View3D::XYZ_dup(aViewUp);
1442   }
1443
1444   void View3D_i::SetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1445                                 const CORBA::Double theFocalPnt[3])
1446   {
1447     GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1448   }
1449
1450   void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
1451   {
1452     if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1453     ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myViewWindow,theCoord));
1454   }
1455
1456
1457   void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1458                                 CORBA::Double theFocalPnt[3])
1459   {
1460     GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1461   }
1462
1463   VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
1464   {
1465     if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1466     CORBA::Double aFocalPnt[3];
1467     GetFocalPoint(myViewWindow,aFocalPnt);
1468     return VISU::View3D::XYZ_dup(aFocalPnt);
1469   }
1470
1471   class TSetViewParamEvent: public SALOME_Event
1472   {
1473   public:
1474     typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, CORBA::Double theParam);
1475     TSetViewParamEvent (TFun theFun,
1476                         SUIT_ViewWindow* theStudyFrame,
1477                         CORBA::Double theParam):
1478       myFun(theFun),
1479       myViewWindow(theStudyFrame),
1480       myParam(theParam)
1481     {}
1482     virtual void Execute()
1483     {
1484       myFun(myViewWindow,myParam);
1485     }
1486   private:
1487     TFun myFun;
1488     SUIT_ViewWindow* myViewWindow;
1489     CORBA::Double myParam;
1490   };
1491
1492   void View3D_i::SetParallelScale (SUIT_ViewWindow* theStudyFrame,
1493                                    CORBA::Double theScale)
1494   {
1495     GetCamera(theStudyFrame)->SetParallelScale(theScale);
1496   }
1497
1498   void View3D_i::SetParallelScale (CORBA::Double theScale)
1499   {
1500     if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1501     ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myViewWindow,theScale));
1502   }
1503
1504   CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theStudyFrame)
1505   {
1506     return GetCamera(theStudyFrame)->GetParallelScale();
1507   }
1508
1509   CORBA::Double View3D_i::GetParallelScale()
1510   {
1511     if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1512     return GetParallelScale(myViewWindow);
1513   }
1514
1515   void View3D_i::ScaleView (SUIT_ViewWindow* theStudyFrame,
1516                             VISU::View3D::Axis theAxis, CORBA::Double theParam)
1517   {
1518     SVTK_ViewWindow* aViewFrame = GetViewWindow(theStudyFrame);
1519     double aScaleFactor[3];
1520     aViewFrame->GetScale(aScaleFactor);
1521     aScaleFactor[theAxis] = theParam;
1522     aViewFrame->SetScale(aScaleFactor);
1523   }
1524
1525   void SetScaleView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theScale[3])
1526   {
1527     double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1528     GetViewWindow(theStudyFrame)->SetScale(aScale);
1529   }
1530
1531   void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
1532   {
1533     if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1534     double aScale[3];
1535     GetViewWindow(myViewWindow)->GetScale(aScale);
1536     aScale[theAxis] = theParam;
1537     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
1538   }
1539
1540   void View3D_i::RemoveScale()
1541   {
1542     if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1543     double aScale[3] = {1.0, 1.0, 1.0};
1544     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
1545   }
1546 }