Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / VTKViewer / VTKViewer_RenderWindowInteractor.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #include "VTKViewer_RenderWindowInteractor.h"
20 #include "VTKViewer_RenderWindow.h"
21 #include "VTKViewer_InteractorStyle.h"
22 #include "SUIT_ViewModel.h"
23 #include "VTKViewer_ViewWindow.h"
24
25 //#include "SUIT_Application.h"
26 //#include "SUIT_Desktop.h"
27
28 //#include "SALOME_Selection.h"
29 #include "VTKViewer_Actor.h"
30 #include "VTKViewer_Algorithm.h"
31 #include "VTKViewer_Functor.h"
32
33 //#include <stdio.h>
34 //#include <stdlib.h>
35 //#include <string.h>
36 //#include <math.h>
37
38 // VTK Includes
39 #include <vtkAssemblyNode.h>
40 #include <vtkActor.h>
41 #include <vtkInteractorStyle.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkPicker.h>
44 #include <vtkCellPicker.h>
45 #include <vtkPointPicker.h>
46 #include <vtkUnstructuredGrid.h>
47 #include <vtkPolyDataMapper.h>
48 #include <vtkSphereSource.h>
49 #include <vtkDataSet.h>
50 #include <vtkMaskPoints.h>
51 #include <vtkVertex.h>
52 #include <vtkRendererCollection.h>
53 #include <vtkPolyDataWriter.h>
54 #include <vtkProperty.h>
55
56 // QT Includes
57 #include <qkeycode.h>
58
59 /*! Create new instance of VTKViewer_RenderWindowInteractor*/
60 VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() 
61 {
62   vtkObject *ret = vtkObjectFactory::CreateInstance("VTKViewer_RenderWindowInteractor") ;
63   if( ret ) {
64     return dynamic_cast<VTKViewer_RenderWindowInteractor *>(ret) ;
65   }
66   return new VTKViewer_RenderWindowInteractor;
67 }
68
69 /*!Constructor.*/
70 VTKViewer_RenderWindowInteractor::VTKViewer_RenderWindowInteractor() 
71 {
72   this->Enabled = 0 ;
73   this->mTimer = new QTimer( this ) ;
74   myDisplayMode = 0;
75
76   myBasicPicker = vtkPicker::New();
77   myCellPicker = vtkCellPicker::New();
78   myPointPicker = vtkPointPicker::New();
79
80   myCellActor = VTKViewer_Actor::New(); 
81   myCellActor->PickableOff();
82   myCellActor->GetProperty()->SetColor(1,1,0);
83   myCellActor->GetProperty()->SetLineWidth(5);
84   myCellActor->GetProperty()->SetRepresentationToSurface();
85
86   myEdgeActor = VTKViewer_Actor::New(); 
87   myEdgeActor->PickableOff();
88   myEdgeActor->GetProperty()->SetColor(1,0,0);
89   myEdgeActor->GetProperty()->SetLineWidth(5);
90   myEdgeActor->GetProperty()->SetRepresentationToWireframe();
91
92   myPointActor = VTKViewer_Actor::New(); 
93   myPointActor->PickableOff();
94   myPointActor->GetProperty()->SetColor(1,1,0);
95   myPointActor->GetProperty()->SetPointSize(5);
96   myPointActor->GetProperty()->SetRepresentationToPoints();
97
98   connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ;
99 }
100
101 /*!Destructor.*/
102 VTKViewer_RenderWindowInteractor::~VTKViewer_RenderWindowInteractor() 
103 {
104   delete mTimer ;
105
106   if ( GetRenderWindow() ) {
107     myViewWnd->RemoveActor(myCellActor);
108     myViewWnd->RemoveActor(myEdgeActor);
109     myViewWnd->RemoveActor(myPointActor);
110   }
111
112   myCellActor->Delete();
113   myEdgeActor->Delete();
114   myPointActor->Delete();
115
116   myBasicPicker->Delete();
117   myCellPicker->Delete();
118   myPointPicker->Delete();
119 }
120
121 /*!
122   Print interactor to stream
123   \param os - stream
124   \param indent
125 */
126 void VTKViewer_RenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) 
127 {
128   vtkRenderWindowInteractor::PrintSelf(os, indent) ;
129   //
130   // :NOTE: Fri Apr 21 21:51:05 2000 Pagey
131   // QGL specific stuff goes here. One should add output 
132   // lines here if any protected members are added to
133   // the class. 
134   //
135 }
136
137 /*!Description:\n
138  * Initializes the event handlers without an XtAppContext.  This is \n
139  * good for when you don`t have a user interface, but you still \n
140  * want to have mouse interaction.\n
141  * We never allow the VTKViewer_RenderWindowInteractor to control \n
142  * the event loop. The application always has the control.
143  */
144 void VTKViewer_RenderWindowInteractor::Initialize()
145 {
146   //
147   // We cannot do much unless there is a render window 
148   // associated with this interactor. 
149   //
150   if( ! RenderWindow ) {
151     vtkErrorMacro(<< "VTKViewer_RenderWindowInteractor::Initialize(): No render window attached!") ;
152     return ;
153   }
154   
155   //
156   // We cannot hand a render window which is not a VTKViewer_RenderWindow. 
157   // One way to force this is to use dynamic_cast and hope that 
158   // it works. If the dynamic_cast does not work, we flag an error
159   // and get the hell out.
160   //
161   vtkRenderWindow *my_render_win = dynamic_cast<vtkRenderWindow *>(RenderWindow) ;
162   if( !my_render_win ) {
163     vtkErrorMacro(<< "VTKViewer_RenderWindowInteractor::Initialize() can only handle VTKViewer_RenderWindow.") ;
164     return ;
165   }
166  
167   //
168   // If the render window has zero size, then set it to a default 
169   // value of 300x300.
170   // 
171   int* aSize = my_render_win->GetSize();
172   this->Size[0] = ((aSize[0] > 0) ? aSize[0] : 300);
173   this->Size[1] = ((aSize[1] > 0) ? aSize[1] : 300);
174
175   this->SetPicker(myBasicPicker);
176
177   SetSelectionTolerance();
178
179   //
180   // Enable the interactor. 
181   //
182   this->Enable() ;
183   
184   //
185   // Start the rendering of the window. 
186   //
187   my_render_win->Start() ;
188   
189   //
190   // The interactor has been initialized.
191   //
192   this->Initialized = 1 ;
193
194   return ;
195 }
196
197 /*!Sets view window and add to it selection actors.*/
198 void VTKViewer_RenderWindowInteractor::setViewWindow(VTKViewer_ViewWindow* theViewWnd){
199   myViewWnd = theViewWnd;
200
201   if ( myViewWnd ) {
202     myViewWnd->InsertActor(myCellActor);
203     myViewWnd->InsertActor(myEdgeActor);
204     myViewWnd->InsertActor(myPointActor);
205   }
206 }
207
208 /*!Move selection actors to view window.*/
209 void VTKViewer_RenderWindowInteractor::MoveInternalActors()
210 {
211   myViewWnd->MoveActor(myCellActor);
212   myViewWnd->MoveActor(myEdgeActor);
213   myViewWnd->MoveActor(myPointActor);
214 }
215
216 /*!Sets interactor style.*/
217 void VTKViewer_RenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver *theInteractor){
218   myInteractorStyle = dynamic_cast<VTKViewer_InteractorStyle*>(theInteractor);
219   vtkRenderWindowInteractor::SetInteractorStyle(theInteractor);
220 }
221
222 /*!Sets selection properties.
223  *\param theRed - red component of color
224  *\param theGreen - green component of color
225  *\param theBlue - blue component of color
226  *\param theWidth - point size and line width
227  */
228 void VTKViewer_RenderWindowInteractor::SetSelectionProp(const double& theRed, const double& theGreen, 
229                                                         const double& theBlue, const int& theWidth) 
230 {
231   myCellActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
232   myCellActor->GetProperty()->SetLineWidth(theWidth);
233
234   myPointActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
235   myPointActor->GetProperty()->SetPointSize(theWidth);
236 }
237
238 /*!Sets selection tolerance
239  *\param theTolNodes - nodes selection tolerance
240  *\param theTolItems - selection tolerance for basic and cell pickers.
241  */
242 void VTKViewer_RenderWindowInteractor::SetSelectionTolerance(const double& theTolNodes, const double& theTolItems)
243 {
244   myTolNodes = theTolNodes;
245   myTolItems = theTolItems;
246
247   myBasicPicker->SetTolerance(myTolItems);
248   myCellPicker->SetTolerance(myTolItems);
249   myPointPicker->SetTolerance(myTolNodes);
250
251 }
252
253 /*! Description:\n
254  * Enable/Disable interactions.  By default interactors are enabled when \n
255  * initialized.  Initialize() must be called prior to enabling/disabling \n
256  * interaction. These methods are used when a window/widget is being \n
257  * shared by multiple renderers and interactors.  This allows a "modal" \n
258  * display where one interactor is active when its data is to be displayed \n
259  * and all other interactors associated with the widget are disabled \n
260  * when their data is not displayed.
261  */
262 void VTKViewer_RenderWindowInteractor::Enable()
263 {
264   //
265   // Do not need to do anything if already enabled.
266   //
267   if( this->Enabled ) {
268     return ;
269   }
270   
271   this->Enabled = 1 ;
272   this->Modified() ;
273 }
274
275 /*!See Enable().*/
276 void VTKViewer_RenderWindowInteractor::Disable()
277 {
278   if( ! this->Enabled ) {
279     return ;
280   }
281   
282   this->Enabled = 0 ;
283   this->Modified() ;
284 }
285
286 /*!Description:\n
287  * This will start up the X event loop and never return. If you \n
288  * call this method it will loop processing X events until the \n
289  * application is exited.
290  */
291 void VTKViewer_RenderWindowInteractor::Start()
292 {
293   //
294   // We do not allow this interactor to control the 
295   // event loop. Only the QtApplication objects are
296   // allowed to do that. 
297   //
298   vtkErrorMacro(<<"VTKViewer_RenderWindowInteractor::Start() not allowed to start event loop.") ;
299 }
300
301 /*! Description:\n
302  * Event loop notification member for Window size change
303  */
304 void VTKViewer_RenderWindowInteractor::UpdateSize(int w, int h)
305 {
306   // if the size changed send this on to the RenderWindow
307   if ((w != this->Size[0])||(h != this->Size[1])) {
308     this->Size[0] = w;
309     this->Size[1] = h;
310     this->RenderWindow->SetSize(w,h);
311   }
312 }
313
314 /*! Description: 
315  * Timer methods must be overridden by platform dependent subclasses.
316  * flag is passed to indicate if this is first timer set or an update 
317  * as Win32 uses repeating timers, whereas X uses One shot more timer 
318  * if flag == VTKXI_TIMER_FIRST Win32 and X should createtimer 
319  * otherwise Win32 should exit and X should perform AddTimeOut
320  * \retval 1
321  */
322 int VTKViewer_RenderWindowInteractor::CreateTimer(int vtkNotUsed(timertype))
323 {
324   ///
325   /// Start a one-shot timer for 10ms.
326   ///
327   mTimer->start(10, TRUE) ;
328   return 1 ;
329 }
330
331 /*! 
332   \sa CreateTimer(int )
333   \retval 1
334  */
335 int VTKViewer_RenderWindowInteractor::DestroyTimer(void)
336 {
337   //
338   // :TRICKY: Tue May  2 00:17:32 2000 Pagey
339   //
340   /*! QTimer will automatically expire after 10ms. So 
341    * we do not need to do anything here. In fact, we 
342    * should not even Stop() the QTimer here because doing 
343    * this will skip some of the processing that the TimerFunc()
344    * does and will result in undesirable effects. For 
345    * example, this will result in vtkLODActor to leave
346    * the models in low-res mode after the mouse stops
347    * moving. 
348    */
349   return 1 ;
350 }
351
352 /*! Not all of these slots are needed in VTK_MAJOR_VERSION=3,\n
353  * but moc does not understand "#if VTK_MAJOR_VERSION". Hence, \n
354  * we have to include all of these for the time being. Once,\n
355  * this bug in MOC is fixed, we can separate these. 
356  */
357 void VTKViewer_RenderWindowInteractor::TimerFunc()
358 {
359   if( ! this->Enabled ) {
360     return ;
361   }
362   
363   ((vtkInteractorStyle*)this->InteractorStyle)->OnTimer() ;
364   emit RenderWindowModified() ;
365 }
366
367 /*!Emit render window modified on mouse move,\n
368  *if interactor style needs redrawing and render window enabled.*/
369 void VTKViewer_RenderWindowInteractor::MouseMove(QMouseEvent *event) {
370   if( ! this->Enabled ) {
371     return ;
372   }
373   myInteractorStyle->OnMouseMove(0, 0, event->x(), event->y()/*this->Size[1] - event->y() - 1*/) ;
374   if (myInteractorStyle->needsRedrawing() )
375     emit RenderWindowModified() ; 
376 }
377
378 /*!Reaction on left button pressed.\n
379  *Same as left button down for interactor style.\n
380  *If render window enabled.
381  */
382 void VTKViewer_RenderWindowInteractor::LeftButtonPressed(const QMouseEvent *event) {
383   if( ! this->Enabled ) {
384     return ;
385   }
386   myInteractorStyle->OnLeftButtonDown((event->state() & ControlButton), 
387                                       (event->state() & ShiftButton), 
388                                       event->x(), event->y());
389 }
390
391 /*!Reaction on left button releases.\n
392  *Same as left button up for interactor style.\n
393  *If render window enabled.
394  */
395 void VTKViewer_RenderWindowInteractor::LeftButtonReleased(const QMouseEvent *event) {
396   if( ! this->Enabled ) {
397     return ;
398   }
399   myInteractorStyle->OnLeftButtonUp( (event->state() & ControlButton), 
400                                      (event->state() & ShiftButton), 
401                                      event->x(), event->y() ) ;
402 }
403
404 /*!Reaction on middle button pressed.\n
405  *Same as middle button down for interactor style.\n
406  *If render window enabled.
407  */
408 void VTKViewer_RenderWindowInteractor::MiddleButtonPressed(const QMouseEvent *event) {
409   if( ! this->Enabled ) {
410     return ;
411   }
412   myInteractorStyle->OnMiddleButtonDown((event->state() & ControlButton), 
413                                         (event->state() & ShiftButton), 
414                                         event->x(), event->y() ) ;
415 }
416
417 /*!Reaction on middle button released.\n
418  *Same as middle button up for interactor style.\n
419  *If render window enabled.
420  */
421 void VTKViewer_RenderWindowInteractor::MiddleButtonReleased(const QMouseEvent *event) {
422   if( ! this->Enabled ) {
423     return ;
424   }
425   myInteractorStyle->OnMiddleButtonUp( (event->state() & ControlButton), 
426                                        (event->state() & ShiftButton), 
427                                        event->x(), event->y() ) ;
428 }
429
430 /*!Reaction on right button pressed.\n
431  *Same as right button down for interactor style.\n
432  *If render window enabled.
433  */
434 void VTKViewer_RenderWindowInteractor::RightButtonPressed(const QMouseEvent *event) {
435   if( ! this->Enabled ) {
436     return ;
437   }
438   myInteractorStyle->OnRightButtonDown( (event->state() & ControlButton), 
439                                         (event->state() & ShiftButton), 
440                                         event->x(), event->y() ) ;
441 }
442
443 /*!Reaction on right button released.\n
444  *Same as right button up for interactor style.If render window enabled.\n
445  *Emit context menu requested, if interactor style state equal VTK_INTERACTOR_STYLE_CAMERA_NONE.
446  */
447 void VTKViewer_RenderWindowInteractor::RightButtonReleased(const QMouseEvent *event) {
448   if( ! this->Enabled ) {
449     return ;
450   }
451   bool isOperation = myInteractorStyle->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE;
452   myInteractorStyle->OnRightButtonUp( (event->state() & ControlButton),
453                                       (event->state() & ShiftButton),
454                                       event->x(), event->y() );
455   if ( !isOperation )
456   {
457     QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
458                               event->pos(), event->globalPos(),
459                               event->state() );
460     emit contextMenuRequested( &aEvent );
461   }
462 }
463
464 /*!Reaction on button pressed.
465  *\warning Do nothing.
466  */
467 void VTKViewer_RenderWindowInteractor::ButtonPressed(const QMouseEvent *event) {
468   return ;
469 }
470
471 /*!Reaction on button released..
472  *\warning Do nothing.
473  */
474 void VTKViewer_RenderWindowInteractor::ButtonReleased(const QMouseEvent *event) {
475   return ;
476 }
477
478 /*!Gets display mode.*/
479 int VTKViewer_RenderWindowInteractor::GetDisplayMode() {
480   return myDisplayMode;
481 }
482
483 /*!Sets display mode.*/
484 void VTKViewer_RenderWindowInteractor::SetDisplayMode(int theMode) {
485   if(theMode == 0)
486     ChangeRepresentationToWireframe();
487   else
488     ChangeRepresentationToSurface();
489   myDisplayMode = theMode;
490 }
491
492 /*!Change all actors to wireframe*/
493 void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe()
494 {
495   ChangeRepresentationToWireframe(GetRenderer()->GetActors());
496 }
497
498 /*!Change all actors to surface*/
499 void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface()
500 {
501   ChangeRepresentationToSurface(GetRenderer()->GetActors());
502 }
503
504 /*!Change all actors from \a theCollection to wireframe and
505  * emit render window modified.
506  */
507 void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe(vtkActorCollection* theCollection)
508 {
509   using namespace VTK;
510   ForEach<VTKViewer_Actor>(theCollection,
511                         TSetFunction<VTKViewer_Actor,int>
512                         (&VTKViewer_Actor::setDisplayMode,0));
513   emit RenderWindowModified();
514 }
515
516 /*!Change all actors from \a theCollection to surface and
517  * emit render window modified.
518  */
519 void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCollection* theCollection)
520 {
521   using namespace VTK;
522   ForEach<VTKViewer_Actor>(theCollection,
523                         TSetFunction<VTKViewer_Actor,int>
524                         (&VTKViewer_Actor::setDisplayMode,1));
525   emit RenderWindowModified();
526 }
527
528 /*!Gets renderer.*/
529 vtkRenderer* VTKViewer_RenderWindowInteractor::GetRenderer()
530 {
531   vtkRendererCollection * theRenderers =  this->RenderWindow->GetRenderers();
532   theRenderers->InitTraversal();
533   return theRenderers->GetNextItem();
534 }
535
536 /*!Do nothing*/
537 void VTKViewer_RenderWindowInteractor::EraseAll()
538 {
539 }
540
541 /*!Display all actors.
542  *Sets visible for all actors from renderer collection and emit render window modified.
543  */
544 void VTKViewer_RenderWindowInteractor::DisplayAll()
545 {
546   using namespace VTK;
547   vtkActorCollection* aCollection = GetRenderer()->GetActors();
548   ForEach<VTKViewer_Actor>(aCollection,TSetVisibility<VTKViewer_Actor>(true));
549
550   emit RenderWindowModified() ;
551 }
552
553 /*!Do nothing*/
554 void VTKViewer_RenderWindowInteractor::Erase( VTKViewer_Actor* SActor, bool update)
555 {
556 }
557
558 /*!Remove \a SActor from renderer and emit update window, if \a updateViewer - true*/
559 void VTKViewer_RenderWindowInteractor::Remove( VTKViewer_Actor* SActor, bool updateViewer )
560 {
561   if ( SActor != 0 )
562   {
563     GetRenderer()->RemoveProp( SActor );
564     if ( updateViewer )
565       emit RenderWindowModified();
566   }
567 }
568
569 /*!Remove actors from render window collection(not implemented).
570  *Emit render window modified, if \a updateViewer - true.
571  */
572 void VTKViewer_RenderWindowInteractor::RemoveAll( const bool updateViewer )
573 {
574   vtkRenderer* aRenderer = GetRenderer();
575   vtkActorCollection* anActors = aRenderer->GetActors();
576   if ( anActors )
577   {
578     anActors->InitTraversal();
579     while ( vtkActor *anAct = anActors->GetNextActor() )
580     {
581       if ( anAct->IsA( "VTKViewer_Actor" ) )
582       {
583       }
584     }
585
586     if ( updateViewer )
587       emit RenderWindowModified();
588   }
589 }
590
591 /*!\brief Display the \a theActor.*/
592 /*! Add actor to renderer and set visibility to true.
593  * Emit render window modified, if \a update - true.
594  */
595 void VTKViewer_RenderWindowInteractor::Display( VTKViewer_Actor* theActor, bool update)
596 {
597   GetRenderer()->AddActor(theActor);
598   theActor->SetVisibility(true);
599
600   if(update)
601     emit RenderWindowModified();
602 }
603
604 /*!
605   default key press event (empty implementation)
606 */
607 void VTKViewer_RenderWindowInteractor::KeyPressed(QKeyEvent *event)
608 {
609   /// NOT_IMPLEMENTED
610 }
611
612 /*!Structure with one function "operator()", which call apply properties for actor.*/
613 struct TUpdateAction{
614   /*!Apply properties for \a theActor.*/
615   void operator()(vtkActor* theActor){
616     theActor->ApplyProperties();
617   }
618 };
619
620 /*!Update all actors from renderer and emit render window modified.*/
621 void VTKViewer_RenderWindowInteractor::Update() {
622   using namespace VTK;
623   vtkRenderer* aRen = GetRenderer();
624   ForEach<vtkActor>(aRen->GetActors(),TUpdateAction());
625
626   aRen->ResetCamera();
627
628   emit RenderWindowModified();  
629 }
630
631 /*!Unhighlight all selection actors.*/
632 void VTKViewer_RenderWindowInteractor::unHighlightSubSelection(){
633   myPointActor->SetVisibility(false);
634   myEdgeActor->SetVisibility(false);
635   myCellActor->SetVisibility(false);
636 }
637
638 /*!@see unHighlightSubSelection()
639  * Also emit render window modified.
640  */
641 bool VTKViewer_RenderWindowInteractor::unHighlightAll(){
642   unHighlightSubSelection();
643
644   emit RenderWindowModified() ;
645   return false;
646 }
647
648
649 /*! \li Sets actors data and sets visibility to true, if flag \a hilight - true, 
650  * else sets visibility to false.
651  * \li Emit render window modified, if flag \a update - true.
652  */
653 bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
654                                                  VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
655                                                  TUpdateActor theFun, bool hilight, bool update)
656 {
657   if(theMapIndex.Extent() == 0) return false;
658
659   if (hilight) {
660     setActorData(theMapIndex,theMapActor,theActor,theFun);
661     theActor->SetVisibility(true);
662   }
663   else {
664     theActor->SetVisibility(false);
665   }
666
667   if(update){
668     this->RenderWindow->Render();
669     emit RenderWindowModified() ;
670   }
671
672   return false;
673 }
674
675 /*!Sets actors data.*/
676 void VTKViewer_RenderWindowInteractor::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
677                                                     VTKViewer_Actor * theMapActor,
678                                                     VTKViewer_Actor * theActor,
679                                                     TUpdateActor theFun)
680 {
681   (*theFun)(theMapIndex,theMapActor,theActor);
682   vtkFloatingPointType aPos[3];
683   theMapActor->GetPosition(aPos);
684   theActor->SetPosition(aPos);
685 }