1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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 SALOME_Prs() : myIsClippable (true) {};
54 virtual ~SALOME_Prs() {}
56 //! Key method for double dispatch of display operation
57 virtual void DisplayIn( SALOME_View* ) const = 0;
59 //! Key method for double dispatch of erase operation
60 virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
62 //! Key method for double dispatch of pre-display operation
63 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
65 //! Key method for double dispatch of post-display operation
66 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
68 //! Key method for double dispatch of pre-erase operation
69 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
71 //! Key method for double dispatch of post-erase operation
72 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
74 //! Key method for double dispatch of update operation
75 virtual void Update( SALOME_Displayer* ) = 0;
77 //! Should return true, if this presentation contains a graphic object
78 virtual bool IsNull() const = 0;
80 //! Key method for double dispatch of activation of sub-shapes selection
81 virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
83 // checks if shape is clippable
84 inline bool IsClippable() const
89 // makes shape clippable/not clippable
90 inline void SetClippable (bool isClippable)
92 myIsClippable = isClippable;
102 Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
103 This intermediate class is necessary to avoid dependencies from OCC libs.
106 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
109 //! It uses double dispatch in order to
110 //! invoke Display() method corresponding to the actual type of presentation.
111 virtual void DisplayIn( SALOME_View* ) const;
113 //! It uses double dispatch in order to
114 //! invoke Erase() method corresponding to the actual type of presentation.
115 virtual void EraseIn( SALOME_View*, const bool = false ) const;
117 //! It uses double dispatch in order to
118 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
119 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
121 //! It uses double dispatch in order to
122 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
123 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
125 //! It uses double dispatch in order to
126 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
127 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
129 //! It uses double dispatch in order to
130 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
131 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
133 //! It uses double dispatch in order to
134 //! invoke Update() method corresponding to the actual type of presentation.
135 virtual void Update( SALOME_Displayer* );
137 //! Key method for double dispatch of activation of sub-shapes selection
138 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
143 Base class for VTK graphic object (vtkActor) wrappers.
144 This intermediate class is necessary to avoid dependencies from VTK libs.
146 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
149 //! It uses double dispatch in order to
150 //! invoke Display() method corresponding to the actual type of presentation.
151 virtual void DisplayIn( SALOME_View* ) const;
153 //! It uses double dispatch in order to
154 //! invoke Erase() method corresponding to the actual type of presentation.
155 virtual void EraseIn( SALOME_View*, const bool = false ) const;
157 //! It uses double dispatch in order to
158 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
159 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
161 //! It uses double dispatch in order to
162 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
163 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
165 //! It uses double dispatch in order to
166 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
167 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
169 //! It uses double dispatch in order to
170 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
171 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
173 //! It uses double dispatch in order to
174 //! invoke Update() method corresponding to the actual type of presentation.
175 virtual void Update( SALOME_Displayer* );
177 //! Key method for double dispatch of activation of sub-shapes selection
178 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
183 Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
185 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
188 //! It uses double dispatch in order to
189 //! invoke Display() method corresponding to the actual type of presentation.
190 virtual void DisplayIn( SALOME_View* ) const;
192 //! It uses double dispatch in order to
193 //! invoke Erase() method corresponding to the actual type of presentation.
194 virtual void EraseIn( SALOME_View*, const bool = false ) const;
196 //! It uses double dispatch in order to
197 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
198 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
200 //! It uses double dispatch in order to
201 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
202 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
204 //! It uses double dispatch in order to
205 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
206 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
208 //! It uses double dispatch in order to
209 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
210 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
212 //! It uses double dispatch in order to
213 //! invoke Update() method corresponding to the actual type of presentation.
214 virtual void Update( SALOME_Displayer* );
216 //! Key method for double dispatch of activation of sub-shapes selection
217 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
221 Base classes for object wrappers for any other visualization libraries should be added here!
225 Base class for SALOME views (or view frames)
227 class PRS_EXPORT SALOME_View
231 virtual ~SALOME_View() {}
233 //! This Display() method should be called to display given presentation
234 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
235 //! so that it could perform double dispatch.
236 void Display( const SALOME_Prs* );
238 //! This Erase() method should be called to erase given presentation
239 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
240 //! so that it could perform double dispatch.
241 void Erase( const SALOME_Prs*, const bool = false );
243 //! This LocalSelection() method should be called to activate sub-shapes selection
244 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
245 //! so that it could perform double dispatch.
246 void LocalSelection( const SALOME_Prs*, const int );
248 // Interface for derived views
250 // Display() methods for ALL kinds of presentation should appear here
251 virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation.
252 virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation.
253 virtual void Display( const SALOME_Prs2d* );//!< Display SALOME_Prs2d presentation.
254 // Add new Display() methods here...
256 // Erase() methods for ALL kinds of presentation should appear here
257 virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs
258 virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs
259 virtual void Erase( const SALOME_Prs2d*, const bool = false );//!< Erase SALOME_Prs2d
260 virtual void EraseAll( const bool = false );
261 // Add new Erase() methods here...
263 // LocalSelection() methods for ALL kinds of presentation should appear here
264 virtual void LocalSelection( const SALOME_OCCPrs*, const int );//!< Local selection SALOME_OCCPrs
265 virtual void LocalSelection( const SALOME_VTKPrs*, const int );//!< Local selection SALOME_VTKPrs
266 virtual void LocalSelection( const SALOME_Prs2d* , const int );//!< Local selection SALOME_Prs2d
268 //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
269 virtual void GlobalSelection( const bool = false ) const;
271 //! Creates empty presenation of corresponding type
272 virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; }
274 // Axiluary methods called before and after displaying of objects
275 virtual void BeforeDisplay( SALOME_Displayer*, const SALOME_Prs* );
276 virtual void AfterDisplay ( SALOME_Displayer*, const SALOME_Prs* );
278 // Axiluary methods called before and after erasing of objects
279 virtual void BeforeErase( SALOME_Displayer*, const SALOME_Prs* );
280 virtual void AfterErase ( SALOME_Displayer*, const SALOME_Prs* );
283 //! \retval Return false.
284 virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
285 virtual void Repaint() {} //!< Null body here.
286 virtual void GetVisible( SALOME_ListIO& theList ) {}
290 \class SALOME_Displayer
291 Base class for SALOME displayers
293 class PRS_EXPORT SALOME_Displayer
297 virtual ~SALOME_Displayer() {/*! Null body here*/}
299 //! This Update() method should be called to update given presentation
300 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
301 //! so that it could perform double dispatch.
302 void UpdatePrs( SALOME_Prs* );
304 // Interface for derived displayers
306 // Update() methods for ALL kinds of presentation should appear here
307 virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation.
308 virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation.
309 virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation.
310 // Add new Update() methods here...
312 // Axiluary methods called before and after displaying of objects
313 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
314 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
315 virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
316 virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
317 virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
318 virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
320 // Axiluary methods called before and after erasing of objects
321 virtual void BeforeErase( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
322 virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
323 virtual void BeforeErase( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
324 virtual void AfterErase ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
325 virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
326 virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here