1 // Copyright (C) 2007-2016 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)
39 #include <Standard_DefineHandle.hxx>
42 class SALOME_Displayer;
44 class SALOME_InteractiveObject;
48 Base class for SALOME graphic object wrappers - presentations.
49 Presentations are temporary objects, so they can be created on the stack.
52 class PRS_EXPORT SALOME_Prs
56 explicit SALOME_Prs( const char* );
59 virtual ~SALOME_Prs() {}
62 const char* GetEntry() const;
64 //! Key method for double dispatch of display operation
65 virtual void DisplayIn( SALOME_View* ) const = 0;
67 //! Key method for double dispatch of erase operation
68 virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
70 //! Key method for double dispatch of pre-display operation
71 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
73 //! Key method for double dispatch of post-display operation
74 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
76 //! Key method for double dispatch of pre-erase operation
77 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
79 //! Key method for double dispatch of post-erase operation
80 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
82 //! Key method for double dispatch of update operation
83 virtual void Update( SALOME_Displayer* ) = 0;
85 //! Should return true, if this presentation contains a graphic object
86 virtual bool IsNull() const = 0;
88 //! Key method for double dispatch of activation of sub-shapes selection
89 virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
90 virtual void LocalSelectionIn( SALOME_View*, const std::list<int> ) const;
92 // checks if shape is clippable
93 inline bool IsClippable() const
98 // makes shape clippable/not clippable
99 inline void SetClippable (bool isClippable)
101 myIsClippable = isClippable;
111 Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
112 This intermediate class is necessary to avoid dependencies from OCC libs.
115 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
119 explicit SALOME_OCCPrs(const char* e) : SALOME_Prs(e) {}
121 //! It uses double dispatch in order to
122 //! invoke Display() method corresponding to the actual type of presentation.
123 virtual void DisplayIn( SALOME_View* ) const;
125 //! It uses double dispatch in order to
126 //! invoke Erase() method corresponding to the actual type of presentation.
127 virtual void EraseIn( SALOME_View*, const bool = false ) const;
129 //! It uses double dispatch in order to
130 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
131 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
133 //! It uses double dispatch in order to
134 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
135 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
137 //! It uses double dispatch in order to
138 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
139 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
141 //! It uses double dispatch in order to
142 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
143 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
145 //! It uses double dispatch in order to
146 //! invoke Update() method corresponding to the actual type of presentation.
147 virtual void Update( SALOME_Displayer* );
149 //! Key method for double dispatch of activation of sub-shapes selection
150 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
151 virtual void LocalSelectionIn( SALOME_View*, const std::list<int> ) const;
156 Base class for VTK graphic object (vtkActor) wrappers.
157 This intermediate class is necessary to avoid dependencies from VTK libs.
159 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
163 explicit SALOME_VTKPrs(const char* e) : SALOME_Prs(e) {}
165 //! It uses double dispatch in order to
166 //! invoke Display() method corresponding to the actual type of presentation.
167 virtual void DisplayIn( SALOME_View* ) const;
169 //! It uses double dispatch in order to
170 //! invoke Erase() method corresponding to the actual type of presentation.
171 virtual void EraseIn( SALOME_View*, const bool = false ) const;
173 //! It uses double dispatch in order to
174 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
175 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
177 //! It uses double dispatch in order to
178 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
179 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
181 //! It uses double dispatch in order to
182 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
183 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
185 //! It uses double dispatch in order to
186 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
187 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
189 //! It uses double dispatch in order to
190 //! invoke Update() method corresponding to the actual type of presentation.
191 virtual void Update( SALOME_Displayer* );
193 //! Key method for double dispatch of activation of sub-shapes selection
194 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
199 Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
201 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
205 explicit SALOME_Prs2d(const char* e) : SALOME_Prs(e) {}
207 //! It uses double dispatch in order to
208 //! invoke Display() method corresponding to the actual type of presentation.
209 virtual void DisplayIn( SALOME_View* ) const;
211 //! It uses double dispatch in order to
212 //! invoke Erase() method corresponding to the actual type of presentation.
213 virtual void EraseIn( SALOME_View*, const bool = false ) const;
215 //! It uses double dispatch in order to
216 //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
217 virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
219 //! It uses double dispatch in order to
220 //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
221 virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
223 //! It uses double dispatch in order to
224 //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
225 virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
227 //! It uses double dispatch in order to
228 //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
229 virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
231 //! It uses double dispatch in order to
232 //! invoke Update() method corresponding to the actual type of presentation.
233 virtual void Update( SALOME_Displayer* );
235 //! Key method for double dispatch of activation of sub-shapes selection
236 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
240 Base classes for object wrappers for any other visualization libraries should be added here!
244 Base class for SALOME views (or view frames)
246 class PRS_EXPORT SALOME_View
250 virtual ~SALOME_View() {}
252 //! This Display() method should be called to display given presentation
253 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
254 //! so that it could perform double dispatch.
255 void Display( SALOME_Displayer*, const SALOME_Prs* );
257 //! This Erase() method should be called to erase given presentation
258 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
259 //! so that it could perform double dispatch.
260 void Erase( SALOME_Displayer*, const SALOME_Prs*, const bool = false );
262 //! This EraseAll() method should be called to erase all presentations
263 //! created anywhere by anybody.
264 virtual void EraseAll( SALOME_Displayer*, const bool = false );
266 //! This LocalSelection() method should be called to activate sub-shapes selection
267 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
268 //! so that it could perform double dispatch.
269 void LocalSelection( const SALOME_Prs*, const int );
270 void LocalSelection( const SALOME_Prs*, const std::list<int> );
272 // Interface for derived views
274 // Display() methods for ALL kinds of presentation should appear here
275 virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation.
276 virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation.
277 virtual void Display( const SALOME_Prs2d* );//!< Display SALOME_Prs2d presentation.
278 // Add new Display() methods here...
280 // Erase() methods for ALL kinds of presentation should appear here
281 virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs
282 virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs
283 virtual void Erase( const SALOME_Prs2d*, const bool = false );//!< Erase SALOME_Prs2d
284 // Add new Erase() methods here...
286 // LocalSelection() methods for ALL kinds of presentation should appear here
287 virtual void LocalSelection( const SALOME_OCCPrs*, const int ); //!< Local selection SALOME_OCCPrs
288 virtual void LocalSelection( const SALOME_OCCPrs*, const std::list<int> );//!< Multiple local selection SALOME_OCCPrs
289 virtual void LocalSelection( const SALOME_VTKPrs*, const int ); //!< Local selection SALOME_VTKPrs
290 virtual void LocalSelection( const SALOME_Prs2d* , const int ); //!< Local selection SALOME_Prs2d
292 //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
293 virtual void GlobalSelection( const bool = false ) const;
295 //! Creates empty presenation of corresponding type
296 virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; }
298 // Axiluary methods called before and after displaying of objects
299 virtual void BeforeDisplay( SALOME_Displayer*, const SALOME_Prs* );
300 virtual void AfterDisplay ( SALOME_Displayer*, const SALOME_Prs* );
302 // Axiluary methods called before and after erasing of objects
303 virtual void BeforeErase( SALOME_Displayer*, const SALOME_Prs* );
304 virtual void AfterErase ( SALOME_Displayer*, const SALOME_Prs* );
307 //! \retval Return false.
308 virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ){ return false; }
309 virtual void Repaint() {} //!< Null body here.
310 virtual void GetVisible( SALOME_ListIO& theList ) {}
314 \class SALOME_Displayer
315 Base class for SALOME displayers
317 class PRS_EXPORT SALOME_Displayer
321 virtual ~SALOME_Displayer() {/*! Null body here*/}
323 //! This Update() method should be called to update given presentation
324 //! created anywhere by anybody. It simply passes control to SALOME_Prs object
325 //! so that it could perform double dispatch.
326 void UpdatePrs( SALOME_Prs* );
328 // Interface for derived displayers
330 // Update() methods for ALL kinds of presentation should appear here
331 virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation.
332 virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation.
333 virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation.
334 // Add new Update() methods here...
336 // Axiluary methods called before and after displaying of objects
337 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
338 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
339 virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
340 virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
341 virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
342 virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
344 // Axiluary methods called before and after erasing of objects
345 virtual void BeforeErase( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
346 virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
347 virtual void BeforeErase( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
348 virtual void AfterErase ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
349 virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
350 virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here
352 // Axiluary method called to update visibility state of presentation
353 virtual void UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool );