1 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
3 // Copyright (C) 2004 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.org
24 // File : SALOME_Prs.h
25 // Author : Sergey ANIKIN
33 class SALOME_Displayer;
35 //===========================================================
38 * Description: Base class for SALOME graphic object wrappers - presentations.
39 * Presentations are temporary objects, so they can be created on the stack.
41 //===========================================================
46 virtual ~SALOME_Prs() {}
49 virtual void DisplayIn( SALOME_View* ) const = 0;
50 // Key method for double dispatch of display operation
52 virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
53 // Key method for double dispatch of erase operation
55 virtual void Update( SALOME_Displayer* ) = 0;
56 // Key method for double dispatch of update operation
58 virtual bool IsNull() const = 0;
59 // Should return true, if this presentation contains a graphic object
61 virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
62 // Key method for double dispatch of activation of subshapes selection
65 //===========================================================
67 * Class: SALOME_OCCPrs
68 * Description: Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
69 * This intermediate class is necessary to avoid dependencies from OCC libs.
71 //===========================================================
73 class SALOME_OCCPrs : public SALOME_Prs
76 virtual void DisplayIn( SALOME_View* ) const;
77 // It uses double dispatch in order to
78 // invoke Display() method corresponding to the actual type of presentation.
80 virtual void EraseIn( SALOME_View*, const bool = false ) const;
81 // It uses double dispatch in order to
82 // invoke Erase() method corresponding to the actual type of presentation.
84 virtual void Update( SALOME_Displayer* );
85 // It uses double dispatch in order to
86 // invoke Update() method corresponding to the actual type of presentation.
88 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
89 // Key method for double dispatch of activation of subshapes selection
92 //===========================================================
94 * Class: SALOME_VTKPrs
95 * Description: Base class for VTK graphic object (vtkActor) wrappers
96 * This intermediate class is necessary to avoid dependencies from VTK libs.
98 //===========================================================
100 class SALOME_VTKPrs : public SALOME_Prs
103 virtual void DisplayIn( SALOME_View* ) const;
104 // It uses double dispatch in order to
105 // invoke Display() method corresponding to the actual type of presentation.
107 virtual void EraseIn( SALOME_View*, const bool = false ) const;
108 // It uses double dispatch in order to
109 // invoke Erase() method corresponding to the actual type of presentation.
111 virtual void Update( SALOME_Displayer* );
112 // It uses double dispatch in order to
113 // invoke Update() method corresponding to the actual type of presentation.
115 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
116 // Key method for double dispatch of activation of subshapes selection
119 //===========================================================
121 * Class: SALOME_Prs2d
122 * Description: Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
124 //===========================================================
126 class SALOME_Prs2d : public SALOME_Prs
129 virtual void DisplayIn( SALOME_View* ) const;
130 // It uses double dispatch in order to
131 // invoke Display() method corresponding to the actual type of presentation.
133 virtual void EraseIn( SALOME_View*, const bool = false ) const;
134 // It uses double dispatch in order to
135 // invoke Erase() method corresponding to the actual type of presentation.
137 virtual void Update( SALOME_Displayer* );
138 // It uses double dispatch in order to
139 // invoke Update() method corresponding to the actual type of presentation.
141 virtual void LocalSelectionIn( SALOME_View*, const int ) const;
142 // Key method for double dispatch of activation of subshapes selection
145 /////////////////////////////////////////////////////////////////////////
146 // Base classes for object wrappers for any other visualization libraries
147 // should be added here!
148 /////////////////////////////////////////////////////////////////////////
150 //===========================================================
153 * Description: Base class for SALOME views (or view frames)
155 //===========================================================
160 virtual ~SALOME_View() {}
163 void Display( const SALOME_Prs* );
164 // This Display() method should be called to display given presentation
165 // created anywhere by anybody. It simply passes control to SALOME_Prs object
166 // so that it could perform double dispatch.
167 void Erase( const SALOME_Prs*, const bool = false );
168 // This Erase() method should be called to erase given presentation
169 // created anywhere by anybody. It simply passes control to SALOME_Prs object
170 // so that it could perform double dispatch.
172 void LocalSelection( const SALOME_Prs*, const int );
173 // This LocalSelection() method should be called to activate sub-shapes selection
174 // created anywhere by anybody. It simply passes control to SALOME_Prs object
175 // so that it could perform double dispatch.
177 // Interface for derived views
179 // Display() methods for ALL kinds of presentation should appear here
180 virtual void Display( const SALOME_OCCPrs* );
181 virtual void Display( const SALOME_VTKPrs* );
182 virtual void Display( const SALOME_Prs2d* );
183 // Add new Display() methods here...
185 // Erase() methods for ALL kinds of presentation should appear here
186 virtual void Erase( const SALOME_OCCPrs*, const bool = false );
187 virtual void Erase( const SALOME_VTKPrs*, const bool = false );
188 virtual void Erase( const SALOME_Prs2d*, const bool = false );
189 // Add new Erase() methods here...
191 // LocalSelection() methods for ALL kinds of presentation should appear here
192 virtual void LocalSelection( const SALOME_OCCPrs*, const int );
193 virtual void LocalSelection( const SALOME_VTKPrs*, const int );
194 virtual void LocalSelection( const SALOME_Prs2d* , const int );
196 virtual void GlobalSelection( const bool = false ) const;
197 // Deactivates selection of sub-shapes (must be redefined with OCC viewer)
199 // Creates empty presenation of corresponding type
200 virtual SALOME_Prs* CreatePrs( const char* entry = 0 ) { return 0; }
202 // Axiluary methods called before and after displaying of objects
203 virtual void BeforeDisplay( SALOME_Displayer* d ) {}
204 virtual void AfterDisplay ( SALOME_Displayer* d ) {}
207 //===========================================================
209 * Classes: SALOME_Displayer
210 * Description: These classes are used to specify type of view
213 //===========================================================
215 class SALOME_OCCViewType {};
216 class SALOME_VTKViewType {};
217 class SALOME_Plot2dViewType {};
219 //===========================================================
221 * Class: SALOME_Displayer
222 * Description: Base class for SALOME displayers
224 //===========================================================
226 class SALOME_Displayer
229 virtual ~SALOME_Displayer() {}
232 void UpdatePrs( SALOME_Prs* );
233 // This Update() method should be called to update given presentation
234 // created anywhere by anybody. It simply passes control to SALOME_Prs object
235 // so that it could perform double dispatch.
237 // Interface for derived displayers
239 // Update() methods for ALL kinds of presentation should appear here
240 virtual void Update( SALOME_OCCPrs* );
241 virtual void Update( SALOME_VTKPrs* );
242 virtual void Update( SALOME_Prs2d* );
243 // Add new Update() methods here...
245 // Axiluary methods called before and after displaying of objects
246 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& ) {};
247 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& ) {};
248 virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKViewType& ) {};
249 virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKViewType& ) {};
250 virtual void BeforeDisplay( SALOME_View*, const SALOME_Plot2dViewType& ) {};
251 virtual void AfterDisplay ( SALOME_View*, const SALOME_Plot2dViewType& ) {};