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