Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/visu.git] / src / VISU_I / VISU_View_i.hh
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU OBJECT : interactive object for VISU entities implementation
23 //  File   : VISU_View_i.hh
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //
27 #ifndef VISU_View_i_HeaderFile
28 #define VISU_View_i_HeaderFile
29
30 #include "VISUConfig.hh"
31 #include "SALOME_GenericObj_i.hh"
32
33 class QWidget;
34
35 class VisuGUI_TableDlg;
36
37 class SalomeApp_Application;
38
39 class SUIT_ViewManager;
40 class SUIT_ViewWindow;
41
42 class Plot2d_ViewFrame;
43
44 namespace VISU
45 {
46   class Prs3d_i;
47   class Curve_i;
48
49   class VISU_I_EXPORT View_i : public virtual POA_VISU::View,
50                                public virtual SALOME::GenericObj_i,
51                                public virtual Storable
52   {
53   public:
54     View_i (SalomeApp_Application *theApplication,
55             SUIT_ViewManager* theViewManager);
56     virtual ~View_i();
57
58   public:
59     virtual void ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state );
60     virtual CORBA::Boolean IsPartShown( VISU::View::ViewRepresentation ViewRepr );
61
62     // Begin: New methods for view parameters management
63     virtual void SplitRight();
64     virtual void SplitLeft();
65     virtual void SplitBottom();
66     virtual void SplitTop();
67
68     virtual void OnTop();
69
70     virtual void Attract   (VISU::View_ptr theView);
71     virtual void AttractAll(VISU::View_ptr theView);
72
73     virtual void SetRelativePositionInSplitter(CORBA::Double thePosition);
74     virtual void SetRelativeSizeInSplitter(CORBA::Double theSize);
75
76     virtual void SetRelativePositionX(CORBA::Double thePosition);
77     virtual void SetRelativePositionY(CORBA::Double thePosition);
78
79     virtual void SetRelativeSizeX(CORBA::Double theSize);
80     virtual void SetRelativeSizeY(CORBA::Double theSize);
81     // End: New methods for view parameters management
82
83     // Begin: Old methods for view parameters management, they don't work now
84     virtual void SetViewWidth(CORBA::Long Width);
85     virtual void SetViewHeight(CORBA::Long Height);
86     virtual CORBA::Long GetViewWidth();
87     virtual CORBA::Long GetViewHeight();
88     virtual void SetViewPositionHorizontal(VISU::View::ViewPosition ViewPosHor);
89     virtual void SetViewPositionVertical(VISU::View::ViewPosition ViewPosVer);
90     virtual void SetRelativePosition( CORBA::Double x, CORBA::Double y );
91     virtual void SetRelativeSize( CORBA::Double x, CORBA::Double y );
92     virtual void Minimize();
93     virtual void Restore();
94     virtual void Maximize();
95     // End: Old methods for view parameters management, they don't work now
96
97     virtual void SetBackground(const SALOMEDS::Color& theColor);
98     virtual SALOMEDS::Color GetBackground();
99
100     virtual void EraseAll();
101     virtual void DisplayAll();
102     virtual void Erase(PrsObject_ptr thePrsObj);
103     virtual void Display(PrsObject_ptr thePrsObj);
104     virtual void DisplayOnly(PrsObject_ptr thePrsObj);
105
106     virtual void Update();
107
108     virtual CORBA::Boolean SavePicture(const char* theFileName);
109
110     virtual void Close() = 0;
111     virtual void ToStream(std::ostringstream& theStr);
112     virtual const char* GetComment() const;
113
114     SUIT_ViewWindow* GetViewWindow();
115     void             SetViewWindow(SUIT_ViewWindow* theViewWindow);
116
117   public:
118     QWidget *myWorkspace;
119
120     SalomeApp_Application *myApplication;
121     SUIT_ViewManager      *myViewManager;
122
123   private:
124     SUIT_ViewWindow *myViewWindow;
125   };
126
127
128   //===========================================================================
129   class VISU_I_EXPORT XYPlot_i : public virtual POA_VISU::XYPlot,
130                                  public virtual View_i
131   {
132   public:
133     typedef VISU::XYPlot TInterface;
134
135     XYPlot_i (SalomeApp_Application *theApplication);
136     virtual ~XYPlot_i();
137
138     virtual VISU::VISUType GetType() { return VISU::TXYPLOT; };
139
140     virtual void SetTitle (const char* theTitle);
141     virtual char* GetTitle();
142
143     virtual void SetSubTitle (const char* theTitle);
144     virtual char* GetSubTitle();
145
146     virtual void SetCurveType (VISU::XYPlot::CurveType theType);
147     virtual VISU::XYPlot::CurveType GetCurveType();
148
149     virtual void SetMarkerSize (CORBA::Long theSize);
150     virtual CORBA::Long GetMarkerSize();
151
152     virtual void EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
153                               CORBA::Boolean theMinor, CORBA::Long theNumMinor);
154     virtual void EnableYGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
155                               CORBA::Boolean theMinor, CORBA::Long theNumMinor);
156
157     virtual void EnableYGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
158                               CORBA::Boolean theMinor, CORBA::Long theNumMinor,
159                               CORBA::Boolean the2Major, CORBA::Long the2NumMajor,
160                               CORBA::Boolean the2Minor, CORBA::Long the2NumMinor);
161                               
162     virtual void SetHorScaling (VISU::Scaling theScaling);
163     virtual VISU::Scaling GetHorScaling();
164     virtual void SetVerScaling (VISU::Scaling theScaling);
165     virtual VISU::Scaling GetVerScaling();
166
167     virtual void SetXTitle (const char* theTitle);
168     virtual char* GetXTitle();
169
170     virtual void SetYTitle (const char* theTitle);
171     virtual char* GetYTitle();
172
173     virtual void ShowLegend (CORBA::Boolean theShowing);
174
175     virtual void EraseAll();
176     virtual void Erase (PrsObject_ptr thePrsObj);
177     virtual void Display (PrsObject_ptr thePrsObj);
178     virtual void DisplayOnly (PrsObject_ptr thePrsObj);
179     virtual void Update();
180
181     virtual void FitAll();
182     virtual void FitXRange(CORBA::Double xMin, CORBA::Double xMax);
183     virtual void FitYRange(CORBA::Double yMin, CORBA::Double yMax);
184     virtual void FitRange(CORBA::Double xMin, CORBA::Double xMax,
185                                       CORBA::Double yMin, CORBA::Double yMax);
186     virtual void GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax);
187
188     virtual void Close();
189   protected:
190     Plot2d_ViewFrame* myView;
191   public:
192     virtual Storable* Create (int theNew);
193   };
194
195
196   //===========================================================================
197   class VISU_I_EXPORT TableView_i : public virtual POA_VISU::TableView,
198                       public virtual View_i
199   {
200   public:
201     typedef VISU::TableView TInterface;
202
203     TableView_i (SalomeApp_Application *theApplication);
204     virtual ~TableView_i();
205
206     virtual VISU::VISUType GetType() { return VISU::TTABLEVIEW; };
207
208     virtual void SetTitle (const char* theTitle);
209     virtual char* GetTitle();
210
211     virtual void Close();
212   protected:
213     VisuGUI_TableDlg* myView;
214   public:
215     virtual Storable* Create (VISU::Table_ptr theTable);
216   };
217
218
219   //===========================================================================
220   class VISU_I_EXPORT View3D_i : public virtual POA_VISU::View3D,
221                                  public virtual View_i
222   {
223   public:
224     typedef VISU::View3D TInterface;
225
226     View3D_i (SalomeApp_Application *theApplication);
227     virtual ~View3D_i();
228
229     virtual VISU::VISUType GetType() { return VISU::TVIEW3D; };
230
231     //View interface
232     virtual void SetTitle (const char* theTitle);
233     virtual char* GetTitle();
234
235     static  void SetBackground (SUIT_ViewWindow* theViewWindow,
236                                 const SALOMEDS::Color& theColor);
237
238     static  SALOMEDS::Color GetBackground (SUIT_ViewWindow* theViewWindow);
239
240     virtual void EraseAll();
241     virtual void DisplayAll();
242     virtual void Erase (PrsObject_ptr thePrsObj);
243     virtual void Display (PrsObject_ptr thePrsObj);
244     virtual void DisplayOnly (PrsObject_ptr thePrsObj);
245     virtual void Update();
246
247     //View3D interface
248     virtual void FitAll();
249     virtual void SetView (VISU::View3D::ViewType theType);
250
251     static  void SetPointOfView (SUIT_ViewWindow* theViewWindow,
252                                  const CORBA::Double thePosition[3]);
253     virtual void SetPointOfView (const VISU::View3D::XYZ theCoord);
254
255     static  void GetPointOfView (SUIT_ViewWindow* theViewWindow,
256                                  CORBA::Double thePosition[3]);
257     virtual VISU::View3D::XYZ_slice* GetPointOfView();
258
259     static  void SetViewUp (SUIT_ViewWindow* theViewWindow,
260                             const CORBA::Double theViewUp[3]);
261     virtual void SetViewUp (const VISU::View3D::XYZ theDir);
262
263     static  void GetViewUp (SUIT_ViewWindow* theViewWindow, CORBA::Double theViewUp[3]);
264     virtual VISU::View3D::XYZ_slice* GetViewUp();
265
266     static  void SetFocalPoint (SUIT_ViewWindow* theViewWindow, const CORBA::Double theFocalPnt[3]);
267     virtual void SetFocalPoint (const VISU::View3D::XYZ theCoord);
268
269     static  void GetFocalPoint (SUIT_ViewWindow* theViewWindow, CORBA::Double theFocalPnt[3]);
270     virtual VISU::View3D::XYZ_slice* GetFocalPoint();
271
272     static  void SetParallelScale (SUIT_ViewWindow* theViewWindow, CORBA::Double theScale);
273     virtual void SetParallelScale (CORBA::Double theScale);
274
275     static  CORBA::Double GetParallelScale (SUIT_ViewWindow* theViewWindow);
276     virtual CORBA::Double GetParallelScale ();
277
278     static  void ScaleView (SUIT_ViewWindow* theViewWindow,
279                             VISU::View3D::Axis theAxis, CORBA::Double theParam);
280     virtual void ScaleView (VISU::View3D::Axis theAxis, CORBA::Double theParam);
281     virtual void RemoveScale();
282
283     static std::string ToString (SUIT_ViewWindow* theViewWindow);
284
285     static void ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr);
286
287     static  bool           SaveViewParams (SUIT_ViewManager* theViewManager,
288                                            const std::string& theName);
289     virtual CORBA::Boolean SaveViewParams (const char* theViewParamsName);
290
291     static  bool           RestoreViewParams (SUIT_ViewManager* theViewManager,
292                                               const std::string& theName);
293     virtual CORBA::Boolean RestoreViewParams (const char* theViewParamsName);
294
295     static QString GenerateViewParamsName();
296
297     static  void Restore (SUIT_ViewWindow* theViewWindow,
298                           const Storable::TRestoringMap& theMap);
299
300     virtual void Close();
301
302     // Certain presentation view parameters management
303     virtual PresentationType GetPresentationType(ScalarMap_ptr thePrs);
304     virtual CORBA::Boolean   IsShrinked         (ScalarMap_ptr thePrs);
305     virtual CORBA::Boolean   IsShaded           (ScalarMap_ptr thePrs);
306     virtual CORBA::Double    GetOpacity         (ScalarMap_ptr thePrs);
307     virtual CORBA::Double    GetLineWidth       (ScalarMap_ptr thePrs);
308
309     virtual char* SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType);
310     virtual char* SetShrinked        (ScalarMap_ptr thePrs, CORBA::Boolean   isShrinked);
311     virtual char* SetShaded          (ScalarMap_ptr thePrs, CORBA::Boolean   isShaded);
312     virtual char* SetOpacity         (ScalarMap_ptr thePrs, CORBA::Double    theOpacity);
313     virtual char* SetLineWidth       (ScalarMap_ptr thePrs, CORBA::Double    theLineWidth);
314
315   protected:
316     static int myNbViewParams;
317
318   public:
319     virtual Storable* Create (int theNew);
320     virtual void ToStream (std::ostringstream& theStr);
321     virtual const char* GetComment() const;
322     static const std::string myComment;
323   };
324 }
325
326 #endif