1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
27 #if defined PRS_EXPORTS || defined SalomePrs_EXPORTS
28 #define PRS_EXPORT __declspec(dllexport)
30 #define PRS_EXPORT __declspec(dllimport)
37 class SALOME_Displayer;
39 class Handle_SALOME_InteractiveObject;
43 Base class for SALOME graphic object wrappers - presentations.
44 Presentations are temporary objects, so they can be created on the stack.
47 class PRS_EXPORT SALOME_Prs
51 virtual ~SALOME_Prs() {}
53 //! Key method for double dispatch of display operation
54 virtual void DisplayIn( SALOME_View* ) const = 0;
56 //! Key method for double dispatch of erase operation
57 virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
59 //! Key method for double dispatch of pre-display operation
60 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
62 //! Key method for double dispatch of post-display operation
63 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
65 //! Key method for double dispatch of pre-erase operation
66 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
68 //! Key method for double dispatch of post-erase operation
69 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
71 //! Key method for double dispatch of update operation
72 virtual void Update( SALOME_Displayer* ) = 0;
74 //! Should return true, if this presentation contains a graphic object
75 virtual bool IsNull() const = 0;
77 //! Key method for double dispatch of activation of sub-shapes selection
78 virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
83 Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
84 This intermediate class is necessary to avoid dependencies from OCC libs.
87 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
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;
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;
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;
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;
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;
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;
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* );
118 //! Key method for double dispatch of activation of sub-shapes selection
119 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
124 Base class for VTK graphic object (vtkActor) wrappers.
125 This intermediate class is necessary to avoid dependencies from VTK libs.
127 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
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;
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;
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;
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;
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;
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;
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* );
158 //! Key method for double dispatch of activation of sub-shapes selection
159 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
164 Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
166 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
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;
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;
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;
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;
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;
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;
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* );
197 //! Key method for double dispatch of activation of sub-shapes selection
198 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
202 Base classes for object wrappers for any other visualization libraries should be added here!
206 Base class for SALOME views (or view frames)
208 class PRS_EXPORT SALOME_View
212 virtual ~SALOME_View() {}
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* );
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 );
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 );
229 // Interface for derived views
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...
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...
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
249 //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
250 virtual void GlobalSelection( const bool = false ) const;
252 //! Creates empty presenation of corresponding type
253 virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; }
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* );
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* );
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 ) {}
271 \class SALOME_Displayer
272 Base class for SALOME displayers
274 class PRS_EXPORT SALOME_Displayer
278 virtual ~SALOME_Displayer() {/*! Null body here*/}
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* );
285 // Interface for derived displayers
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...
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
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