Salome HOME
Merge branch 'V7_dev'
[modules/gui.git] / src / Prs / SALOME_Prs.cxx
1 // Copyright (C) 2007-2016  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 // File:        SALOME_Prs.cxx
24 // Author:      Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
25
26 #include "SALOME_Prs.h"
27
28 /*!
29   Constructor
30 */
31 SALOME_Prs::SALOME_Prs(const char* e) : myIsClippable(true)
32 {
33   myEntry = std::string( e ? e : "" );
34 }
35
36 /*!
37   Get entry
38 */
39 const char* SALOME_Prs::GetEntry() const
40 {
41   return myEntry.c_str();
42 }
43
44 /*!
45   Dispatches operation of activation of sub-shapes selection
46 */
47 void SALOME_Prs::LocalSelectionIn( SALOME_View*, const std::list<int> ) const
48 {
49   // base implementation does nothing
50 }
51
52 /*!
53   Dispatches display operation to proper Display() method of SALOME_View
54 */
55 void SALOME_OCCPrs::DisplayIn( SALOME_View* v ) const
56 {
57   if ( v ) v->Display( this );
58 }
59
60 /*!
61   Dispatches display operation to proper Erase() method of SALOME_View
62 */
63 void SALOME_OCCPrs::EraseIn( SALOME_View* v, const bool forced ) const
64 {
65   if ( v ) v->Erase( this, forced );
66 }
67
68 /*!
69   Dispatches display operation to proper BeforeDisplay() method of SALOME_Displayer
70 */
71 void SALOME_OCCPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
72 {
73   d->BeforeDisplay( v, this );
74 }
75
76 /*!
77   Dispatches display operation to proper AfterDisplay() method of SALOME_Displayer
78 */
79 void SALOME_OCCPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
80 {
81   d->AfterDisplay( v, this );
82 }
83
84 /*!
85   Dispatches display operation to proper BeforeErase() method of SALOME_Displayer
86 */
87 void SALOME_OCCPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
88 {
89   d->BeforeErase( v, this );
90 }
91
92 /*!
93   Dispatches display operation to proper AfterErase() method of SALOME_Displayer
94 */
95 void SALOME_OCCPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
96 {
97   d->AfterErase( v, this );
98 }
99
100 /*!
101   Dispatches operation to proper LocalSelectionIn() method of SALOME_View
102 */
103 void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const
104 {
105   std::list<int> modes;
106   modes.push_back( mode );
107   LocalSelectionIn( v, modes );
108 }
109
110 /*!
111   Dispatches operation to proper LocalSelectionIn() method of SALOME_View
112 */
113 void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const std::list<int> modes ) const
114 {
115   if ( v && !modes.empty() ) v->LocalSelection( this, modes );
116 }
117
118 /*!
119    Dispatches update operation to proper Update() method of SALOME_Displayer
120 */
121 void SALOME_OCCPrs::Update( SALOME_Displayer* d )
122 {
123   if ( d ) d->Update( this );
124 }
125
126 /*!
127   Dispatches display operation to proper Display() method of SALOME_View
128 */
129 void SALOME_VTKPrs::DisplayIn( SALOME_View* v ) const
130 {
131   if ( v ) v->Display( this );
132 }
133
134 /*!
135   Dispatches display operation to proper Erase() method of SALOME_View
136 */
137 void SALOME_VTKPrs::EraseIn( SALOME_View* v, const bool forced ) const
138 {
139   if ( v ) v->Erase( this, forced );
140 }
141
142 /*!
143   Dispatches display operation to proper BeforeDisplay() method of SALOME_Displayer
144 */
145 void SALOME_VTKPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
146 {
147   d->BeforeDisplay( v, this );
148 }
149
150 /*!
151   Dispatches display operation to proper AfterDisplay() method of SALOME_Displayer
152 */
153 void SALOME_VTKPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
154 {
155   d->AfterDisplay( v, this );
156 }
157
158 /*!
159   Dispatches display operation to proper BeforeErase() method of SALOME_Displayer
160 */
161 void SALOME_VTKPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
162 {
163   d->BeforeErase( v, this );
164 }
165
166 /*!
167   Dispatches display operation to proper AfterErase() method of SALOME_Displayer
168 */
169 void SALOME_VTKPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
170 {
171   d->AfterErase( v, this );
172 }
173
174 /*!
175   Dispatches operation to proper LocalSelectionIn() method of SALOME_View
176 */
177 void SALOME_VTKPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const
178 {
179   if ( v ) v->LocalSelection( this, mode );
180 }
181
182 /*!
183   Dispatches update operation to proper Update() method of SALOME_Displayer
184 */
185 void SALOME_VTKPrs::Update( SALOME_Displayer* d )
186 {
187   if ( d ) d->Update( this );
188 }
189
190 /*!
191   Dispatches display operation to proper Display() method of SALOME_View
192 */
193 void SALOME_Prs2d::DisplayIn( SALOME_View* v ) const
194 {
195   if ( v ) v->Display( this );
196 }
197
198 /*!
199   Dispatches display operation to proper Erase() method of SALOME_View
200 */
201 void SALOME_Prs2d::EraseIn( SALOME_View* v, const bool forced ) const
202 {
203   if ( v ) v->Erase( this, forced );
204 }
205
206 /*!
207   Dispatches display operation to proper BeforeDisplay() method of SALOME_Displayer
208 */
209 void SALOME_Prs2d::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
210 {
211   d->BeforeDisplay( v, this );
212 }
213
214 /*!
215   Dispatches display operation to proper AfterDisplay() method of SALOME_Displayer
216 */
217 void SALOME_Prs2d::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
218 {
219   d->AfterDisplay( v, this );
220 }
221
222 /*!
223   Dispatches display operation to proper BeforeErase() method of SALOME_Displayer
224 */
225 void SALOME_Prs2d::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
226 {
227   d->BeforeErase( v, this );
228 }
229
230 /*!
231   Dispatches display operation to proper AfterErase() method of SALOME_Displayer
232 */
233 void SALOME_Prs2d::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
234 {
235   d->AfterErase( v, this );
236 }
237
238 /*!
239   Dispatches operation to proper LocalSelectionIn() method of SALOME_View
240 */
241 void SALOME_Prs2d::LocalSelectionIn( SALOME_View* v, const int mode ) const
242 {
243   if ( v ) v->LocalSelection( this, mode );
244 }
245
246 /*!
247   Dispatches update operation to proper Update() method of SALOME_Displayer
248 */
249 void SALOME_Prs2d::Update( SALOME_Displayer* d )
250 {
251   if ( d ) d->Update( this );
252 }
253
254 /*!
255   Gives control to SALOME_Prs object, so that it could perform double dispatch
256 */
257 void SALOME_View::Display( SALOME_Displayer* d, const SALOME_Prs* prs )
258 {
259   prs->DisplayIn( this );
260   if ( d ) d->UpdateVisibility( this, prs, true );
261 }
262
263 /*!
264   Gives control to SALOME_Prs object, so that it could perform double dispatch
265 */
266 void SALOME_View::Erase( SALOME_Displayer* d, const SALOME_Prs* prs, const bool forced )
267 {
268   prs->EraseIn( this, forced );
269   if ( d ) d->UpdateVisibility( this, prs, false );
270 }
271
272 /*!
273   Gives control to SALOME_Prs object, so that it could perform double dispatch
274 */
275 void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode )
276 {
277   std::list<int> modes;
278   modes.push_back( mode );
279   LocalSelection( prs, modes );
280 }
281
282 /*!
283   Gives control to SALOME_Prs object, so that it could perform double dispatch
284 */
285 void SALOME_View::LocalSelection( const SALOME_Prs* prs, const std::list<int> modes )
286 {
287   prs->LocalSelectionIn( this, modes );
288 }
289
290 /*!
291   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
292 */
293 void SALOME_View::Display( const SALOME_OCCPrs* )
294 {
295 //  MESSAGE( "SALOME_View::Display( const SALOME_OCCPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
296 }
297
298 /*!
299   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
300 */
301 void SALOME_View::Display( const SALOME_VTKPrs* )
302 {
303 //  MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
304 }
305
306 /*!
307   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
308 */
309 void SALOME_View::Display( const SALOME_Prs2d* )
310 {
311 //  MESSAGE( "SALOME_View::Display( const SALOME_Prs2d& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
312 }
313
314 /*!
315   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
316 */
317 void SALOME_View::Erase( const SALOME_OCCPrs*, const bool )
318 {
319 //  MESSAGE( "SALOME_View::Erase( const SALOME_OCCPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." );
320 }
321
322 /*!
323   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
324 */
325 void SALOME_View::Erase( const SALOME_VTKPrs*, const bool )
326 {
327 //  MESSAGE( "SALOME_View::Erase( const SALOME_VTKPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." );
328 }
329
330 /*!
331   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
332 */
333 void SALOME_View::Erase( const SALOME_Prs2d*, const bool )
334 {
335 //  MESSAGE( "SALOME_View::Erase( const SALOME_Prs2d& ) called! Probably, presentation is being erased in uncompatible viewframe." );
336 }
337
338 /*!
339   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
340 */
341 void SALOME_View::EraseAll( SALOME_Displayer* d, const bool )
342 {
343 //  MESSAGE( "SALOME_View::EraseAll() called!" );
344   if ( d ) d->UpdateVisibility( this, 0, false );
345 }
346
347 /*!
348   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
349 */
350 void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int )
351 {
352 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called!
353 //   Probably, selection is being activated in uncompatible viewframe." );
354 }
355
356 /*!
357   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
358 */
359 void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const std::list<int> )
360 {
361 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called!
362 //   Probably, selection is being activated in uncompatible viewframe." );
363 }
364
365 /*!
366   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
367 */
368 void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int )
369 {
370 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_VTKPrs* ) called!
371 //   Probably, selection is being activated in uncompatible viewframe." );
372 }
373
374 /*!
375   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
376 */
377 void SALOME_View::LocalSelection( const SALOME_Prs2d*, const int )
378 {
379 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_Prs2d* ) called!
380 //   Probably, selection is being activated in uncompatible viewframe." );
381 }
382
383 /*!
384   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
385 */
386 void SALOME_View::GlobalSelection( const bool ) const
387 {
388 //  MESSAGE( "SALOME_View::GlobalSelection() called!
389 //   Probably, selection is being activated in uncompatible viewframe." );
390 }
391
392 void SALOME_View::BeforeDisplay( SALOME_Displayer* d, const SALOME_Prs* p )
393 {
394   p->BeforeDisplayIn( d, this );
395 }
396
397 void SALOME_View::AfterDisplay( SALOME_Displayer* d, const SALOME_Prs* p )
398 {
399   p->AfterDisplayIn( d, this );
400 }
401
402 void SALOME_View::BeforeErase( SALOME_Displayer* d, const SALOME_Prs* p )
403 {
404   p->BeforeEraseIn( d, this );
405 }
406
407 void SALOME_View::AfterErase ( SALOME_Displayer* d, const SALOME_Prs* p )
408 {
409   p->AfterEraseIn( d, this );
410 }
411
412 /*!
413   Gives control to SALOME_Prs object, so that it could perform double dispatch
414 */
415 void SALOME_Displayer::UpdatePrs( SALOME_Prs* prs )
416 {
417   prs->Update( this );
418 }
419
420 /*!
421   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
422 */
423 void SALOME_Displayer::Update( SALOME_OCCPrs* )
424 {
425 //  MESSAGE( "SALOME_Displayer::Update( SALOME_OCCPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." );
426 }
427
428 /*!
429   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
430 */
431 void SALOME_Displayer::Update( SALOME_VTKPrs* )
432 {
433 //  MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." );
434 }
435
436 /*!
437   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
438 */
439 void SALOME_Displayer::Update( SALOME_Prs2d* )
440 {
441 //  MESSAGE( "SALOME_Displayer::Update( SALOME_Prs2d* ) called! Probably, presentation is being updated in uncompatible viewframe." );
442 }
443
444 /*!
445   Virtual method, should be reimplemented in successors, by default does nothing.
446 */
447 void SALOME_Displayer::UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool )
448 {
449 }