Salome HOME
681cb70688a2f879fc072440e34e61d3f4481958
[modules/gui.git] / src / Prs / SALOME_Prs.cxx
1 // Copyright (C) 2007-2022  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_PV3DPrs::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_PV3DPrs::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_PV3DPrs::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_PV3DPrs::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_PV3DPrs::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_PV3DPrs::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_PV3DPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const
242 {
243   std::list<int> modes;
244   modes.push_back( mode );
245   LocalSelectionIn( v, modes );
246 }
247
248 /*!
249   Dispatches operation to proper LocalSelectionIn() method of SALOME_View
250 */
251 void SALOME_PV3DPrs::LocalSelectionIn( SALOME_View* v, const std::list<int> modes ) const
252 {
253   if ( v && !modes.empty() ) v->LocalSelection( this, modes );
254 }
255
256 /*!
257    Dispatches update operation to proper Update() method of SALOME_Displayer
258 */
259 void SALOME_PV3DPrs::Update( SALOME_Displayer* d )
260 {
261   if ( d ) d->Update( this );
262 }
263
264 /*!
265   Dispatches display operation to proper Display() method of SALOME_View
266 */
267 void SALOME_Prs2d::DisplayIn( SALOME_View* v ) const
268 {
269   if ( v ) v->Display( this );
270 }
271
272 /*!
273   Dispatches display operation to proper Erase() method of SALOME_View
274 */
275 void SALOME_Prs2d::EraseIn( SALOME_View* v, const bool forced ) const
276 {
277   if ( v ) v->Erase( this, forced );
278 }
279
280 /*!
281   Dispatches display operation to proper BeforeDisplay() method of SALOME_Displayer
282 */
283 void SALOME_Prs2d::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
284 {
285   d->BeforeDisplay( v, this );
286 }
287
288 /*!
289   Dispatches display operation to proper AfterDisplay() method of SALOME_Displayer
290 */
291 void SALOME_Prs2d::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const
292 {
293   d->AfterDisplay( v, this );
294 }
295
296 /*!
297   Dispatches display operation to proper BeforeErase() method of SALOME_Displayer
298 */
299 void SALOME_Prs2d::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
300 {
301   d->BeforeErase( v, this );
302 }
303
304 /*!
305   Dispatches display operation to proper AfterErase() method of SALOME_Displayer
306 */
307 void SALOME_Prs2d::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const
308 {
309   d->AfterErase( v, this );
310 }
311
312 /*!
313   Dispatches operation to proper LocalSelectionIn() method of SALOME_View
314 */
315 void SALOME_Prs2d::LocalSelectionIn( SALOME_View* v, const int mode ) const
316 {
317   if ( v ) v->LocalSelection( this, mode );
318 }
319
320 /*!
321   Dispatches update operation to proper Update() method of SALOME_Displayer
322 */
323 void SALOME_Prs2d::Update( SALOME_Displayer* d )
324 {
325   if ( d ) d->Update( this );
326 }
327
328 /*!
329   Gives control to SALOME_Prs object, so that it could perform double dispatch
330 */
331 void SALOME_View::Display( SALOME_Displayer* d, const SALOME_Prs* prs )
332 {
333   prs->DisplayIn( this );
334   if ( d ) d->UpdateVisibility( this, prs, true );
335 }
336
337 /*!
338   Gives control to SALOME_Prs object, so that it could perform double dispatch
339 */
340 void SALOME_View::Erase( SALOME_Displayer* d, const SALOME_Prs* prs, const bool forced )
341 {
342   prs->EraseIn( this, forced );
343   if ( d ) d->UpdateVisibility( this, prs, false );
344 }
345
346 /*!
347   Gives control to SALOME_Prs object, so that it could perform double dispatch
348 */
349 void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode )
350 {
351   std::list<int> modes;
352   modes.push_back( mode );
353   LocalSelection( prs, modes );
354 }
355
356 /*!
357   Gives control to SALOME_Prs object, so that it could perform double dispatch
358 */
359 void SALOME_View::LocalSelection( const SALOME_Prs* prs, const std::list<int> modes )
360 {
361   prs->LocalSelectionIn( this, modes );
362 }
363
364 /*!
365   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
366 */
367 void SALOME_View::Display( const SALOME_OCCPrs* )
368 {
369 //  MESSAGE( "SALOME_View::Display( const SALOME_OCCPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
370 }
371
372 /*!
373   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
374 */
375 void SALOME_View::Display( const SALOME_VTKPrs* )
376 {
377 //  MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
378 }
379
380 /*!
381   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
382 */
383 void SALOME_View::Display( const SALOME_PV3DPrs* )
384 {
385 //  MESSAGE( "SALOME_View::Display( const SALOME_PV3DPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
386 }
387
388 /*!
389   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
390 */
391 void SALOME_View::Display( const SALOME_Prs2d* )
392 {
393 //  MESSAGE( "SALOME_View::Display( const SALOME_Prs2d& ) called! Probably, presentation is being displayed in uncompatible viewframe." );
394 }
395
396 /*!
397   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
398 */
399 void SALOME_View::Erase( const SALOME_OCCPrs*, const bool )
400 {
401 //  MESSAGE( "SALOME_View::Erase( const SALOME_OCCPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." );
402 }
403
404 /*!
405   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
406 */
407 void SALOME_View::Erase( const SALOME_VTKPrs*, const bool )
408 {
409 //  MESSAGE( "SALOME_View::Erase( const SALOME_VTKPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." );
410 }
411
412 /*!
413   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
414 */
415 void SALOME_View::Erase( const SALOME_PV3DPrs*, const bool )
416 {
417 //  MESSAGE( "SALOME_View::Erase( const SALOME_PV3DPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." );
418 }
419
420 /*!
421   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
422 */
423 void SALOME_View::Erase( const SALOME_Prs2d*, const bool )
424 {
425 //  MESSAGE( "SALOME_View::Erase( const SALOME_Prs2d& ) called! Probably, presentation is being erased 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_View::EraseAll( SALOME_Displayer* d, const bool )
432 {
433 //  MESSAGE( "SALOME_View::EraseAll() called!" );
434   if ( d ) d->UpdateVisibility( this, 0, false );
435 }
436
437 /*!
438   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
439 */
440 void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int )
441 {
442 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called!
443 //   Probably, selection is being activated in uncompatible viewframe." );
444 }
445
446 /*!
447   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
448 */
449 void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const std::list<int> )
450 {
451 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called!
452 //   Probably, selection is being activated in uncompatible viewframe." );
453 }
454
455 /*!
456   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
457 */
458 void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int )
459 {
460 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_VTKPrs* ) called!
461 //   Probably, selection is being activated in uncompatible viewframe." );
462 }
463
464 /*!
465   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
466 */
467 void SALOME_View::LocalSelection( const SALOME_PV3DPrs*, const int )
468 {
469 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_PV3DPrs* ) called!
470 //   Probably, selection is being activated in uncompatible viewframe." );
471 }
472
473 /*!
474   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
475 */
476 void SALOME_View::LocalSelection( const SALOME_Prs2d*, const int )
477 {
478 //  MESSAGE( "SALOME_View::LocalSelection( const SALOME_Prs2d* ) called!
479 //   Probably, selection is being activated in uncompatible viewframe." );
480 }
481
482 /*!
483   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
484 */
485 void SALOME_View::GlobalSelection( const bool ) const
486 {
487 //  MESSAGE( "SALOME_View::GlobalSelection() called!
488 //   Probably, selection is being activated in uncompatible viewframe." );
489 }
490
491 void SALOME_View::BeforeDisplay( SALOME_Displayer* d, const SALOME_Prs* p )
492 {
493   p->BeforeDisplayIn( d, this );
494 }
495
496 void SALOME_View::AfterDisplay( SALOME_Displayer* d, const SALOME_Prs* p )
497 {
498   p->AfterDisplayIn( d, this );
499 }
500
501 void SALOME_View::BeforeErase( SALOME_Displayer* d, const SALOME_Prs* p )
502 {
503   p->BeforeEraseIn( d, this );
504 }
505
506 void SALOME_View::AfterErase ( SALOME_Displayer* d, const SALOME_Prs* p )
507 {
508   p->AfterEraseIn( d, this );
509 }
510
511 /*!
512   Gives control to SALOME_Prs object, so that it could perform double dispatch
513 */
514 void SALOME_Displayer::UpdatePrs( SALOME_Prs* prs )
515 {
516   prs->Update( this );
517 }
518
519 /*!
520   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
521 */
522 void SALOME_Displayer::Update( SALOME_OCCPrs* )
523 {
524 //  MESSAGE( "SALOME_Displayer::Update( SALOME_OCCPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." );
525 }
526
527 /*!
528   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
529 */
530 void SALOME_Displayer::Update( SALOME_VTKPrs* )
531 {
532 //  MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." );
533 }
534
535 /*!
536   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
537 */
538 void SALOME_Displayer::Update( SALOME_PV3DPrs* )
539 {
540 //  MESSAGE( "SALOME_Displayer::Update( SALOME_PV3DPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." );
541 }
542
543 /*!
544   Virtual method, should be reimplemented in successors, by default issues a warning and does nothing.
545 */
546 void SALOME_Displayer::Update( SALOME_Prs2d* )
547 {
548 //  MESSAGE( "SALOME_Displayer::Update( SALOME_Prs2d* ) called! Probably, presentation is being updated in uncompatible viewframe." );
549 }
550
551 /*!
552   Virtual method, should be reimplemented in successors, by default does nothing.
553 */
554 void SALOME_Displayer::UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool )
555 {
556 }