]> SALOME platform Git repositories - modules/gui.git/blob - src/Prs/SALOME_Prs.h
Salome HOME
0022800: EDF 9132 PARAVIS: Sigsegv when using pvviewer outside paravis
[modules/gui.git] / src / Prs / SALOME_Prs.h
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef SALOME_PRS_H
24 #define SALOME_PRS_H
25
26 #ifdef WIN32
27 #if defined PRS_EXPORTS || defined SalomePrs_EXPORTS
28 #define PRS_EXPORT __declspec(dllexport)
29 #else
30 #define PRS_EXPORT __declspec(dllimport)
31 #endif
32 #else
33 #define PRS_EXPORT
34 #endif
35
36 class SALOME_View;
37 class SALOME_Displayer;
38 class SALOME_ListIO;
39 class Handle_SALOME_InteractiveObject;
40
41 #include <string>
42
43 /*!
44  \class SALOME_Prs
45  Base class for SALOME graphic object wrappers - presentations.
46  Presentations are temporary objects, so they can be created on the stack.
47 */
48
49 class PRS_EXPORT SALOME_Prs
50 {
51 public:
52   //! Constructor
53   explicit SALOME_Prs( const char* );
54  
55   //! Destructor
56   virtual ~SALOME_Prs() {}
57
58   //! Get entry
59   const char* GetEntry() const;
60
61   //! Key method for double dispatch of display operation
62   virtual void DisplayIn( SALOME_View* ) const = 0;
63
64   //! Key method for double dispatch of erase operation
65   virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
66
67   //! Key method for double dispatch of pre-display operation
68   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
69
70   //! Key method for double dispatch of post-display operation
71   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const = 0;
72
73   //! Key method for double dispatch of pre-erase operation
74   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
75
76   //! Key method for double dispatch of post-erase operation
77   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const = 0;
78
79   //! Key method for double dispatch of update operation
80   virtual void Update( SALOME_Displayer* ) = 0;
81
82   //! Should return true, if this presentation contains a graphic object
83   virtual bool IsNull() const = 0;
84
85   //! Key method for double dispatch of activation of sub-shapes selection
86   virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
87
88     // checks if shape is clippable
89   inline bool IsClippable() const
90   {
91     return myIsClippable;
92   }
93
94   // makes shape clippable/not clippable
95   inline void SetClippable (bool isClippable)
96   {
97     myIsClippable = isClippable;
98   }
99
100 protected:
101   std::string myEntry;
102   bool myIsClippable;
103 };
104
105 /*!
106  \class SALOME_OCCPrs
107  Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.
108  This intermediate class is necessary to avoid dependencies from OCC libs.
109 */
110
111 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
112 {
113 public:
114   //! Constructor
115   explicit SALOME_OCCPrs(const char* e) : SALOME_Prs(e) {}
116
117   //! It uses double dispatch in order to
118   //! invoke Display() method corresponding to the actual type of presentation.
119   virtual void DisplayIn( SALOME_View* ) const;
120
121   //! It uses double dispatch in order to
122   //! invoke Erase() method corresponding to the actual type of presentation.
123   virtual void EraseIn( SALOME_View*, const bool = false ) const;
124
125   //! It uses double dispatch in order to
126   //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
127   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
128
129   //! It uses double dispatch in order to
130   //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
131   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
132
133   //! It uses double dispatch in order to
134   //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
135   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
136
137   //! It uses double dispatch in order to
138   //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
139   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
140
141   //! It uses double dispatch in order to
142   //! invoke Update() method corresponding to the actual type of presentation.
143   virtual void Update( SALOME_Displayer* );
144
145   //! Key method for double dispatch of activation of sub-shapes selection
146   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
147 };
148
149 /*!
150  \class SALOME_VTKPrs
151  Base class for VTK graphic object (vtkActor) wrappers.
152  This intermediate class is necessary to avoid dependencies from VTK libs.
153 */
154 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
155 {
156 public:
157   //! Constructor
158   explicit SALOME_VTKPrs(const char* e) : SALOME_Prs(e) {}
159
160   //! It uses double dispatch in order to
161   //! invoke Display() method corresponding to the actual type of presentation.
162   virtual void DisplayIn( SALOME_View* ) const;
163
164   //! It uses double dispatch in order to
165   //! invoke Erase() method corresponding to the actual type of presentation.
166   virtual void EraseIn( SALOME_View*, const bool = false ) const;
167
168   //! It uses double dispatch in order to
169   //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
170   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
171
172   //! It uses double dispatch in order to
173   //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
174   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
175
176   //! It uses double dispatch in order to
177   //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
178   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
179
180   //! It uses double dispatch in order to
181   //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
182   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
183
184   //! It uses double dispatch in order to
185   //! invoke Update() method corresponding to the actual type of presentation.
186   virtual void Update( SALOME_Displayer* );
187
188   //! Key method for double dispatch of activation of sub-shapes selection
189   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
190 };
191
192 /*!
193  \class SALOME_Prs2d
194  Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
195 */
196 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
197 {
198 public:
199   //! Constructor
200   explicit SALOME_Prs2d(const char* e) : SALOME_Prs(e) {}
201
202   //! It uses double dispatch in order to
203   //! invoke Display() method corresponding to the actual type of presentation.
204   virtual void DisplayIn( SALOME_View* ) const;
205
206   //! It uses double dispatch in order to
207   //! invoke Erase() method corresponding to the actual type of presentation.
208   virtual void EraseIn( SALOME_View*, const bool = false ) const;
209
210   //! It uses double dispatch in order to
211   //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation.
212   virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
213
214   //! It uses double dispatch in order to
215   //! invoke AfterDisplayIn() method corresponding to the actual type of presentation.
216   virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const;
217
218   //! It uses double dispatch in order to
219   //! invoke BeforeEraseIn() method corresponding to the actual type of presentation.
220   virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const;
221
222   //! It uses double dispatch in order to
223   //! invoke AfterEraseIn() method corresponding to the actual type of presentation.
224   virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const;
225
226   //! It uses double dispatch in order to
227   //! invoke Update() method corresponding to the actual type of presentation.
228   virtual void Update( SALOME_Displayer* );
229
230   //! Key method for double dispatch of activation of sub-shapes selection
231   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
232 };
233
234 /*!
235   Base classes for object wrappers for any other visualization libraries should be added here!
236 */
237 /*!
238  \class SALOME_View
239  Base class for SALOME views (or view frames)
240 */
241 class PRS_EXPORT SALOME_View
242 {
243 public:
244   //! Destructor
245   virtual ~SALOME_View() {}
246
247   //! This Display() method should be called to display given presentation
248   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
249   //! so that it could perform double dispatch.
250   void Display( SALOME_Displayer*, const SALOME_Prs* );
251
252   //! This Erase() method should be called to erase 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 Erase( SALOME_Displayer*, const SALOME_Prs*, const bool = false );
256
257   //! This EraseAll() method should be called to erase all presentations
258   //! created anywhere by anybody.
259   virtual void EraseAll( SALOME_Displayer*, const bool = false );
260
261   //! This LocalSelection() method should be called to activate sub-shapes selection
262   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
263   //! so that it could perform double dispatch.
264   void LocalSelection( const SALOME_Prs*, const int );
265
266   // Interface for derived views
267
268   // Display() methods for ALL kinds of presentation should appear here
269   virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation.
270   virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation.
271   virtual void Display( const SALOME_Prs2d*  );//!< Display SALOME_Prs2d  presentation.
272   // Add new Display() methods here...
273
274   // Erase() methods for ALL kinds of presentation should appear here
275   virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs
276   virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs
277   virtual void Erase( const SALOME_Prs2d*,  const bool = false );//!< Erase SALOME_Prs2d
278   // Add new Erase() methods here...
279
280   // LocalSelection() methods for ALL kinds of presentation should appear here
281   virtual void LocalSelection( const SALOME_OCCPrs*, const int );//!< Local selection SALOME_OCCPrs
282   virtual void LocalSelection( const SALOME_VTKPrs*, const int );//!< Local selection SALOME_VTKPrs
283   virtual void LocalSelection( const SALOME_Prs2d* , const int );//!< Local selection SALOME_Prs2d
284
285   //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
286   virtual void GlobalSelection( const bool = false ) const;
287
288   //! Creates empty presenation of corresponding type
289   virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; }
290
291   // Axiluary methods called before and after displaying of objects
292   virtual void BeforeDisplay( SALOME_Displayer*, const SALOME_Prs* );
293   virtual void AfterDisplay ( SALOME_Displayer*, const SALOME_Prs* );
294
295   // Axiluary methods called before and after erasing of objects
296   virtual void BeforeErase( SALOME_Displayer*, const SALOME_Prs* );
297   virtual void AfterErase ( SALOME_Displayer*, const SALOME_Prs* );
298
299   // New methods (asv)
300   //! \retval Return false.
301   virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
302   virtual void Repaint() {} //!< Null body here.
303   virtual void GetVisible( SALOME_ListIO& theList ) {}
304 };
305
306 /*!
307  \class SALOME_Displayer
308  Base class for SALOME displayers
309 */
310 class PRS_EXPORT SALOME_Displayer
311 {
312 public:
313   //! Destructor
314   virtual ~SALOME_Displayer() {/*! Null body here*/}
315
316   //! This Update() method should be called to update given presentation
317   //! created anywhere by anybody. It simply passes control to SALOME_Prs object
318   //! so that it could perform double dispatch.
319   void UpdatePrs( SALOME_Prs* );
320
321   // Interface for derived displayers
322
323   // Update() methods for ALL kinds of presentation should appear here
324   virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation.
325   virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation.
326   virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation.
327   // Add new Update() methods here...
328
329   // Axiluary methods called before and after displaying of objects
330   virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
331   virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
332   virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
333   virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
334   virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
335   virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
336
337   // Axiluary methods called before and after erasing of objects
338   virtual void BeforeErase( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
339   virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here
340   virtual void BeforeErase( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
341   virtual void AfterErase ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here
342   virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
343   virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d*  ) {} //! Null body here
344
345   // Axiluary method called to update visibility state of presentation
346   virtual void UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool );
347 };
348
349 #endif