Salome HOME
50a7950ebe805b489819518e8d074766db7e9ec0
[modules/gui.git] / src / VTKViewer / VTKViewer_ViewWindow.cxx
1 #include "VTKViewer_ViewWindow.h"
2 #include "VTKViewer_ViewModel.h"
3 #include "VTKViewer_RenderWindow.h"
4 #include "VTKViewer_RenderWindowInteractor.h"
5 #include "VTKViewer_InteractorStyle.h"
6 #include "VTKViewer_Trihedron.h"
7 #include "VTKViewer_Transform.h"
8 #include "VTKViewer_Utilities.h"
9
10 #include "SUIT_Session.h"
11 #include "SUIT_ToolButton.h"
12 #include "SUIT_MessageBox.h"
13
14 #include "SUIT_Tools.h"
15 #include "SUIT_ResourceMgr.h"
16
17 #include <qapplication.h>
18
19 #include <vtkRenderer.h>
20 #include <vtkCamera.h>
21
22 /*! Construction*/
23 VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, 
24                                             VTKViewer_Viewer* theModel,
25                                             VTKViewer_InteractorStyle* iStyle,
26                                             VTKViewer_RenderWindowInteractor* rw )
27 : SUIT_ViewWindow( theDesktop )
28 {
29   myModel = theModel;
30
31   myTrihedron = VTKViewer_Trihedron::New();
32   myTransform = VTKViewer_Transform::New();
33   myRenderer  = vtkRenderer::New() ;
34
35   myTrihedron->AddToRender( myRenderer );
36
37   myRenderWindow = new VTKViewer_RenderWindow( this, "RenderWindow" );
38   setCentralWidget(myRenderWindow);
39   myRenderWindow->setFocusPolicy( StrongFocus );
40   myRenderWindow->setFocus();
41
42   myRenderWindow->getRenderWindow()->AddRenderer( myRenderer );
43
44   myRenderer->GetActiveCamera()->ParallelProjectionOn();
45   myRenderer->LightFollowCameraOn();
46   myRenderer->TwoSidedLightingOn();
47
48   // Set BackgroundColor
49   QString BgrColorRed   = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
50   QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
51   QString BgrColorBlue  = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
52
53   if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() ) 
54     myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
55   else
56     myRenderer->SetBackground( 0, 0, 0 );
57   
58   // Create an interactor.
59   myRWInteractor = rw ? rw : VTKViewer_RenderWindowInteractor::New();
60   myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
61
62   VTKViewer_InteractorStyle* RWS = iStyle ? iStyle : VTKViewer_InteractorStyle::New();
63   RWS->setGUIWindow( myRenderWindow );
64   myRWInteractor->SetInteractorStyle( RWS ); 
65
66   myRWInteractor->Initialize();
67   RWS->setTriedron( myTrihedron );
68   RWS->FindPokedRenderer( 0, 0 );
69
70   setCentralWidget( myRenderWindow );
71
72   myToolBar = new QToolBar(this);
73   myToolBar->setCloseMode(QDockWindow::Undocked);
74   myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
75
76   createActions();
77   createToolBar();
78
79   connect( myRenderWindow, SIGNAL(KeyPressed( QKeyEvent* )),
80            this,           SLOT(onKeyPressed( QKeyEvent* )) );
81   connect( myRenderWindow, SIGNAL(KeyReleased( QKeyEvent* )),
82            this,           SLOT(onKeyReleased( QKeyEvent* )) );
83   connect( myRenderWindow, SIGNAL(MouseButtonPressed( QMouseEvent* )),
84            this,           SLOT(onMousePressed( QMouseEvent* )) );
85   connect( myRenderWindow, SIGNAL(MouseButtonReleased( QMouseEvent* )),
86            this,           SLOT(onMouseReleased( QMouseEvent* )) );
87   connect( myRenderWindow, SIGNAL(MouseDoubleClicked( QMouseEvent* )),
88            this,           SLOT(onMouseDoubleClicked( QMouseEvent* )) );
89   connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
90            this,           SLOT(onMouseMoving( QMouseEvent* )) );
91   connect( myRWInteractor, SIGNAL(RenderWindowModified()),
92            myRenderWindow, SLOT(update()) );
93
94   connect( myRenderWindow, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
95            this,           SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
96
97   connect( myRWInteractor, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
98            this,           SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
99
100
101   onResetView();
102 }
103
104 /*!Destructor.*/
105 VTKViewer_ViewWindow::~VTKViewer_ViewWindow()
106 {
107   myTransform->Delete();
108   // In order to ensure that the interactor unregisters
109   // this RenderWindow, we assign a NULL RenderWindow to 
110   // it before deleting it.
111   myRWInteractor->SetRenderWindow( NULL );
112   myRWInteractor->Delete();
113   
114   //m_RW->Delete() ;
115   myRenderer->RemoveAllProps();
116   //m_Renderer->Delete() ;
117   myTrihedron->Delete();
118 }
119
120 /*!Checks: is trihedron displayed.*/
121 bool VTKViewer_ViewWindow::isTrihedronDisplayed(){
122   return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
123 }
124
125 /*!Activates 'zooming' transformation*/
126 void VTKViewer_ViewWindow::activateZoom()
127 {
128   myRWInteractor->GetInteractorStyle()->startZoom();
129 }
130
131 /*!Activates 'panning' transformation*/
132 void VTKViewer_ViewWindow::activatePanning()
133 {
134   myRWInteractor->GetInteractorStyle()->startPan();
135 }
136
137 /*!Activates 'rotation' transformation*/
138 void VTKViewer_ViewWindow::activateRotation()
139 {
140   myRWInteractor->GetInteractorStyle()->startRotate();
141 }
142
143 /*!Activate global panning.*/
144 void VTKViewer_ViewWindow::activateGlobalPanning()
145 {
146   //if(myTrihedron->GetVisibleActorCount(myRenderer))
147   myRWInteractor->GetInteractorStyle()->startGlobalPan();
148 }
149
150 /*!Activates 'fit area' transformation*/
151 void VTKViewer_ViewWindow::activateWindowFit()
152 {
153   myRWInteractor->GetInteractorStyle()->startFitArea();
154 }
155
156 /*!Create actions:*/
157 void VTKViewer_ViewWindow::createActions()
158 {
159   if (!myActionsMap.isEmpty()) return;
160   
161   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
162   
163   QtxAction* aAction;
164
165   //! \li Dump view
166   aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
167                            tr( "MNU_DUMP_VIEW" ), 0, this);
168   aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
169   connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
170   myActionsMap[ DumpId ] = aAction;
171
172   //! \li FitAll
173   aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
174                            tr( "MNU_FITALL" ), 0, this);
175   aAction->setStatusTip(tr("DSC_FITALL"));
176   connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
177   myActionsMap[ FitAllId ] = aAction;
178
179   //! \li FitRect
180   aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
181                            tr( "MNU_FITRECT" ), 0, this);
182   aAction->setStatusTip(tr("DSC_FITRECT"));
183   connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
184   myActionsMap[ FitRectId ] = aAction;
185
186   //! \li Zoom
187   aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
188                            tr( "MNU_ZOOM_VIEW" ), 0, this);
189   aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
190   connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
191   myActionsMap[ ZoomId ] = aAction;
192
193   //! \li Panning
194   aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
195                            tr( "MNU_PAN_VIEW" ), 0, this);
196   aAction->setStatusTip(tr("DSC_PAN_VIEW"));
197   connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
198   myActionsMap[ PanId ] = aAction;
199
200   //! \li Global Panning
201   aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
202                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
203   aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
204   connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
205   myActionsMap[ GlobalPanId ] = aAction;
206
207   //! \li Rotation
208   aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
209                            tr( "MNU_ROTATE_VIEW" ), 0, this);
210   aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
211   connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
212   myActionsMap[ RotationId ] = aAction;
213
214   //! \li Projections
215   aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
216                            tr( "MNU_FRONT_VIEW" ), 0, this);
217   aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
218   connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
219   myActionsMap[ FrontId ] = aAction;
220
221   //! \li Back view
222   aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
223                            tr( "MNU_BACK_VIEW" ), 0, this);
224   aAction->setStatusTip(tr("DSC_BACK_VIEW"));
225   connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
226   myActionsMap[ BackId ] = aAction;
227
228   //! \li Top view
229   aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
230                            tr( "MNU_TOP_VIEW" ), 0, this);
231   aAction->setStatusTip(tr("DSC_TOP_VIEW"));
232   connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
233   myActionsMap[ TopId ] = aAction;
234
235   //! \li Bottom view
236   aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
237                            tr( "MNU_BOTTOM_VIEW" ), 0, this);
238   aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
239   connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
240   myActionsMap[ BottomId ] = aAction;
241
242   //! \li Left view
243   aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
244                            tr( "MNU_LEFT_VIEW" ), 0, this);
245   aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
246   connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
247   myActionsMap[ LeftId ] = aAction;
248
249   //! \li Right view
250   aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
251                            tr( "MNU_RIGHT_VIEW" ), 0, this);
252   aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
253   connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
254   myActionsMap[ RightId ] = aAction;
255
256   //! \li Reset
257   aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
258                            tr( "MNU_RESET_VIEW" ), 0, this);
259   aAction->setStatusTip(tr("DSC_RESET_VIEW"));
260   connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
261   myActionsMap[ ResetId ] = aAction;
262
263   //! \li Trihedron shown
264   aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
265                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
266   aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
267   connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
268   myActionsMap[ TrihedronShowId ] = aAction;
269 }
270
271 /*!Create tool bar.*/
272 void VTKViewer_ViewWindow::createToolBar()
273 {
274   myActionsMap[DumpId]->addTo(myToolBar);
275   myActionsMap[TrihedronShowId]->addTo(myToolBar);
276
277   SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
278   aScaleBtn->AddAction(myActionsMap[FitAllId]);
279   aScaleBtn->AddAction(myActionsMap[FitRectId]);
280   aScaleBtn->AddAction(myActionsMap[ZoomId]);
281
282   SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
283   aPanningBtn->AddAction(myActionsMap[PanId]);
284   aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
285
286   myActionsMap[RotationId]->addTo(myToolBar);
287
288   SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
289   aViewsBtn->AddAction(myActionsMap[FrontId]);
290   aViewsBtn->AddAction(myActionsMap[BackId]);
291   aViewsBtn->AddAction(myActionsMap[TopId]);
292   aViewsBtn->AddAction(myActionsMap[BottomId]);
293   aViewsBtn->AddAction(myActionsMap[LeftId]);
294   aViewsBtn->AddAction(myActionsMap[RightId]);
295
296   myActionsMap[ResetId]->addTo(myToolBar);
297 }
298
299 /*!On front view event.*/
300 void VTKViewer_ViewWindow::onFrontView()
301 {
302   vtkCamera* camera = myRenderer->GetActiveCamera();
303   camera->SetPosition(1,0,0);
304   camera->SetViewUp(0,0,1);
305   camera->SetFocalPoint(0,0,0);
306   onFitAll();
307 }
308
309 /*!On back view slot.*/
310 void VTKViewer_ViewWindow::onBackView()
311 {
312   vtkCamera* camera = myRenderer->GetActiveCamera();
313   camera->SetPosition(-1,0,0);
314   camera->SetViewUp(0,0,1);
315   camera->SetFocalPoint(0,0,0);
316   onFitAll();
317 }
318
319 /*!On back view slot.*/
320 void VTKViewer_ViewWindow::onTopView()
321 {
322   vtkCamera* camera = myRenderer->GetActiveCamera();
323   camera->SetPosition(0,0,1);
324   camera->SetViewUp(0,1,0);
325   camera->SetFocalPoint(0,0,0);
326   onFitAll();
327 }
328
329 /*!On bottom view slot.*/
330 void VTKViewer_ViewWindow::onBottomView()
331 {
332   vtkCamera* camera = myRenderer->GetActiveCamera();
333   camera->SetPosition(0,0,-1);
334   camera->SetViewUp(0,1,0);
335   camera->SetFocalPoint(0,0,0);
336   onFitAll();
337 }
338
339 /*!On left view slot.*/
340 void VTKViewer_ViewWindow::onLeftView()
341 {
342   vtkCamera* camera = myRenderer->GetActiveCamera(); 
343   camera->SetPosition(0,-1,0);
344   camera->SetViewUp(0,0,1);
345   camera->SetFocalPoint(0,0,0);
346   onFitAll();
347 }
348
349 /*!On right view slot.*/
350 void VTKViewer_ViewWindow::onRightView()
351 {
352   vtkCamera* camera = myRenderer->GetActiveCamera();
353   camera->SetPosition(0,1,0);
354   camera->SetViewUp(0,0,1);
355   camera->SetFocalPoint(0,0,0);
356   onFitAll();
357 }
358
359 /*!On reset view slot.*/
360 void VTKViewer_ViewWindow::onResetView()
361 {
362   int aTriedronIsVisible = isTrihedronDisplayed();
363   myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
364   ::ResetCamera(myRenderer,true);  
365   vtkCamera* aCamera = myRenderer->GetActiveCamera();
366   aCamera->SetPosition(1,-1,1);
367   aCamera->SetViewUp(0,0,1);
368   ::ResetCamera(myRenderer,true);  
369   if(aTriedronIsVisible) myTrihedron->VisibilityOn();
370   else myTrihedron->VisibilityOff();
371   static float aCoeff = 3.0;
372   aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
373   Repaint();
374 }
375
376 /*!On fit all slot.*/
377 void VTKViewer_ViewWindow::onFitAll()
378 {
379   myRWInteractor->GetInteractorStyle()->ViewFitAll();
380   Repaint();
381 }
382
383 /*!Set background of the viewport*/
384 void VTKViewer_ViewWindow::setBackgroundColor( const QColor& color )
385 {
386   if ( myRenderer )
387     myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
388 }
389
390 /*!Returns background of the viewport*/
391 QColor VTKViewer_ViewWindow::backgroundColor() const
392 {
393   float backint[3];
394   if ( myRenderer ) {
395     myRenderer->GetBackground( backint );
396     return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
397   }
398   return SUIT_ViewWindow::backgroundColor();
399 }
400
401 /*!Repaint window. If \a theUpdateTrihedron is true - recalculate trihedron.*/
402 void VTKViewer_ViewWindow::Repaint(bool theUpdateTrihedron)
403 {
404   if (theUpdateTrihedron) onAdjustTrihedron();
405   myRenderWindow->update();
406 }
407
408 /*!Get scale of transformation filter.*/
409 void VTKViewer_ViewWindow::GetScale( double theScale[3] ) {
410   myTransform->GetScale( theScale );
411 }
412
413 /*!Set scale of transformation filter and repaint window.*/
414 void VTKViewer_ViewWindow::SetScale( double theScale[3] ) {
415   myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
416   myRWInteractor->Render();
417   Repaint();
418 }
419
420 /*!Calculation trihedron size.*/
421 void VTKViewer_ViewWindow::onAdjustTrihedron(){   
422   if( !isTrihedronDisplayed() ) 
423     return;
424   int aVisibleNum = myTrihedron->GetVisibleActorCount(myRenderer);
425   if(aVisibleNum){
426     // calculating diagonal of visible props of the renderer
427     float bnd[6];
428     myTrihedron->VisibilityOff();
429     ::ComputeVisiblePropBounds(myRenderer,bnd);
430     myTrihedron->VisibilityOn();
431     float aLength = 0;
432     static bool CalcByDiag = false;
433     if(CalcByDiag){
434       aLength = sqrt((bnd[1]-bnd[0])*(bnd[1]-bnd[0])+
435                      (bnd[3]-bnd[2])*(bnd[3]-bnd[2])+
436                      (bnd[5]-bnd[4])*(bnd[5]-bnd[4]));
437     }else{
438       aLength = bnd[1]-bnd[0];
439       aLength = max((bnd[3]-bnd[2]),aLength);
440       aLength = max((bnd[5]-bnd[4]),aLength);
441     }
442    
443     static float aSizeInPercents = 105;
444     QString aSetting;// = SUIT_CONFIG->getSetting("Viewer:TrihedronSize");
445     if(!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat();
446
447     static float EPS_SIZE = 5.0E-3;
448     float aSize = myTrihedron->GetSize();
449     float aNewSize = aLength*aSizeInPercents/100.0;
450     // if the new trihedron size have sufficient difference, then apply the value
451     if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE){
452       myTrihedron->SetSize(aNewSize);
453     }
454   }
455   ::ResetCameraClippingRange(myRenderer);
456 }
457
458 /*!Emit key pressed.*/
459 void VTKViewer_ViewWindow::onKeyPressed(QKeyEvent* event)
460 {
461   emit keyPressed( this, event );
462 }
463
464 /*!Emit key released.*/
465 void VTKViewer_ViewWindow::onKeyReleased(QKeyEvent* event)
466 {
467   emit keyReleased( this, event );
468 }
469
470 /*!Emit key pressed.*/
471 void VTKViewer_ViewWindow::onMousePressed(QMouseEvent* event)
472 {
473   emit mousePressed(this, event);
474 }
475
476 /*!Emit mouse released.*/
477 void VTKViewer_ViewWindow::onMouseReleased(QMouseEvent* event)
478 {
479   emit mouseReleased( this, event );
480 }
481
482 /*!Emit mouse moving.*/
483 void VTKViewer_ViewWindow::onMouseMoving(QMouseEvent* event)
484 {
485   emit mouseMoving( this, event );
486 }
487
488 /*!Emit mouse double clicked.*/
489 void VTKViewer_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
490 {
491   emit mouseDoubleClicked( this, event );
492 }
493
494 /*!Insert actor to renderer and transformation filter.
495  *Move Internal actors, if \a theMoveInternalActors is true.
496  */
497 void VTKViewer_ViewWindow::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors ){
498   theActor->AddToRender(myRenderer);
499   theActor->SetTransform(myTransform);
500   if(theMoveInternalActors) 
501     myRWInteractor->MoveInternalActors();
502 }
503
504 /*!Add actor.Repaint window if \a theUpdate is true.
505  *@see InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors )
506  */
507 void VTKViewer_ViewWindow::AddActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ ){
508   InsertActor(theActor);
509   if(theUpdate) 
510     Repaint();
511 }
512
513 /*!Remove \a theActor from renderer and pepaint, if \a theUpdate is true.*/
514 void VTKViewer_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ ){
515   theActor->RemoveFromRender(myRenderer);
516   if(theUpdate) 
517     Repaint();
518 }
519
520 /*!@see RemoveActor() and InsertActor().*/
521 void VTKViewer_ViewWindow::MoveActor( VTKViewer_Actor* theActor)
522 {
523   RemoveActor(theActor);
524   InsertActor(theActor,true);
525 }
526
527 /*!On trihedron show slot.*/
528 void VTKViewer_ViewWindow::onTrihedronShow()
529 {
530   if (isTrihedronDisplayed())
531     myTrihedron->VisibilityOff();
532   else
533     myTrihedron->VisibilityOn();
534   myRenderWindow->update();
535 }
536
537 /*!Dump view.*/
538 QImage VTKViewer_ViewWindow::dumpView()
539 {
540   QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
541   return px.convertToImage();
542 }