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