Salome HOME
b399434dcf78c01cae1bebf3dccc79441c0a8ef0
[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
60   protected:
61     SALOMEDS::Study_var myStudyDocument;
62   };
63
64   //===========================================================================
65   class View_i : public virtual POA_VISU::View,
66                  public virtual Storable
67   {
68   protected:
69     QAD_Study* myStudy;
70   public:
71     View_i(SALOMEDS::Study_ptr theStudy);
72     virtual ~View_i();
73     virtual void SetBackground(const SALOMEDS::Color& theColor);
74     virtual SALOMEDS::Color GetBackground();
75     virtual void Minimize();
76     virtual void Restore();
77     virtual void Maximize();
78     virtual void EraseAll();
79     virtual void DisplayAll();
80     virtual void Erase(PrsObject_ptr thePrsObj);
81     virtual void Display(PrsObject_ptr thePrsObj);
82     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
83     virtual void Update();
84
85     virtual CORBA::Boolean SavePicture(const char* theFileName);
86
87     virtual void Close() = 0;
88     virtual void ToStream(std::ostringstream& theStr);
89     virtual const char* GetComment() const;
90   public:
91     virtual std::string View_i::GetEntry();
92   };
93
94   //===========================================================================
95   class XYPlot_i : public virtual POA_VISU::XYPlot,
96                    public virtual View_i
97   {
98   public:
99     typedef VISU::XYPlot TInterface;
100     XYPlot_i(SALOMEDS::Study_ptr theStudy);
101     virtual ~XYPlot_i();
102     virtual VISU::VISUType GetType() { return VISU::TXYPLOT;};
103
104     virtual void SetTitle(const char* theTitle);
105     virtual char* GetTitle();
106
107     virtual void SetSubTitle(const char* theTitle);
108     virtual char* GetSubTitle();
109
110     virtual void SetCurveType(VISU::XYPlot::CurveType theType);
111     virtual VISU::XYPlot::CurveType GetCurveType();
112
113     virtual void SetMarkerSize(CORBA::Long theSize);
114     virtual CORBA::Long GetMarkerSize();
115
116     virtual void EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
117                              CORBA::Boolean theMinor, CORBA::Long theNumMinor);
118     virtual void EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
119                              CORBA::Boolean theMinor, CORBA::Long theNumMinor);
120
121     virtual void SetHorScaling(VISU::Scaling theScaling);
122     virtual VISU::Scaling GetHorScaling();
123     virtual void SetVerScaling(VISU::Scaling theScaling);
124     virtual VISU::Scaling GetVerScaling();
125
126     virtual void SetXTitle(const char* theTitle);
127     virtual char* GetXTitle();
128
129     virtual void SetYTitle(const char* theTitle);
130     virtual char* GetYTitle();
131
132     virtual void ShowLegend(CORBA::Boolean theShowing);
133
134     virtual void SetBackground(const SALOMEDS::Color& theColor);
135     virtual SALOMEDS::Color GetBackground();
136     virtual void Minimize();
137     virtual void Restore();
138     virtual void Maximize();
139     virtual void EraseAll();
140     virtual void Erase(PrsObject_ptr thePrsObj);
141     virtual void Display(PrsObject_ptr thePrsObj);
142     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
143     virtual void Update();
144
145     virtual CORBA::Boolean SavePicture(const char* theFileName);
146
147     virtual void FitAll();
148
149     virtual void Close();
150   protected:
151     QAD_StudyFrame*   myStudyFrame;
152     Plot2d_ViewFrame* myView;
153   public:
154     virtual Storable* Create(int theNew);
155   };
156
157   //===========================================================================
158   class TableView_i : public virtual POA_VISU::TableView,
159                       public virtual View_i
160   {
161   public:
162     typedef VISU::TableView TInterface;
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_ptr theTable);
175   };
176
177   //===========================================================================
178   class View3D_i : public virtual POA_VISU::View3D,
179                    public virtual View_i
180   {
181   public:
182     typedef VISU::View3D TInterface;
183     View3D_i(SALOMEDS::Study_ptr theStudy);
184     virtual ~View3D_i();
185     virtual VISU::VISUType GetType() { return VISU::TVIEW3D;};
186
187     //View interface
188     virtual void SetTitle(const char* theTitle);
189     virtual char* GetTitle();
190
191     static void SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor);
192     virtual void SetBackground(const SALOMEDS::Color& theColor);
193
194     static SALOMEDS::Color GetBackground(QAD_StudyFrame* theStudyFrame);
195     virtual SALOMEDS::Color GetBackground();
196
197     virtual void Minimize();
198     virtual void Restore();
199     virtual void Maximize();
200     virtual void EraseAll();
201     virtual void DisplayAll();
202     virtual void Erase(PrsObject_ptr thePrsObj);
203     virtual void Display(PrsObject_ptr thePrsObj);
204     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
205     virtual void Update();
206
207     virtual CORBA::Boolean SavePicture(const char* theFileName);
208     
209     //View3D interface
210     virtual void FitAll();
211     virtual void SetView(VISU::View3D::ViewType theType);
212
213     static void SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]);
214     virtual void SetPointOfView(const VISU::View3D::XYZ theCoord);
215
216     static void GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]);
217     virtual VISU::View3D::XYZ_slice* GetPointOfView();
218
219     static void SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]);
220     virtual void SetViewUp(const VISU::View3D::XYZ theDir);
221
222     static void GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]);
223     virtual VISU::View3D::XYZ_slice* GetViewUp();
224
225     static void SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]);
226     virtual void SetFocalPoint(const VISU::View3D::XYZ theCoord);
227     
228     static void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]);
229     virtual VISU::View3D::XYZ_slice* GetFocalPoint();
230
231     static void SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale);
232     virtual void SetParallelScale(CORBA::Double theScale);
233     
234     static CORBA::Double GetParallelScale(QAD_StudyFrame* theStudyFrame);
235     virtual CORBA::Double GetParallelScale();
236
237     static void ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam);
238     virtual void ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam);
239     virtual void RemoveScale();
240
241     static std::string ToString(QAD_StudyFrame* theStudyFrame);
242     static void ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr);
243     static bool SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName);
244     virtual CORBA::Boolean SaveViewParams(const char* theName);
245     static QString GenerateViewParamsName();
246
247     static void Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap);
248     static bool RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName);
249     virtual CORBA::Boolean RestoreViewParams(const char* theName);
250
251     virtual void Close();
252
253   protected:
254     QAD_StudyFrame* myStudyFrame;
255     static int myNbViewParams;
256
257   public:
258     virtual Storable* Create(int theNew);
259     virtual void ToStream(std::ostringstream& theStr);
260     virtual const char* GetComment() const;
261     static const string myComment;
262     QAD_StudyFrame* GetStudyFrame() const { return myStudyFrame;}
263   };
264
265   VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame);
266   vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame);
267   vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame);
268   void RepaintView(QAD_StudyFrame* theStudyFrame);
269
270   enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
271   VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs = NULL);
272 }
273
274 #endif