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;
46 Base class for SALOME graphic object wrappers - presentations.
47 Presentations are temporary objects, so they can be created on the stack.
50 class PRS_EXPORT SALOME_Prs
54 explicit SALOME_Prs( const char* );
57 virtual ~SALOME_Prs() {}
60 const char* GetEntry() const;
62 //! Key method for double dispatch of display operation
63 virtual void DisplayIn( SALOME_View* ) const = 0;
65 //! Key method for double dispatch of erase operation
66 virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
68 //! Key method for double dispatch of pre-display operation
69 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
71 //! Key method for double dispatch of post-display operation
72 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
74 //! Key method for double dispatch of pre-erase operation
75 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
77 //! Key method for double dispatch of post-erase operation
78 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
80 //! Key method for double dispatch of update operation
81 virtual void Update( SALOME_Displayer* ) = 0;
83 //! Should return true, if this presentation contains a graphic object
84 virtual bool IsNull() const = 0;
86 //! Key method for double dispatch of activation of sub-shapes selection
87 virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
88 virtual void LocalSelectionIn( SALOME_View*, const std::list<int> ) const;
90 // checks if shape is clippable
91 inline bool IsClippable() const
96 // makes shape clippable/not clippable
97 inline void SetClippable (bool isClippable)
99 myIsClippable = isClippable;
109 Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
110 This intermediate class is necessary to avoid dependencies from OCC libs.
113 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
117 explicit SALOME_OCCPrs(const char* e) : SALOME_Prs(e) {}
119 //! It uses double dispatch in order to
120 //! invoke Display() method corresponding to the actual type of presentation.
121 virtual void DisplayIn( SALOME_View* ) const;
123 //! It uses double dispatch in order to
124 //! invoke Erase() method corresponding to the actual type of presentation.
125 virtual void EraseIn( SALOME_View*, const bool = false ) const;
127 //! It uses double dispatch in order to
128 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
129 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
131 //! It uses double dispatch in order to
132 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
133 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
135 //! It uses double dispatch in order to
136 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
137 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
139 //! It uses double dispatch in order to
140 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
141 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
143 //! It uses double dispatch in order to
144 //! invoke Update() method corresponding to the actual type of presentation.
145 virtual void Update( SALOME_Displayer* );
147 //! Key method for double dispatch of activation of sub-shapes selection
148 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
149 virtual void LocalSelectionIn( SALOME_View*, const std::list<int> ) const;
154 Base class for VTK graphic object (vtkActor) wrappers.
155 This intermediate class is necessary to avoid dependencies from VTK libs.
157 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
161 explicit SALOME_VTKPrs(const char* e) : SALOME_Prs(e) {}
163 //! It uses double dispatch in order to
164 //! invoke Display() method corresponding to the actual type of presentation.
165 virtual void DisplayIn( SALOME_View* ) const;
167 //! It uses double dispatch in order to
168 //! invoke Erase() method corresponding to the actual type of presentation.
169 virtual void EraseIn( SALOME_View*, const bool = false ) const;
171 //! It uses double dispatch in order to
172 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
173 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
175 //! It uses double dispatch in order to
176 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
177 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
179 //! It uses double dispatch in order to
180 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
181 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
183 //! It uses double dispatch in order to
184 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
185 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
187 //! It uses double dispatch in order to
188 //! invoke Update() method corresponding to the actual type of presentation.
189 virtual void Update( SALOME_Displayer* );
191 //! Key method for double dispatch of activation of sub-shapes selection
192 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
197 Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
199 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
203 explicit SALOME_Prs2d(const char* e) : SALOME_Prs(e) {}
205 //! It uses double dispatch in order to
206 //! invoke Display() method corresponding to the actual type of presentation.
207 virtual void DisplayIn( SALOME_View* ) const;
209 //! It uses double dispatch in order to
210 //! invoke Erase() method corresponding to the actual type of presentation.
211 virtual void EraseIn( SALOME_View*, const bool = false ) const;
213 //! It uses double dispatch in order to
214 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
215 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
217 //! It uses double dispatch in order to
218 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
219 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
221 //! It uses double dispatch in order to
222 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
223 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
225 //! It uses double dispatch in order to
226 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
227 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
229 //! It uses double dispatch in order to
230 //! invoke Update() method corresponding to the actual type of presentation.
231 virtual void Update( SALOME_Displayer* );
233 //! Key method for double dispatch of activation of sub-shapes selection
234 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
238 Base classes for object wrappers for any other visualization libraries should be added here!
242 Base class for SALOME views (or view frames)
244 class PRS_EXPORT SALOME_View
248 virtual ~SALOME_View() {}
250 //! This Display() method should be called to display given presentation
251 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
252 //! so that it could perform double dispatch.
253 void Display( SALOME_Displayer*, const SALOME_Prs* );
255 //! This Erase() method should be called to erase given presentation
256 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
257 //! so that it could perform double dispatch.
258 void Erase( SALOME_Displayer*, const SALOME_Prs*, const bool = false );
260 //! This EraseAll() method should be called to erase all presentations
261 //! created anywhere by anybody.
262 virtual void EraseAll( SALOME_Displayer*, const bool = false );
264 //! This LocalSelection() method should be called to activate sub-shapes selection
265 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
266 //! so that it could perform double dispatch.
267 void LocalSelection( const SALOME_Prs*, const int );
268 void LocalSelection( const SALOME_Prs*, const std::list<int> );
270 // Interface for derived views
272 // Display() methods for ALL kinds of presentation should appear here
273 virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation.
274 virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation.
275 virtual void Display( const SALOME_Prs2d* );//!< Display SALOME_Prs2d presentation.
276 // Add new Display() methods here...
278 // Erase() methods for ALL kinds of presentation should appear here
279 virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs
280 virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs
281 virtual void Erase( const SALOME_Prs2d*, const bool = false );//!< Erase SALOME_Prs2d
282 // Add new Erase() methods here...
284 // LocalSelection() methods for ALL kinds of presentation should appear here
285 virtual void LocalSelection( const SALOME_OCCPrs*, const int ); //!< Local selection SALOME_OCCPrs
286 virtual void LocalSelection( const SALOME_OCCPrs*, const std::list<int> );//!< Multiple local selection SALOME_OCCPrs
287 virtual void LocalSelection( const SALOME_VTKPrs*, const int ); //!< Local selection SALOME_VTKPrs
288 virtual void LocalSelection( const SALOME_Prs2d* , const int ); //!< Local selection SALOME_Prs2d
290 //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
291 virtual void GlobalSelection( const bool = false ) const;
293 //! Creates empty presenation of corresponding type
294 virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; }
296 // Axiluary methods called before and after displaying of objects
297 virtual void BeforeDisplay( SALOME_Displayer*, const SALOME_Prs* );
298 virtual void AfterDisplay ( SALOME_Displayer*, const SALOME_Prs* );
300 // Axiluary methods called before and after erasing of objects
301 virtual void BeforeErase( SALOME_Displayer*, const SALOME_Prs* );
302 virtual void AfterErase ( SALOME_Displayer*, const SALOME_Prs* );
305 //! \retval Return false.
306 virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
307 virtual void Repaint() {} //!< Null body here.
308 virtual void GetVisible( SALOME_ListIO& theList ) {}
312 \class SALOME_Displayer
313 Base class for SALOME displayers
315 class PRS_EXPORT SALOME_Displayer
319 virtual ~SALOME_Displayer() {/*! Null body here*/}
321 //! This Update() method should be called to update given presentation
322 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
323 //! so that it could perform double dispatch.
324 void UpdatePrs( SALOME_Prs* );
326 // Interface for derived displayers
328 // Update() methods for ALL kinds of presentation should appear here
329 virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation.
330 virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation.
331 virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation.
332 // Add new Update() methods here...
334 // Axiluary methods called before and after displaying of objects
335 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
336 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
337 virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
338 virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
339 virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
340 virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
342 // Axiluary methods called before and after erasing of objects
343 virtual void BeforeErase( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
344 virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
345 virtual void BeforeErase( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
346 virtual void AfterErase ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
347 virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
348 virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
350 // Axiluary method called to update visibility state of presentation
351 virtual void UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool );