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