Salome HOME
Roll-back previous integration
[modules/visu.git] / src / VISU_I / VISU_ViewManager_i.hh
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_ViewManager_i.hh
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef VISU_ViewManager_i_HeaderFile
28 #define VISU_ViewManager_i_HeaderFile
29
30 #include "VISUConfig.hh"
31
32 class QAD_Study;
33 class QAD_StudyFrame;
34
35 class VTKViewer_ViewFrame;
36 class SALOMEGUI_TableDlg;
37 class Plot2d_ViewFrame;
38
39 class VISU_Actor;
40
41 class vtkRenderer;
42 class vtkCamera;
43
44 namespace VISU{
45   class Prs3d_i;
46   class ViewManager_i : public virtual POA_VISU::ViewManager,
47                         public virtual Base_i
48   {
49   public:
50     ViewManager_i(SALOMEDS::Study_ptr theStudy);
51     virtual ~ViewManager_i() {};
52     virtual VISU::VISUType GetType() { return VISU::TVIEWMANAGER;};
53
54     virtual View3D_ptr Create3DView();
55     virtual View_ptr   GetCurrentView();
56     virtual TableView_ptr CreateTableView(VISU::Table_ptr theTable);
57     virtual XYPlot_ptr CreateXYPlot();
58     virtual void Destroy(View_ptr theView);
59     virtual void ProcessEvents();
60
61   protected:
62     SALOMEDS::Study_var myStudyDocument;
63   };
64
65   //===========================================================================
66   class View_i : public virtual POA_VISU::View,
67                  public virtual Storable
68   {
69   protected:
70     QAD_Study* myStudy;
71     string myName;
72   public:
73     View_i(SALOMEDS::Study_ptr theStudy);
74     virtual ~View_i();
75     virtual void SetBackground(const SALOMEDS::Color& theColor);
76     virtual SALOMEDS::Color GetBackground();
77     virtual void Minimize();
78     virtual void Restore();
79     virtual void Maximize();
80     virtual void EraseAll();
81     virtual void DisplayAll();
82     virtual void Erase(PrsObject_ptr thePrsObj);
83     virtual void Display(PrsObject_ptr thePrsObj);
84     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
85     virtual void Update();
86
87     virtual CORBA::Boolean SavePicture(const char* theFileName);
88
89     virtual void Close() = 0;
90     virtual void ToStream(std::ostringstream& theStr);
91     virtual const char* GetComment() const;
92   public:
93     virtual const char* View_i::GetEntry();
94   };
95
96   //===========================================================================
97   class XYPlot_i : public virtual POA_VISU::XYPlot,
98                    public virtual View_i
99   {
100   public:
101     XYPlot_i(SALOMEDS::Study_ptr theStudy);
102     virtual ~XYPlot_i();
103     virtual VISU::VISUType GetType() { return VISU::TXYPLOT;};
104
105     virtual void SetTitle(const char* theTitle);
106     virtual char* GetTitle();
107
108     virtual void SetSubTitle(const char* theTitle);
109     virtual char* GetSubTitle();
110
111     virtual void SetCurveType(VISU::XYPlot::CurveType theType);
112     virtual VISU::XYPlot::CurveType GetCurveType();
113
114     virtual void SetMarkerSize(CORBA::Long theSize);
115     virtual CORBA::Long GetMarkerSize();
116
117     virtual void EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
118                              CORBA::Boolean theMinor, CORBA::Long theNumMinor);
119     virtual void EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
120                              CORBA::Boolean theMinor, CORBA::Long theNumMinor);
121
122     virtual void SetHorScaling(VISU::Scaling theScaling);
123     virtual VISU::Scaling GetHorScaling();
124     virtual void SetVerScaling(VISU::Scaling theScaling);
125     virtual VISU::Scaling GetVerScaling();
126
127     virtual void SetXTitle(const char* theTitle);
128     virtual char* GetXTitle();
129
130     virtual void SetYTitle(const char* theTitle);
131     virtual char* GetYTitle();
132
133     virtual void ShowLegend(CORBA::Boolean theShowing);
134
135     virtual void SetBackground(const SALOMEDS::Color& theColor);
136     virtual SALOMEDS::Color GetBackground();
137     virtual void Minimize();
138     virtual void Restore();
139     virtual void Maximize();
140     virtual void EraseAll();
141     virtual void Erase(PrsObject_ptr thePrsObj);
142     virtual void Display(PrsObject_ptr thePrsObj);
143     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
144     virtual void Update();
145
146     virtual CORBA::Boolean SavePicture(const char* theFileName);
147
148     virtual void FitAll();
149
150     virtual void Close();
151   protected:
152     QAD_StudyFrame*   myStudyFrame;
153     Plot2d_ViewFrame* myView;
154   public:
155     virtual Storable* Create(int theNew);
156   };
157
158   //===========================================================================
159   class TableView_i : public virtual POA_VISU::TableView,
160                       public virtual View_i
161   {
162   public:
163     TableView_i(SALOMEDS::Study_ptr theStudy);
164     virtual ~TableView_i();
165     virtual VISU::VISUType GetType() { return VISU::TTABLEVIEW;};
166
167     virtual void SetTitle(const char* theTitle);
168     virtual char* GetTitle();
169
170     virtual void Close();
171   protected:
172     SALOMEGUI_TableDlg* myView;
173   public:
174     virtual Storable* Create(VISU::Table_var theTable);
175   };
176
177   //===========================================================================
178   class View3D_i : public virtual POA_VISU::View3D,
179                    public virtual View_i
180   {
181   public:
182     View3D_i(SALOMEDS::Study_ptr theStudy);
183     virtual ~View3D_i();
184     virtual VISU::VISUType GetType() { return VISU::TVIEW3D;};
185
186     //View interface
187     virtual void SetTitle(const char* theTitle);
188     virtual char* GetTitle();
189
190     static void SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor);
191     virtual void SetBackground(const SALOMEDS::Color& theColor);
192
193     static SALOMEDS::Color GetBackground(QAD_StudyFrame* theStudyFrame);
194     virtual SALOMEDS::Color GetBackground();
195
196     virtual void Minimize();
197     virtual void Restore();
198     virtual void Maximize();
199     virtual void EraseAll();
200     virtual void DisplayAll();
201     virtual void Erase(PrsObject_ptr thePrsObj);
202     virtual void Display(PrsObject_ptr thePrsObj);
203     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
204     virtual void Update();
205
206     virtual CORBA::Boolean SavePicture(const char* theFileName);
207     
208     //View3D interface
209     virtual void FitAll();
210     virtual void SetView(VISU::View3D::ViewType theType);
211
212     static void SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]);
213     virtual void SetPointOfView(const VISU::View3D::XYZ theCoord);
214
215     static void GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]);
216     virtual VISU::View3D::XYZ_slice* GetPointOfView();
217
218     static void SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]);
219     virtual void SetViewUp(const VISU::View3D::XYZ theDir);
220
221     static void GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]);
222     virtual VISU::View3D::XYZ_slice* GetViewUp();
223
224     static void SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]);
225     virtual void SetFocalPoint(const VISU::View3D::XYZ theCoord);
226     
227     static void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]);
228     virtual VISU::View3D::XYZ_slice* GetFocalPoint();
229
230     static void SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale);
231     virtual void SetParallelScale(CORBA::Double theScale);
232     
233     static CORBA::Double GetParallelScale(QAD_StudyFrame* theStudyFrame);
234     virtual CORBA::Double GetParallelScale();
235
236     static void ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam);
237     virtual void ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam);
238     virtual void RemoveScale();
239
240     virtual QString GenerateViewParamsName();
241     virtual CORBA::Boolean SaveViewParams(const char* theName);
242     virtual CORBA::Boolean RestoreViewParams(const char* theName);
243
244     virtual void Close();
245   protected:
246     QAD_StudyFrame* myStudyFrame;
247     //SALOMEDS::Color myColor;
248     //CORBA::Double myPosition[3], myFocalPnt[3], myViewUp[3], myParallelScale, myScaleFactor[3];
249
250     //Storable* Build(int theRestoring);
251     static int myNbViewParams;
252
253   public:
254     virtual Storable* Create(int theNew);
255     virtual Storable* Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&);
256     virtual void ToStream(std::ostringstream& theStr);
257     virtual const char* GetComment() const;
258     static const string myComment;
259     QAD_StudyFrame* GetStudyFrame() const { return myStudyFrame;}
260   };
261   //Storable* View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
262   //                      const char* thePrefix, const Storable::TRestoringMap& theMap);
263
264   VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame);
265   vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame);
266   vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame);
267   void RepaintView(QAD_StudyFrame* theStudyFrame);
268
269   enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
270   VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs = NULL);
271 }
272
273 #endif