]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_View_i.cc
Salome HOME
a9b943c318bc1e388abebdcbfcb9fb1040b980c2
[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, theApplication->getViewManager(Plot2d_Viewer::Type(), true))
612   {
613     if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
614   }
615
616   Storable* XYPlot_i::Create (int theNew)
617   {
618     if (theNew) {
619       myViewWindow = myViewManager->createViewWindow();
620     } else {
621       myViewWindow = myViewManager->getActiveView();
622     }
623     ////myView = dynamic_cast<Plot2d_ViewFrame*>(myViewWindow->getRightFrame()->getViewFrame());
624     //SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(myViewManager->getViewModel());
625     //myView = aView->getActiveViewFrame();
626     if (myViewWindow) {
627       Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myViewWindow);
628       if (aPlot2dVW) {
629         myView = aPlot2dVW->getViewFrame();
630         if (myView) {
631           myView->Repaint();
632         }
633       }
634     }
635     return this;
636   }
637
638   void XYPlot_i::Update()
639   {
640     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
641   }
642
643   void XYPlot_i::Close()
644   {
645     myViewWindow->close();
646   }
647
648   XYPlot_i::~XYPlot_i() {
649     if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
650   }
651
652   void XYPlot_i::SetTitle (const char* theTitle)
653   {
654     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
655                      (myViewWindow, &SUIT_ViewWindow::setCaption, QString(theTitle)));
656   }
657   char* XYPlot_i::GetTitle()
658   {
659     return CORBA::string_dup(myViewWindow->caption().latin1());
660   }
661
662   void XYPlot_i::SetSubTitle (const char* theTitle)
663   {
664     ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
665                      (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
666   }
667
668   char* XYPlot_i::GetSubTitle()
669   {
670     return CORBA::string_dup(myView->getTitle());
671   }
672
673   void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
674   {
675     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
676                      (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
677   }
678
679   VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
680   {
681     return (VISU::XYPlot::CurveType)myView->getCurveType();
682   }
683
684   void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
685   {
686     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
687                      (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
688   }
689
690   CORBA::Long XYPlot_i::GetMarkerSize()
691   {
692     return myView->getMarkerSize();
693   }
694
695   class TEnableGridEvent: public SALOME_Event
696   {
697   public:
698     typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
699     TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun,
700                       CORBA::Boolean theMajor, CORBA::Long theNumMajor,
701                       CORBA::Boolean theMinor, CORBA::Long theNumMinor):
702       myView(theView), myFun(theFun),
703       myMajor(theMajor), myNumMajor(theNumMajor),
704       myMinor(theMinor), myNumMinor(theNumMinor)
705     {}
706
707     virtual void Execute()
708     {
709       (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true);
710     }
711   protected:
712     Plot2d_ViewFrame* myView;
713     TFun myFun;
714     CORBA::Boolean myMajor, myNumMajor;
715     CORBA::Boolean myMinor, myNumMinor;
716   };
717
718   void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
719                               CORBA::Boolean theMinor, CORBA::Long theNumMinor)
720   {
721     ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
722                                           theMajor,theNumMajor,theMinor,theNumMinor));
723   }
724   void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
725                              CORBA::Boolean theMinor, CORBA::Long theNumMinor)
726   {
727     //jfa tmp:ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
728     //jfa tmp:                                      theMajor,theNumMajor,theMinor,theNumMinor));
729   }
730
731   class TSetScaleModeEvent: public SALOME_Event
732   {
733   public:
734     typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
735     TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
736       myView(theView), myFun(theFun), myScaling(theScaling)
737     {}
738
739     virtual void Execute()
740     {
741       (myView->*myFun)(myScaling,true);
742     }
743   protected:
744     Plot2d_ViewFrame* myView;
745     TFun myFun;
746     int myScaling;
747   };
748
749   void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
750   {
751     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
752                                             theScaling == VISU::LOGARITHMIC));
753   }
754
755   VISU::Scaling XYPlot_i::GetHorScaling()
756   {
757     return (VISU::Scaling)myView->getHorScaleMode();
758   }
759
760   void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
761   {
762     ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
763                                             theScaling == VISU::LOGARITHMIC));
764   }
765
766   VISU::Scaling XYPlot_i::GetVerScaling()
767   {
768     return (VISU::Scaling)myView->getVerScaleMode();
769   }
770
771   class TSetTitleEvent: public SALOME_Event
772   {
773   public:
774     //typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
775     typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, Plot2d_ViewFrame::ObjectType, bool = true);
776     //TSetTitleEvent (Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
777     TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
778       //myView(theView), myFun(theFun), myTitle(theTitle)
779       myView(theView), myType(theType), myTitle(theTitle)
780     {}
781     virtual void Execute()
782     {
783       //(myView->*myFun)(true,myTitle,myType);
784       myView->setTitle(true,myTitle,myType);
785     }
786   protected:
787     Plot2d_ViewFrame* myView;
788     //TFun myFun;
789     Plot2d_ViewFrame::ObjectType myType;
790     const char* myTitle;
791   };
792
793   void XYPlot_i::SetXTitle (const char* theTitle)
794   {
795     //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setXTitle, theTitle));
796     ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
797   }
798   char* XYPlot_i::GetXTitle()
799   {
800     //return CORBA::string_dup(myView->getXTitle());
801     return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
802   }
803
804   void XYPlot_i::SetYTitle (const char* theTitle)
805   {
806     //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setYTitle, theTitle));
807     ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
808   }
809   char* XYPlot_i::GetYTitle()
810   {
811     //return CORBA::string_dup(myView->getYTitle());
812     return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
813   }
814
815   void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
816   {
817     ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
818                      (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
819   }
820
821   class TXYPlotViewEvent: public SALOME_Event
822   {
823     SalomeApp_Application* myApplication;
824     Plot2d_ViewFrame*      myView;
825     PrsObject_ptr          myPrsObj;
826     int                    myDisplaing;
827
828   public:
829     TXYPlotViewEvent(SalomeApp_Application* theApplication,
830                      Plot2d_ViewFrame*      theView,
831                      PrsObject_ptr          thePrsObj,
832                      int                    theDisplaing)
833       : myApplication(theApplication),
834       myView(theView),
835       myPrsObj(thePrsObj),
836       myDisplaing(theDisplaing)
837     {
838     }
839
840     virtual void Execute()
841     {
842       // is it Curve ?
843       if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
844         UpdatePlot2d(myView,myDisplaing,aCurve);
845       }
846       // is it Container ?
847       if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
848         int nbCurves = aContainer->GetNbCurves();
849         for ( int i = 1; i <= nbCurves; i++ ) {
850           VISU::Curve_i* aCurve = aContainer->GetCurve( i );
851           if ( aCurve && aCurve->IsValid() ) {
852             UpdatePlot2d(myView,myDisplaing,aCurve);
853           }
854         }
855         myView->Repaint();
856       }
857       // is it Table ?
858       if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
859         _PTR(Study) aCStudy;
860         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
861           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
862             aCStudy = aStudy->studyDS();
863           }
864         }
865         if (!aCStudy) return;
866         _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
867         if (TableSO) {
868           _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
869           for (; Iter->More(); Iter->Next()) {
870             CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
871             if (!CORBA::is_nil(childObject)) {
872               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
873               if (!CORBA::is_nil(aCurve))
874                 UpdatePlot2d(myView, myDisplaing,
875                              dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
876             }
877           }
878           myView->Repaint();
879         }
880       }
881     }
882   };
883
884   void XYPlot_i::Display (PrsObject_ptr thePrsObj)
885   {
886     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
887   }
888
889   void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
890   {
891     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
892   }
893
894   void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
895   {
896     ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
897   }
898
899   void XYPlot_i::EraseAll()
900   {
901     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
902   }
903
904   void XYPlot_i::FitAll()
905   {
906     ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
907   }
908
909   CORBA::Boolean XYPlot_i::SavePicture (const char* theFileName)
910   {
911     return ProcessEvent(new TSavePictureEvent (myView->getViewWidget(),theFileName));
912   }
913
914
915   //===========================================================================
916   TableView_i::TableView_i (SalomeApp_Application* theApplication)
917     : View_i(theApplication, NULL)
918   {
919   }
920
921   Storable* TableView_i::Create (VISU::Table_ptr theTable)
922   {
923     if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
924     if (!theTable->_is_nil()) {
925       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
926       if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
927       if (table != NULL) {
928         if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
929           if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
930             if (_PTR(Study) aCStudy = aStudy->studyDS()) {
931               _PTR(SObject) aSObject = aCStudy->FindObjectID(table->GetObjectEntry());
932               if (aSObject) {
933                 myView = new VisuGUI_TableDlg (myApplication->desktop(),
934                                                aSObject,
935                                                false,
936                                                VisuGUI_TableDlg::ttAuto,
937                                                Qt::Vertical);
938                 myView->show();
939                 return this;
940               }
941             }
942           }
943         }
944       }
945     }
946     return NULL;
947   }
948
949   TableView_i::~TableView_i()
950   {
951     if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
952     delete myView;
953   }
954
955   void TableView_i::SetTitle (const char* theTitle)
956   {
957     ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
958                      (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
959   }
960
961   char* TableView_i::GetTitle()
962   {
963     return CORBA::string_dup(myView->caption().latin1());
964     return "";
965   }
966
967   void TableView_i::Close()
968   {
969     myView->close();
970   }
971
972
973   //===========================================================================
974   int View3D_i::myNbViewParams = 0;
975   const string View3D_i::myComment = "VIEW3D";
976   const char* View3D_i::GetComment() const { return myComment.c_str();}
977
978   QString View3D_i::GenerateViewParamsName()
979   {
980     return VISU::GenerateName("ViewParams", ++myNbViewParams);
981   }
982
983   View3D_i::View3D_i (SalomeApp_Application* theApplication)
984     : View_i(theApplication, theApplication->getViewManager(SVTK_Viewer::Type(), true))
985   {
986     if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
987   }
988
989   Storable* View3D_i::Create (int theNew)
990   {
991     if (MYDEBUG) MESSAGE("View3D_i::Create");
992     if (theNew) {
993       myViewWindow = myViewManager->createViewWindow();
994     } else {
995       myViewWindow = myViewManager->getActiveView();
996     }
997     return this;
998   }
999
1000   void View3D_i::Update()
1001   {
1002     class TEvent: public SALOME_Event
1003     {
1004       SUIT_ViewWindow* myViewWindow;
1005     public:
1006       TEvent(SUIT_ViewWindow* theStudyFrame):
1007         myViewWindow(theStudyFrame)
1008       {}
1009       virtual void Execute()
1010       {
1011         SVTK_ViewWindow* vf = GetViewWindow(myViewWindow);
1012         vtkRenderer* Renderer = vf->getRenderer();
1013         vtkActorCollection* theActors = Renderer->GetActors();
1014         theActors->InitTraversal();
1015         while (vtkActor *anAct = theActors->GetNextActor()) {
1016           if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
1017             VISU::Prs3d_i* aPrs3d  = anActor->GetPrs3d();
1018             if (anActor->GetVisibility() && aPrs3d) {
1019               aPrs3d->Update();
1020               aPrs3d->UpdateActor(anActor);
1021             }
1022           }
1023         }
1024         RepaintView(myViewWindow);
1025       }
1026     };
1027     ProcessVoidEvent(new TEvent(myViewWindow));
1028   }
1029
1030   CORBA::Boolean View3D_i::SavePicture (const char* theFileName)
1031   {
1032     //jfa tmp:return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(), theFileName));
1033     return false;
1034   }
1035
1036   bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1037   {
1038     _PTR(Study) aCStudy;
1039     if (SUIT_Study* aSStudy = theViewManager->study()) {
1040       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1041         aCStudy = aStudy->studyDS();
1042       }
1043     }
1044     if (!aCStudy)
1045       return false;
1046
1047     if (theName) {
1048       std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1049       _PTR(GenericAttribute) anAttr;
1050       int iEnd = aList.size();
1051       for (int i = 0; i < iEnd; i++) {
1052         _PTR(SObject) anObj = aList[i];
1053         string anEntry = anObj->GetID();
1054         if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1055         if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1056           _PTR(AttributeComment) aCmnt (anAttr);
1057           string aComm (aCmnt->Value());
1058           if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1059           if (aComm.compare(View3D_i::myComment) >= 0) {
1060             aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1061             return true;
1062           }
1063         }
1064       }
1065     }
1066     _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1067     string aSComponentEntry = aSComponent->GetID();
1068     string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
1069                                       ToString(theViewManager->getActiveView()).c_str());
1070     return true;
1071   }
1072
1073   CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
1074   {
1075     return SaveViewParams(myViewManager, theName);
1076   }
1077
1078   bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
1079   {
1080     _PTR(Study) aCStudy;
1081     if (SUIT_Study* aSStudy = theViewManager->study()) {
1082       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1083         aCStudy = aStudy->studyDS();
1084       }
1085     }
1086     if (!aCStudy)
1087       return false;
1088
1089     std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1090     _PTR(GenericAttribute) anAttr;
1091     int iEnd = aList.size();
1092     if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1093     for (int i = 0; i < iEnd; i++) {
1094       _PTR(SObject) anObj = aList[i];
1095       string anEntry = anObj->GetID();
1096       if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1097       if (anObj->FindAttribute(anAttr, "AttributeComment")) {
1098         _PTR(AttributeComment) aCmnt (anAttr);
1099         QString strIn(aCmnt->Value().c_str());
1100         Storable::TRestoringMap aMap;
1101         Storable::StrToMap(strIn, aMap);
1102         if (Storable::FindValue(aMap, "myComment").compare
1103             (View3D_i::myComment.c_str()) >= 0) {
1104           if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
1105           Restore(theViewManager->getActiveView(), aMap);
1106           return true;
1107         }
1108       }
1109     }
1110     return false;
1111   }
1112
1113   class TRestoreViewParamsEvent: public SALOME_Event
1114   {
1115     SUIT_ViewManager* myViewManager;
1116     const char*       myName;
1117   public:
1118     TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1119                              const char*       theName):
1120       myViewManager(theViewManager),
1121       myName(theName)
1122     {}
1123
1124     virtual void Execute()
1125     {
1126       myResult = View3D_i::RestoreViewParams(myViewManager, myName);
1127     }
1128     typedef CORBA::Boolean TResult;
1129     TResult myResult;
1130   };
1131
1132   CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
1133   {
1134     return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
1135   }
1136
1137   void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame,
1138                           const Storable::TRestoringMap& theMap)
1139   {
1140     SALOMEDS::Color aColor;
1141     aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1142     aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1143     aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1144
1145     double aPosition[3];
1146     aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1147     aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1148     aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1149
1150     double aFocalPnt[3];
1151     aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1152     aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1153     aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1154
1155     double aViewUp[3];
1156     aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1157     aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1158     aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1159
1160     double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1161
1162     double aScaleFactor[3];
1163     aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1164     aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1165     aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1166
1167     SetBackground(theStudyFrame,aColor);
1168     SetPointOfView(theStudyFrame,aPosition);
1169     SetViewUp(theStudyFrame,aViewUp);
1170     SetFocalPoint(theStudyFrame,aFocalPnt);
1171     SetParallelScale(theStudyFrame,aParallelScale);
1172     ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1173     ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1174     ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1175   }
1176
1177
1178   string View3D_i::ToString (SUIT_ViewWindow* theStudyFrame)
1179   {
1180     ostringstream strOut;
1181     Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1182     ToStream(theStudyFrame,strOut);
1183     strOut<<ends;
1184     if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1185     return strOut.str();
1186   }
1187
1188   void View3D_i::ToStream (SUIT_ViewWindow* theStudyFrame, std::ostringstream& theStr)
1189   {
1190     Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1191
1192     float backint[3];
1193     GetRenderer(theStudyFrame)->GetBackground(backint);
1194     Storable::DataToStream(theStr,"myColor.R",backint[0]);
1195     Storable::DataToStream(theStr,"myColor.G",backint[1]);
1196     Storable::DataToStream(theStr,"myColor.B",backint[2]);
1197
1198     double aPosition[3];
1199     GetPointOfView(theStudyFrame,aPosition);
1200     Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1201     Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1202     Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1203
1204     double aFocalPnt[3];
1205     GetFocalPoint(theStudyFrame,aFocalPnt);
1206     Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1207     Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1208     Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1209
1210     double aViewUp[3];
1211     GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1212     Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1213     Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1214     Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1215
1216     Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1217
1218     double aScaleFactor[3];
1219     GetViewWindow(theStudyFrame)->GetScale(aScaleFactor);
1220     Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1221     Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1222     Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1223   }
1224
1225   void View3D_i::ToStream(std::ostringstream& theStr)
1226   {
1227     ToStream(myViewWindow,theStr);
1228   }
1229
1230   void View3D_i::Close()
1231   {
1232     myViewWindow->close();
1233   }
1234
1235   View3D_i::~View3D_i()
1236   {
1237     if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1238   }
1239
1240   void View3D_i::SetTitle (const char* theTitle)
1241   {
1242     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1243                      (myViewWindow,&SUIT_ViewWindow::setCaption,QString(theTitle)));
1244   }
1245
1246   char* View3D_i::GetTitle()
1247   {
1248     return CORBA::string_dup(myViewWindow->caption().latin1());
1249   }
1250
1251   void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame,
1252                                 const SALOMEDS::Color& theColor)
1253   {
1254     int aColor[3];
1255     aColor[0] = int(255.0*theColor.R);
1256     aColor[1] = int(255.0*theColor.G);
1257     aColor[2] = int(255.0*theColor.B);
1258     QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1259     GetViewWindow(theStudyFrame)->setBackgroundColor(aNewColor);
1260   }
1261
1262   SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame)
1263   {
1264     SALOMEDS::Color aColor;
1265     float backint[3];
1266     GetRenderer(theStudyFrame)->GetBackground(backint);
1267     aColor.R = backint[0];  aColor.G = backint[1];  aColor.B = backint[2];
1268     return aColor;
1269   }
1270
1271   class TUpdateViewerEvent: public SALOME_Event
1272   {
1273     SUIT_ViewWindow* myViewWindow;
1274     Prs3d_i* myPrs3d;
1275     int myDisplaing;
1276   public:
1277     TUpdateViewerEvent(SUIT_ViewWindow* theStudyFrame,
1278                        Prs3d_i* thePrs3d,
1279                        int theDisplaing):
1280       myViewWindow(theStudyFrame),
1281       myPrs3d(thePrs3d),
1282       myDisplaing(theDisplaing)
1283     {}
1284     virtual void Execute(){
1285       UpdateViewer(myViewWindow,myDisplaing,myPrs3d);
1286     }
1287   };
1288
1289   void View3D_i::EraseAll()
1290   {
1291     if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1292     ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eEraseAll));
1293   }
1294
1295   void View3D_i::DisplayAll()
1296   {
1297     if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1298     ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eDisplayAll));
1299   }
1300
1301   void View3D_i::Erase (PrsObject_ptr thePrsObj)
1302   {
1303     if(MYDEBUG) MESSAGE("View3D_i::Erase");
1304     CORBA::Object_ptr anObj = thePrsObj;
1305     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1306       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eErase));
1307     }
1308   }
1309
1310   void View3D_i::Display (PrsObject_ptr thePrsObj)
1311   {
1312     if(MYDEBUG) MESSAGE("View3D_i::Display");
1313     CORBA::Object_ptr anObj = thePrsObj;
1314     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1315       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplay));
1316     }
1317   }
1318
1319   void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
1320   {
1321     if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1322     CORBA::Object_ptr anObj = thePrsObj;
1323     if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1324       ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplayOnly));
1325     }
1326   }
1327
1328   void View3D_i::FitAll()
1329   {
1330     ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1331                      (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll));
1332     Update();
1333   }
1334
1335   void View3D_i::SetView (VISU::View3D::ViewType theType)
1336   {
1337     switch (theType) {
1338     case VISU::View3D::FRONT :
1339       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1340                        (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFrontView));
1341       break;
1342     case VISU::View3D::BACK :
1343       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1344                        (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView));
1345       break;
1346     case VISU::View3D::LEFT :
1347       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1348                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView));
1349       break;
1350     case VISU::View3D::RIGHT :
1351       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1352                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView));
1353       break;
1354     case VISU::View3D::TOP :
1355       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1356                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView));
1357       break;
1358     case VISU::View3D::BOTTOM :
1359       ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1360                        (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView));
1361       break;
1362     }
1363     Update();
1364   }
1365
1366   class TSet3DViewParamEvent: public SALOME_Event
1367   {
1368   public:
1369     typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, const CORBA::Double theParam[3]);
1370     TSet3DViewParamEvent (TFun theFun,
1371                           SUIT_ViewWindow* theStudyFrame,
1372                           const CORBA::Double theParam[3]):
1373       myFun(theFun),
1374       myViewWindow(theStudyFrame),
1375       myParam(theParam)
1376     {}
1377     virtual void Execute(){
1378       myFun(myViewWindow,myParam);
1379     }
1380   private:
1381     TFun myFun;
1382     SUIT_ViewWindow* myViewWindow;
1383     const CORBA::Double* myParam;
1384   };
1385
1386   void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame,
1387                                  const CORBA::Double thePosition[3])
1388   {
1389     GetCamera(theStudyFrame)->SetPosition(thePosition);
1390   }
1391
1392   void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
1393   {
1394     if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1395     ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myViewWindow,thePosition));
1396   }
1397
1398   void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame,
1399                                  CORBA::Double thePosition[3])
1400   {
1401     GetCamera(theStudyFrame)->GetPosition(thePosition);
1402   }
1403
1404   VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
1405   {
1406     if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1407     CORBA::Double aPosition[3];
1408     GetPointOfView(myViewWindow,aPosition);
1409     return VISU::View3D::XYZ_dup(aPosition);
1410   }
1411
1412   void View3D_i::SetViewUp (SUIT_ViewWindow* theStudyFrame,
1413                             const CORBA::Double theViewUp[3])
1414   {
1415     GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1416   }
1417
1418   void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
1419   {
1420     if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1421     ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myViewWindow,theViewUp));
1422   }
1423
1424   void View3D_i::GetViewUp (SUIT_ViewWindow* theStudyFrame,
1425                             CORBA::Double theViewUp[3])
1426   {
1427     GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1428   }
1429
1430   VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
1431   {
1432     if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1433     CORBA::Double aViewUp[3];
1434     GetCamera(myViewWindow)->GetViewUp(aViewUp);
1435     return VISU::View3D::XYZ_dup(aViewUp);
1436   }
1437
1438   void View3D_i::SetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1439                                 const CORBA::Double theFocalPnt[3])
1440   {
1441     GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1442   }
1443
1444   void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
1445   {
1446     if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1447     ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myViewWindow,theCoord));
1448   }
1449
1450
1451   void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame,
1452                                 CORBA::Double theFocalPnt[3])
1453   {
1454     GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1455   }
1456
1457   VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
1458   {
1459     if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1460     CORBA::Double aFocalPnt[3];
1461     GetFocalPoint(myViewWindow,aFocalPnt);
1462     return VISU::View3D::XYZ_dup(aFocalPnt);
1463   }
1464
1465   class TSetViewParamEvent: public SALOME_Event
1466   {
1467   public:
1468     typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, CORBA::Double theParam);
1469     TSetViewParamEvent (TFun theFun,
1470                         SUIT_ViewWindow* theStudyFrame,
1471                         CORBA::Double theParam):
1472       myFun(theFun),
1473       myViewWindow(theStudyFrame),
1474       myParam(theParam)
1475     {}
1476     virtual void Execute()
1477     {
1478       myFun(myViewWindow,myParam);
1479     }
1480   private:
1481     TFun myFun;
1482     SUIT_ViewWindow* myViewWindow;
1483     CORBA::Double myParam;
1484   };
1485
1486   void View3D_i::SetParallelScale (SUIT_ViewWindow* theStudyFrame,
1487                                    CORBA::Double theScale)
1488   {
1489     GetCamera(theStudyFrame)->SetParallelScale(theScale);
1490   }
1491
1492   void View3D_i::SetParallelScale (CORBA::Double theScale)
1493   {
1494     if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1495     ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myViewWindow,theScale));
1496   }
1497
1498   CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theStudyFrame)
1499   {
1500     return GetCamera(theStudyFrame)->GetParallelScale();
1501   }
1502
1503   CORBA::Double View3D_i::GetParallelScale()
1504   {
1505     if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1506     return GetParallelScale(myViewWindow);
1507   }
1508
1509   void View3D_i::ScaleView (SUIT_ViewWindow* theStudyFrame,
1510                             VISU::View3D::Axis theAxis, CORBA::Double theParam)
1511   {
1512     SVTK_ViewWindow* aViewFrame = GetViewWindow(theStudyFrame);
1513     double aScaleFactor[3];
1514     aViewFrame->GetScale(aScaleFactor);
1515     aScaleFactor[theAxis] = theParam;
1516     aViewFrame->SetScale(aScaleFactor);
1517   }
1518
1519   void SetScaleView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theScale[3])
1520   {
1521     double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1522     GetViewWindow(theStudyFrame)->SetScale(aScale);
1523   }
1524
1525   void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
1526   {
1527     if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1528     double aScale[3];
1529     GetViewWindow(myViewWindow)->GetScale(aScale);
1530     aScale[theAxis] = theParam;
1531     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
1532   }
1533
1534   void View3D_i::RemoveScale()
1535   {
1536     if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1537     double aScale[3] = {1.0, 1.0, 1.0};
1538     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale));
1539   }
1540 }