]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_View.cxx
Salome HOME
9ee31b1803a78f48ecd3696248ec22f6d7a4e0a3
[modules/gui.git] / src / SVTK / SVTK_View.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 //  SALOME VTKViewer : build VTK viewer into Salome desktop
24 //  File   : 
25 //  Author : 
26
27 #include "SALOME_Actor.h"
28
29 #include "SVTK_View.h"
30 #include "SVTK_Renderer.h"
31 #include "SVTK_ViewWindow.h"
32 #include "SVTK_RenderWindowInteractor.h"
33 #include "SALOME_ListIO.hxx"
34
35 #include "VTKViewer_Algorithm.h"
36 #include "SVTK_Functor.h"
37
38 #include <vtkActorCollection.h>
39 #include <vtkRenderer.h>
40 #include <vtkProperty.h>
41
42 /*!
43   Constructor
44 */
45 SVTK_SignalHandler
46 ::SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow):
47   QObject(theMainWindow),
48   myMainWindow(theMainWindow)
49 {
50   SVTK_RenderWindowInteractor* anInteractor = theMainWindow->GetInteractor();
51
52   connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
53           this,SIGNAL(KeyPressed(QKeyEvent*)) );
54   connect(anInteractor,SIGNAL(KeyReleased(QKeyEvent*)),
55           this,SIGNAL(KeyReleased(QKeyEvent*)));
56   connect(anInteractor,SIGNAL(MouseButtonPressed(QMouseEvent*)),
57           this,SIGNAL(MouseButtonPressed(QMouseEvent*)));
58   connect(anInteractor,SIGNAL(MouseButtonReleased(QMouseEvent*)),
59           this,SIGNAL(MouseButtonReleased(QMouseEvent*)));
60   connect(anInteractor,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
61           this,SIGNAL(MouseDoubleClicked(QMouseEvent*)));
62   connect(anInteractor,SIGNAL(MouseMove(QMouseEvent*)),
63           this,SIGNAL(MouseMove(QMouseEvent*)));
64   connect(anInteractor,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
65           this,SIGNAL(contextMenuRequested(QContextMenuEvent*)));
66   connect(anInteractor,SIGNAL(selectionChanged()),
67           this,SIGNAL(selectionChanged()));
68 }
69
70 /*!
71   Destructor
72 */
73 SVTK_SignalHandler
74 ::~SVTK_SignalHandler()
75 {
76 }
77
78 /*!
79   \return corresponding svtk main window
80 */
81 SVTK_ViewWindow*
82 SVTK_SignalHandler
83 ::GetMainWindow()
84 {
85   return myMainWindow;
86 }
87
88
89 /*!
90   Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility)
91 */
92 void
93 SVTK_SignalHandler
94 ::Repaint(bool theUpdateTrihedron)
95 {
96   myMainWindow->Repaint(theUpdateTrihedron);
97 }
98
99 /*!
100   Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility)
101 */
102 SVTK_Renderer* 
103 SVTK_SignalHandler
104 ::GetRenderer()
105 {
106   return myMainWindow->GetRenderer();
107 }
108
109 /*!
110   Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility)
111 */
112 vtkRenderer* 
113 SVTK_SignalHandler
114 ::getRenderer()
115 {
116   return myMainWindow->getRenderer();
117 }
118
119 namespace SVTK
120 {
121   struct THighlightAction
122   {
123     bool myIsHighlight;
124     THighlightAction( bool theIsHighlight ):
125       myIsHighlight( theIsHighlight )
126     {}
127     
128     void
129     operator()( SALOME_Actor* theActor) 
130     {
131       if(theActor->GetMapper() && theActor->hasIO()){
132         theActor->Highlight( myIsHighlight );
133       }
134     }
135   };
136 }
137
138 /*!
139   SLOT: called on selection change
140 */
141 void
142 SVTK_SignalHandler
143 ::onSelectionChanged()
144 {
145   VTK::ActorCollectionCopy aCopy(myMainWindow->getRenderer()->GetActors());
146   vtkActorCollection* anActors = aCopy.GetActors();
147
148   using namespace SVTK;
149   ForEach<SALOME_Actor>(anActors,
150                         THighlightAction( false ));
151   SVTK_Selector* aSelector = myMainWindow->GetSelector();
152   const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
153   SALOME_ListIteratorOfListIO anIter(aListIO);
154   for(; anIter.More(); anIter.Next()){
155     ForEachIf<SALOME_Actor>(anActors,
156                             TIsSameIObject<SALOME_Actor>(anIter.Value()),
157                             THighlightAction(true));
158   }
159
160   myMainWindow->Repaint(false);
161 }
162
163 /*!
164   Constructor
165 */
166 SVTK_View
167 ::SVTK_View(SVTK_ViewWindow* theMainWindow) :
168   SVTK_SignalHandler(theMainWindow)
169 {
170 }
171
172 /*!
173   Destructor
174 */
175 SVTK_View
176 ::~SVTK_View()
177 {
178 }
179
180 /*!
181   Unhilights all objects in viewer
182 */
183 void 
184 SVTK_View
185 ::unHighlightAll() 
186 {
187   using namespace SVTK;
188   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
189   ForEach<SALOME_Actor>(aCopy.GetActors(),
190                         THighlightAction( false ));
191   Repaint();
192 }
193
194 /*!
195   Hilights/unhilights object in viewer
196   \param theIO - object to be updated
197   \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
198   \param theIsUpdate - update current viewer
199 */
200 void
201 SVTK_View
202 ::highlight( const Handle(SALOME_InteractiveObject)& theIO, 
203              bool theIsHighlight, 
204              bool theIsUpdate ) 
205 {
206   using namespace SVTK;
207   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
208   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
209                           TIsSameIObject<SALOME_Actor>( theIO ),
210                           THighlightAction(theIsHighlight));
211   Repaint();
212 }
213
214 /*!
215   Display object
216   \param theEntry - entry that corresponds to intractive objects
217 */
218 Handle(SALOME_InteractiveObject)
219 SVTK_View
220 ::FindIObject(const char* theEntry) 
221 {
222   using namespace SVTK;
223   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
224   SALOME_Actor* anActor = 
225     Find<SALOME_Actor>(aCopy.GetActors(),
226                        TIsSameEntry<SALOME_Actor>(theEntry));
227   if(anActor != NULL)
228     return anActor->getIO();
229  
230   return NULL;
231 }
232
233 /*!
234    Redirect the request to #SVTK_Renderer::SetPreselectionProp
235 */
236 void
237 SVTK_View
238 ::SetSelectionProp(const double& theRed, 
239                    const double& theGreen, 
240                    const double& theBlue, 
241                    const int& theWidth) 
242 {
243   GetRenderer()->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
244 }
245
246 /*!
247   Redirect the request to #SVTK_Renderer::SetPreselectionProp
248 */
249 void
250 SVTK_View
251 ::SetPreselectionProp(const double& theRed, 
252                       const double& theGreen, 
253                       const double& theBlue, 
254                       const int& theWidth) 
255 {
256   GetRenderer()->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
257 }
258
259 /*!
260   Redirect the request to #SVTK_Renderer::SetPreselectionProp
261 */
262 void
263 SVTK_View
264 ::SetSelectionTolerance(const double& theTolNodes, 
265                         const double& theTolCell,
266                         const double& theTolObjects)
267 {
268   GetRenderer()->SetSelectionTolerance(theTolNodes, theTolCell, theTolObjects);
269 }
270
271 /*!
272   \return true if object is in viewer or in collector
273   \param theIO - object to be checked
274 */
275 bool
276 SVTK_View
277 ::isInViewer(const Handle(SALOME_InteractiveObject)& theIObject)
278 {
279   using namespace SVTK;
280   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
281   SALOME_Actor* anActor = 
282     Find<SALOME_Actor>(aCopy.GetActors(),
283                        TIsSameIObject<SALOME_Actor>(theIObject));
284   return anActor != NULL;
285 }
286
287 namespace SVTK
288 {
289   struct TIsActorVisibleAction
290   {
291     bool& myResult;
292     TIsActorVisibleAction(bool& theResult): 
293       myResult(theResult)
294     {
295       myResult = false;
296     }
297     void
298     operator()(SALOME_Actor* theActor)
299     {
300       if( !myResult )
301         myResult = theActor->GetVisibility();
302     }
303   };
304 }
305
306 /*!
307   \return true if object is displayed in viewer
308   \param theIO - object to be checked
309 */
310 bool
311 SVTK_View
312 ::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
313 {
314   using namespace SVTK;
315   bool aResult;
316   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
317   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
318                           TIsSameIObject<SALOME_Actor>(theIObject),
319                           TIsActorVisibleAction(aResult));
320   return aResult;
321 }
322
323 /*!
324   Changes name of object
325   \param theIObject - object to be renamed
326   \param theName - new name
327 */
328 void
329 SVTK_View
330 ::rename(const Handle(SALOME_InteractiveObject)& theIObject, 
331          const QString& theName)
332 {
333   using namespace SVTK;
334   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
335   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
336                           TIsSameIObject<SALOME_Actor>(theIObject),
337                           TSetFunction<SALOME_Actor,const char*,const char*>
338                           (&SALOME_Actor::setName,theName.toLatin1().data()));
339 }
340
341 /*!
342   \return current display mode (obsolete)
343 */
344 int
345 SVTK_View
346 ::GetDisplayMode() 
347 {
348   return myDisplayMode; 
349 }
350
351 /*!
352   Set current display mode
353   \param theMode - new display mode
354 */
355 void
356 SVTK_View
357 ::SetDisplayMode(int theMode)
358 {
359   if(theMode == 0) 
360     ChangeRepresentationToWireframe();
361   else if (theMode == 1)
362     ChangeRepresentationToSurface();
363   else if (theMode == 2) {
364     ChangeRepresentationToSurfaceWithEdges();
365     theMode++;
366   }
367   myDisplayMode = theMode;
368 }
369
370 /*!
371   Set current display mode
372   \param theIObject - object
373   \param theMode - new display mode
374 */
375 void
376 SVTK_View
377 ::SetDisplayMode(const Handle(SALOME_InteractiveObject)& theIObject, 
378                  int theMode)
379 {
380   using namespace SVTK;
381   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
382   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
383                           TIsSameIObject<SALOME_Actor>(theIObject),
384                           TSetFunction<SALOME_Actor,int>
385                           (&SALOME_Actor::setDisplayMode,theMode));
386 }
387
388 /*!
389   Change all actors to wireframe
390 */
391 void
392 SVTK_View
393 ::ChangeRepresentationToWireframe()
394 {
395   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
396   ChangeRepresentationToWireframe(aCopy.GetActors());
397 }
398
399 /*!
400   Change all actors to shading
401 */
402 void
403 SVTK_View
404 ::ChangeRepresentationToSurface()
405 {
406   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
407   ChangeRepresentationToSurface(aCopy.GetActors());
408 }
409
410 /*!
411   Change all actors to shading with edges
412 */
413 void
414 SVTK_View
415 ::ChangeRepresentationToSurfaceWithEdges()
416 {
417   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
418   ChangeRepresentationToSurfaceWithEdges(aCopy.GetActors());
419 }
420
421 /*!
422   Change to wireframe a list of vtkactor
423   theCollection - list of vtkactor
424 */
425 void
426 SVTK_View
427 ::ChangeRepresentationToWireframe(vtkActorCollection* theCollection)
428 {
429   using namespace SVTK;
430   ForEach<SALOME_Actor>(theCollection,
431                         TSetFunction<SALOME_Actor,int>
432                         (&SALOME_Actor::setDisplayMode,0));
433   Repaint();
434 }
435
436 /*!
437   Change to shading a list of vtkactor
438   theCollection - list of vtkactor
439 */
440 void
441 SVTK_View
442 ::ChangeRepresentationToSurface(vtkActorCollection* theCollection)
443 {
444   using namespace SVTK;
445   ForEach<SALOME_Actor>(theCollection,
446                         TSetFunction<SALOME_Actor,int>
447                         (&SALOME_Actor::setDisplayMode,1));
448   Repaint();
449 }
450
451 /*!
452   Change to shading with edges a list of vtkactor
453   theCollection - list of vtkactor
454 */
455 void
456 SVTK_View
457 ::ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* theCollection)
458 {
459   using namespace SVTK;
460   ForEach<SALOME_Actor>(theCollection,
461                         TSetFunction<SALOME_Actor,int>
462                         (&SALOME_Actor::setDisplayMode,3));
463   Repaint();
464 }
465
466 namespace SVTK
467 {
468   struct TErase
469   {
470     VTK::TSetFunction<vtkActor,int> mySetFunction;
471     TErase():
472       mySetFunction(&vtkActor::SetVisibility,false)
473     {}
474     void
475     operator()(SALOME_Actor* theActor)
476     {
477       theActor->SetVisibility(false);
478       // Erase dependent actors
479       vtkActorCollection* aCollection = vtkActorCollection::New(); 
480       theActor->GetChildActors(aCollection);
481       VTK::ForEach<vtkActor>(aCollection,mySetFunction);
482       aCollection->Delete();
483     }
484   };
485 }
486
487 /*!
488   To erase all existing VTK presentations
489 */
490 void
491 SVTK_View
492 ::EraseAll()
493 {   
494   using namespace SVTK;
495   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
496   ForEach<SALOME_Actor>(aCopy.GetActors(),
497                         TErase());
498   Repaint();
499 }
500
501 /*!
502   To display all existing VTK presentations
503 */
504 void
505 SVTK_View
506 ::DisplayAll()
507
508   using namespace SVTK;
509   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
510   ForEach<SALOME_Actor>(aCopy.GetActors(),
511                         TSetVisibility<SALOME_Actor>(true));
512   Repaint();
513 }
514
515 /*!
516   To erase VTK presentation
517   \param theActor - actor
518   \param theIsUpdate - updates current viewer
519 */
520 void
521 SVTK_View
522 ::Erase(SALOME_Actor* theActor, 
523         bool theIsUpdate)
524 {
525   SVTK::TErase()(theActor);
526
527   if(theIsUpdate)
528     Repaint();
529 }
530
531
532 /*!
533   To erase VTK presentation
534   \param theIObject - object
535   \param theIsUpdate - updates current viewer
536 */
537 void
538 SVTK_View
539 ::Erase(const Handle(SALOME_InteractiveObject)& theIObject, 
540         bool theIsUpdate)
541 {
542   using namespace SVTK;
543   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
544   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
545                           TIsSameIObject<SALOME_Actor>(theIObject),
546                           TErase());
547   if(theIsUpdate)
548     Repaint();
549 }
550
551 /*!
552   To display the VTK presentation
553 */
554 void
555 SVTK_View
556 ::Display(SALOME_Actor* theActor, 
557           bool theIsUpdate)
558 {
559   GetRenderer()->AddActor(theActor);
560   theActor->SetVisibility(true);
561
562   if(theIsUpdate)
563     Repaint();
564 }
565
566 /*!
567   To display the VTK presentation
568 */
569 void
570 SVTK_View
571 ::Display(const Handle(SALOME_InteractiveObject)& theIObject, 
572           bool theIsUpdate)
573 {
574   using namespace SVTK;
575   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
576   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
577                           TIsSameIObject<SALOME_Actor>(theIObject),
578                           TSetVisibility<SALOME_Actor>(true));
579
580   if(theIsUpdate)
581     Repaint();
582 }
583
584 /*!
585   To display VTK presentation with defined #SALOME_InteractiveObject and erase all others
586 */
587 void
588 SVTK_View
589 ::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject)
590 {
591   EraseAll();
592   Display(theIObject);
593 }
594
595
596 namespace SVTK
597 {
598   struct TRemoveAction
599   {
600     SVTK_Renderer* myRenderer;
601     TRemoveAction(SVTK_Renderer* theRenderer): 
602       myRenderer(theRenderer)
603     {}
604     void
605     operator()(SALOME_Actor* theActor)
606     {
607       myRenderer->RemoveActor(theActor);
608     }
609   };
610 }
611
612 /*!
613   To remove the VTK presentation
614 */
615 void
616 SVTK_View
617 ::Remove(const Handle(SALOME_InteractiveObject)& theIObject, 
618          bool theIsUpdate)
619 {
620   using namespace SVTK;
621   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
622   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
623                           TIsSameIObject<SALOME_Actor>(theIObject),
624                           TRemoveAction(GetRenderer()));
625   if(theIsUpdate)
626     Repaint();
627 }
628
629 /*!
630   To remove the VTK presentation
631 */
632 void
633 SVTK_View
634 ::Remove(SALOME_Actor* theActor, 
635          bool theIsUpdate)
636 {
637   GetRenderer()->RemoveActor(theActor);
638   if(theIsUpdate)
639     Repaint();
640 }
641
642 /*!
643   To remove all VTK presentations
644 */
645 void
646 SVTK_View
647 ::RemoveAll(bool theIsUpdate)
648 {
649   vtkRenderer* aRenderer = getRenderer();
650   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
651   if(vtkActorCollection* anActors = aCopy.GetActors()){
652     anActors->InitTraversal();
653     while(vtkActor *anAct = anActors->GetNextActor()){
654       if(SALOME_Actor* aSAct = SALOME_Actor::SafeDownCast(anAct)){
655         if(aSAct->hasIO() && aSAct->getIO()->hasEntry())
656           aRenderer->RemoveActor( anAct );
657       }
658     }
659
660     if(theIsUpdate)
661       Repaint();
662   }
663 }
664
665 /*!
666   \return current transparency
667   \param theIObject - object
668 */
669 float
670 SVTK_View
671 ::GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject) 
672 {
673   using namespace SVTK;
674   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
675   SALOME_Actor* anActor = 
676     Find<SALOME_Actor>(aCopy.GetActors(),
677                        TIsSameIObject<SALOME_Actor>(theIObject));
678   if(anActor)
679     return 1.0 - anActor->GetOpacity();
680   return -1.0;
681 }
682
683
684 /*!
685   Sets current transparency
686   \param theIObject - object
687   \param theTrans - new transparency
688 */
689 void
690 SVTK_View
691 ::SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject, 
692                   float theTrans)
693 {
694   double anOpacity = 1.0 - theTrans;
695   using namespace SVTK;
696   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
697   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
698                           TIsSameIObject<SALOME_Actor>(theIObject),
699                           TSetFunction<SALOME_Actor,double>
700                           (&SALOME_Actor::SetOpacity,anOpacity));
701 }
702
703 /*!
704   Change color
705   \param theIObject - object
706   \param theColor - new color
707 */
708 void
709 SVTK_View
710 ::SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
711            const QColor& theColor) 
712 {
713   double aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
714
715   using namespace SVTK;
716   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
717   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
718                           TIsSameIObject<SALOME_Actor>(theIObject),
719                           TSetFunction<SALOME_Actor,const double*>
720                           (&SALOME_Actor::SetColor,aColor));
721 }
722
723
724 /*!
725   \return object color
726   \param theIObject - object
727 */
728 QColor
729 SVTK_View
730 ::GetColor(const Handle(SALOME_InteractiveObject)& theIObject) 
731 {
732   using namespace SVTK;
733   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
734   SALOME_Actor* anActor = 
735     Find<SALOME_Actor>(aCopy.GetActors(),
736                        TIsSameIObject<SALOME_Actor>(theIObject));
737   if(anActor){
738     double r,g,b;
739     anActor->GetColor(r,g,b);
740     return QColor(int(r*255),int(g*255),int(b*255));
741   }
742
743   return QColor(0,0,0);
744 }
745
746 /*!
747   Change material
748   \param theIObject - object
749   \param thePropF - property contained new properties of front material
750   \param thePropB - property contained new properties of back material
751 */
752 void
753 SVTK_View
754 ::SetMaterial(const Handle(SALOME_InteractiveObject)& theIObject,
755               vtkProperty* thePropF, vtkProperty* thePropB)
756 {
757   using namespace SVTK;
758   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
759   std::vector<vtkProperty*> aProps;
760   aProps.push_back( thePropF );
761   aProps.push_back( thePropB );
762   ForEachIf<SALOME_Actor>(aCopy.GetActors(),
763                           TIsSameIObject<SALOME_Actor>(theIObject),
764                           TSetFunction<SALOME_Actor,std::vector<vtkProperty*> >
765                           (&SALOME_Actor::SetMaterial,aProps));
766 }
767
768 /*!\r
769   Get current front material\r
770   \param theIObject - object\r
771   \return property contained front material properties of the given object\r
772 */\r
773 vtkProperty* \r
774 SVTK_View\r
775 ::GetFrontMaterial(const Handle(SALOME_InteractiveObject)& theIObject)\r
776 {\r
777   using namespace SVTK;\r
778   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());\r
779   SALOME_Actor* anActor = \r
780     Find<SALOME_Actor>(aCopy.GetActors(),\r
781                        TIsSameIObject<SALOME_Actor>(theIObject));\r
782   if(anActor)\r
783     return anActor->GetFrontMaterial();\r
784   return NULL;\r
785 }\r
786 \r
787 /*!\r
788   Get current back material\r
789   \param theIObject - object\r
790   \return property contained back material properties of the given object\r
791 */\r
792 vtkProperty* \r
793 SVTK_View\r
794 ::GetBackMaterial(const Handle(SALOME_InteractiveObject)& theIObject)\r
795 {\r
796   using namespace SVTK;\r
797   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());\r
798   SALOME_Actor* anActor = \r
799     Find<SALOME_Actor>(aCopy.GetActors(),\r
800                        TIsSameIObject<SALOME_Actor>(theIObject));\r
801   if(anActor)\r
802     return anActor->GetBackMaterial();
803   return NULL;
804 }
805
806 /*!
807   \Collect objects visible in viewer
808   \param theList - visible objects collection
809 */
810 void SVTK_View::GetVisible( SALOME_ListIO& theList )
811 {
812   using namespace SVTK;
813   VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
814   ForEach<SALOME_Actor>(aCopy.GetActors(),
815                         TCollectIfVisible<SALOME_Actor>(theList));
816 }