Salome HOME
Merge from V6_main 01/04/2013
[modules/gui.git] / src / Prs / SALOME_Prs.h
1 // Copyright (C) 2007-2013  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
23 #ifndef SALOME_PRS_H
24 #define SALOME_PRS_H
25
26 #ifdef WIN32
27 #if defined PRS_EXPORTS || defined SalomePrs_EXPORTS
28 #define PRS_EXPORT __declspec(dllexport)
29 #else
30 #define PRS_EXPORT __declspec(dllimport)
31 #endif
32 #else
33 #define PRS_EXPORT
34 #endif
35
36 class SALOME_View;
37 class SALOME_Displayer;
38 class SALOME_ListIO;
39 class Handle_SALOME_InteractiveObject;
40
41 /*!
42  \class SALOME_Prs
43  Base class for SALOME graphic object wrappers - presentations.
44  Presentations are temporary objects, so they can be created on the stack.
45 */
46
47 class PRS_EXPORT SALOME_Prs
48 {
49 public:
50   //! Destructor
51   virtual ~SALOME_Prs() {}
52
53   //! Key method for double dispatch of display operation
54   virtual void DisplayIn( SALOME_View* ) const = 0;
55
56   //! Key method for double dispatch of erase operation
57   virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
58
59   //! Key method for double dispatch of pre-display operation
60   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
61
62   //! Key method for double dispatch of post-display operation
63   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
64
65   //! Key method for double dispatch of pre-erase operation
66   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
67
68   //! Key method for double dispatch of post-erase operation
69   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
70
71   //! Key method for double dispatch of update operation
72   virtual void Update( SALOME_Displayer* ) = 0;
73
74   //! Should return true, if this presentation contains a graphic object
75   virtual bool IsNull() const = 0;
76
77   //! Key method for double dispatch of activation of sub-shapes selection
78   virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
79 };
80
81 /*!
82  \class SALOME_OCCPrs
83  Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
84  This intermediate class is necessary to avoid dependencies from OCC libs.
85 */
86
87 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
88 {
89 public:
90   //! It uses double dispatch in order to
91   //! invoke Display() method corresponding to the actual type of presentation.
92   virtual void DisplayIn( SALOME_View* ) const;
93
94   //! It uses double dispatch in order to
95   //! invoke Erase() method corresponding to the actual type of presentation.
96   virtual void EraseIn( SALOME_View*, const bool = false ) const;
97
98   //! It uses double dispatch in order to
99   //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
100   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
101
102   //! It uses double dispatch in order to
103   //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
104   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
105
106   //! It uses double dispatch in order to
107   //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
108   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
109
110   //! It uses double dispatch in order to
111   //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
112   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
113
114   //! It uses double dispatch in order to
115   //! invoke Update() method corresponding to the actual type of presentation.
116   virtual void Update( SALOME_Displayer* );
117
118   //! Key method for double dispatch of activation of sub-shapes selection
119   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
120 };
121
122 /*!
123  \class SALOME_VTKPrs
124  Base class for VTK graphic object (vtkActor) wrappers.
125  This intermediate class is necessary to avoid dependencies from VTK libs.
126 */
127 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
128 {
129 public:
130   //! It uses double dispatch in order to
131   //! invoke Display() method corresponding to the actual type of presentation.
132   virtual void DisplayIn( SALOME_View* ) const;
133
134   //! It uses double dispatch in order to
135   //! invoke Erase() method corresponding to the actual type of presentation.
136   virtual void EraseIn( SALOME_View*, const bool = false ) const;
137
138   //! It uses double dispatch in order to
139   //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
140   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
141
142   //! It uses double dispatch in order to
143   //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
144   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
145
146   //! It uses double dispatch in order to
147   //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
148   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
149
150   //! It uses double dispatch in order to
151   //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
152   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
153
154   //! It uses double dispatch in order to
155   //! invoke Update() method corresponding to the actual type of presentation.
156   virtual void Update( SALOME_Displayer* );
157
158   //! Key method for double dispatch of activation of sub-shapes selection
159   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
160 };
161
162 /*!
163  \class SALOME_Prs2d
164  Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
165 */
166 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
167 {
168 public:
169   //! It uses double dispatch in order to
170   //! invoke Display() method corresponding to the actual type of presentation.
171   virtual void DisplayIn( SALOME_View* ) const;
172
173   //! It uses double dispatch in order to
174   //! invoke Erase() method corresponding to the actual type of presentation.
175   virtual void EraseIn( SALOME_View*, const bool = false ) const;
176
177   //! It uses double dispatch in order to
178   //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
179   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
180
181   //! It uses double dispatch in order to
182   //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
183   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
184
185   //! It uses double dispatch in order to
186   //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
187   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
188
189   //! It uses double dispatch in order to
190   //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
191   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
192
193   //! It uses double dispatch in order to
194   //! invoke Update() method corresponding to the actual type of presentation.
195   virtual void Update( SALOME_Displayer* );
196
197   //! Key method for double dispatch of activation of sub-shapes selection
198   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
199 };
200
201 /*!
202   Base classes for object wrappers for any other visualization libraries should be added here!
203 */
204 /*!
205  \class SALOME_View
206  Base class for SALOME views (or view frames)
207 */
208 class PRS_EXPORT SALOME_View
209 {
210 public:
211   //! Destructor
212   virtual ~SALOME_View() {}
213
214   //! This Display() method should be called to display given presentation
215   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
216   //! so that it could perform double dispatch.
217   void Display( const SALOME_Prs* );
218
219   //! This Erase() method should be called to erase given presentation
220   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
221   //! so that it could perform double dispatch.
222   void Erase( const SALOME_Prs*, const bool = false );
223
224   //! This LocalSelection() method should be called to activate sub-shapes selection
225   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
226   //! so that it could perform double dispatch.
227   void LocalSelection( const SALOME_Prs*, const int );
228
229   // Interface for derived views
230
231   // Display() methods for ALL kinds of presentation should appear here
232   virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation.
233   virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation.
234   virtual void Display( const SALOME_Prs2d*  );//!< Display SALOME_Prs2d  presentation.
235   // Add new Display() methods here...
236
237   // Erase() methods for ALL kinds of presentation should appear here
238   virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs
239   virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs
240   virtual void Erase( const SALOME_Prs2d*,  const bool = false );//!< Erase SALOME_Prs2d
241   virtual void EraseAll( const bool = false );
242   // Add new Erase() methods here...
243
244   // LocalSelection() methods for ALL kinds of presentation should appear here
245   virtual void LocalSelection( const SALOME_OCCPrs*, const int );//!< Local selection SALOME_OCCPrs
246   virtual void LocalSelection( const SALOME_VTKPrs*, const int );//!< Local selection SALOME_VTKPrs
247   virtual void LocalSelection( const SALOME_Prs2d* , const int );//!< Local selection SALOME_Prs2d
248
249   //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
250   virtual void GlobalSelection( const bool = false ) const;
251
252   //! Creates empty presenation of corresponding type
253   virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; }
254
255   // Axiluary methods called before and after displaying of objects
256   virtual void BeforeDisplay( SALOME_Displayer*, const SALOME_Prs* );
257   virtual void AfterDisplay ( SALOME_Displayer*, const SALOME_Prs* );
258
259   // Axiluary methods called before and after erasing of objects
260   virtual void BeforeErase( SALOME_Displayer*, const SALOME_Prs* );
261   virtual void AfterErase ( SALOME_Displayer*, const SALOME_Prs* );
262
263   // New methods (asv)
264   //! \retval Return false.
265   virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
266   virtual void Repaint() {} //!< Null body here.
267   virtual void GetVisible( SALOME_ListIO& theList ) {}
268 };
269
270 /*!
271  \class SALOME_Displayer
272  Base class for SALOME displayers
273 */
274 class PRS_EXPORT SALOME_Displayer
275 {
276 public:
277   //! Destructor
278   virtual ~SALOME_Displayer() {/*! Null body here*/}
279
280   //! This Update() method should be called to update given presentation
281   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
282   //! so that it could perform double dispatch.
283   void UpdatePrs( SALOME_Prs* );
284
285   // Interface for derived displayers
286
287   // Update() methods for ALL kinds of presentation should appear here
288   virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation.
289   virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation.
290   virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation.
291   // Add new Update() methods here...
292
293   // Axiluary methods called before and after displaying of objects
294   virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
295   virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
296   virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
297   virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
298   virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
299   virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
300
301   // Axiluary methods called before and after erasing of objects
302   virtual void BeforeErase( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
303   virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
304   virtual void BeforeErase( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
305   virtual void AfterErase ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
306   virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
307   virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
308
309 };
310
311 #endif