Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / SVTK / SVTK_MainWindow.cxx
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : SALOME
27 //  $Header$
28
29 #include "SALOME_Actor.h"
30
31 #include <vtkGenericRenderWindowInteractor.h>
32 #include <vtkRenderer.h>
33
34 #include "QtxAction.h"
35
36 #include "SUIT_ToolButton.h"
37 #include "SUIT_MessageBox.h"
38 #include "SUIT_ViewWindow.h"
39
40 #include "SUIT_Tools.h"
41 #include "SUIT_ResourceMgr.h"
42 #include "SVTK_NonIsometricDlg.h"
43 #include "SVTK_UpdateRateDlg.h"
44 #include "SVTK_CubeAxesDlg.h"
45 #include "SVTK_SetRotationPointDlg.h"
46
47 #include "SVTK_MainWindow.h"
48 #include "SVTK_Event.h"
49 #include "SVTK_Renderer.h"
50 #include "SVTK_RenderWindowInteractor.h"
51 #include "SVTK_InteractorStyle.h"
52
53 #include "SVTK_Selector.h"
54
55 #include <qimage.h>
56
57 /*!
58   Constructor
59 */
60 SVTK_MainWindow
61 ::SVTK_MainWindow(QWidget* theParent, 
62                   const char* theName,
63                   SUIT_ResourceMgr* theResourceMgr,
64                   SUIT_ViewWindow* theViewWindow) :
65   QMainWindow(theParent,theName,0),
66   myViewWindow(theViewWindow)
67 {
68   myToolBar = new QToolBar(this);
69   myToolBar->setCloseMode(QDockWindow::Undocked);
70   myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
71
72   createActions(theResourceMgr);
73   createToolBar();
74 }
75
76 /*!
77   To initialize the class
78 */
79 void
80 SVTK_MainWindow
81 ::Initialize(SVTK_RenderWindowInteractor* theInteractor)
82 {
83   myInteractor = theInteractor;
84   SetEventDispatcher(myInteractor->GetDevice());
85
86   setCentralWidget(myInteractor);
87   myInteractor->setBackgroundMode(Qt::NoBackground);
88
89   myInteractor->setFocusPolicy(StrongFocus);
90   myInteractor->setFocus();
91   setFocusProxy(myInteractor);
92
93   myUpdateRateDlg = new SVTK_UpdateRateDlg(myActionsMap[UpdateRate],this,"SVTK_UpdateRateDlg");
94   myNonIsometricDlg = new SVTK_NonIsometricDlg(myActionsMap[NonIsometric],this,"SVTK_NonIsometricDlg");
95   myCubeAxesDlg = new SVTK_CubeAxesDlg(myActionsMap[GraduatedAxes],this,"SVTK_CubeAxesDlg");
96   mySetRotationPointDlg = new SVTK_SetRotationPointDlg(myActionsMap[ChangeRotationPointId],this,"SVTK_SetRotationPointDlg");
97 }
98
99 /*!
100   Destructor
101 */
102 SVTK_MainWindow
103 ::~SVTK_MainWindow()
104 {
105 }
106
107 /*!
108   \return used SVTK_RenderWindowInteractor
109 */
110 SVTK_RenderWindowInteractor*
111 SVTK_MainWindow
112 ::GetInteractor()
113 {
114   return myInteractor;
115 }
116
117 /*!
118   \return used #vtkRenderWindowInteractor (obsolete)
119 */
120 vtkRenderWindowInteractor*
121 SVTK_MainWindow
122 ::getInteractor()
123 {
124   return GetInteractor()->GetDevice();
125 }
126
127 /*!
128   \return used vtkRenderWindow (obsolete)
129 */
130 vtkRenderWindow*
131 SVTK_MainWindow
132 ::getRenderWindow()
133 {
134   return GetInteractor()->getRenderWindow();
135 }
136
137 /*!
138   To repaint the view
139   \param theUpdateTrihedron - adjust trihedron
140 */
141 void
142 SVTK_MainWindow
143 ::Repaint(bool theUpdateTrihedron)
144 {
145   if(theUpdateTrihedron) 
146     GetRenderer()->OnAdjustTrihedron();
147
148   GetInteractor()->update();
149
150   if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
151     ((SVTK_InteractorStyle*)GetInteractorStyle())->OnTimer();
152 }
153
154 /*!
155   To invoke a VTK event on SVTK_RenderWindowInteractor instance
156 */
157 void
158 SVTK_MainWindow
159 ::InvokeEvent(unsigned long theEvent, void* theCallData)
160 {
161   GetInteractor()->InvokeEvent(theEvent,theCallData);
162 }
163
164 /*!
165   Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
166 */
167 vtkInteractorStyle*
168 SVTK_MainWindow
169 ::GetInteractorStyle()
170 {
171   return GetInteractor()->GetInteractorStyle();
172 }
173
174 /*!
175   Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
176 */
177 void
178 SVTK_MainWindow
179 ::PushInteractorStyle(vtkInteractorStyle* theStyle)
180 {
181   GetInteractor()->PushInteractorStyle(theStyle);
182 }
183
184 /*!
185   Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
186 */
187 void
188 SVTK_MainWindow
189 ::PopInteractorStyle()
190 {
191   GetInteractor()->PopInteractorStyle();
192 }
193
194 /*!
195   Redirect the request to SVTK_RenderWindowInteractor::GetSelector
196 */
197 SVTK_Selector*
198 SVTK_MainWindow
199 ::GetSelector()
200 {
201   return GetInteractor()->GetSelector();
202 }
203
204 /*!
205   Redirect the request to SVTK_RenderWindowInteractor::SelectionMode
206 */
207 Selection_Mode
208 SVTK_MainWindow
209 ::SelectionMode()
210 {
211   return GetSelector()->SelectionMode();
212 }
213
214 /*!
215   Redirect the request to SVTK_RenderWindowInteractor::SetSelectionMode
216 */
217 void
218 SVTK_MainWindow
219 ::SetSelectionMode(Selection_Mode theMode)
220 {
221   GetSelector()->SetSelectionMode(theMode);
222 }
223
224 /*!
225   Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
226 */
227 SVTK_Renderer* 
228 SVTK_MainWindow
229 ::GetRenderer()
230 {
231   return GetInteractor()->GetRenderer();
232 }
233
234 /*!
235   Redirect the request to SVTK_RenderWindowInteractor::getRenderer
236 */
237 vtkRenderer* 
238 SVTK_MainWindow
239 ::getRenderer()
240 {
241   return GetInteractor()->getRenderer();
242 }
243
244 /*!
245   Sets background color of the view
246   \param theColor - new background color
247 */
248 void
249 SVTK_MainWindow
250 ::SetBackgroundColor(const QColor& theColor)
251 {
252   getRenderer()->SetBackground(theColor.red()/255.0, 
253                                theColor.green()/255.0,
254                                theColor.blue()/255.0);
255 }
256
257 /*!
258   \return background color of the view
259 */
260 QColor
261 SVTK_MainWindow
262 ::BackgroundColor()
263 {
264   vtkFloatingPointType aBackgroundColor[3];
265   getRenderer()->GetBackground(aBackgroundColor);
266   return QColor(int(aBackgroundColor[0]*255), 
267                 int(aBackgroundColor[1]*255), 
268                 int(aBackgroundColor[2]*255));
269 }
270
271 /*!
272   Redirect the request to SVTK_Renderer::GetScale
273 */
274 void
275 SVTK_MainWindow
276 ::GetScale( double theScale[3] ) 
277 {
278   GetRenderer()->GetScale( theScale );
279 }
280
281 /*!
282   Redirect the request to SVTK_Renderer::SetScale
283 */
284 void
285 SVTK_MainWindow
286 ::SetScale( double theScale[3] ) 
287 {
288   GetRenderer()->SetScale( theScale );
289   Repaint();
290 }
291
292 /*!
293   Redirect the request to SVTK_Renderer::AddActor
294 */
295 void
296 SVTK_MainWindow
297 ::AddActor(VTKViewer_Actor* theActor, 
298            bool theIsUpdate)
299 {
300   GetRenderer()->AddActor(theActor);
301   if(theIsUpdate) 
302     Repaint();
303 }
304
305 /*!
306   Redirect the request to SVTK_Renderer::RemoveActor
307 */
308 void
309 SVTK_MainWindow
310 ::RemoveActor(VTKViewer_Actor* theActor, 
311               bool theIsUpdate)
312 {
313   GetRenderer()->RemoveActor(theActor);
314   if(theIsUpdate) 
315     Repaint();
316 }
317
318 /*!
319   Redirect the request to SVTK_Renderer::GetTrihedronSize
320 */
321 vtkFloatingPointType
322 SVTK_MainWindow
323 ::GetTrihedronSize()
324 {
325   return GetRenderer()->GetTrihedronSize();
326 }
327
328 /*!
329   Redirect the request to SVTK_Renderer::SetTrihedronSize
330 */
331 void 
332 SVTK_MainWindow
333 ::SetTrihedronSize( const vtkFloatingPointType theSize, const bool theRelative )
334 {
335   GetRenderer()->SetTrihedronSize(theSize, theRelative);
336   Repaint();
337 }
338
339
340 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
341  *  trihedron and cube axes, even if trihedron and cube axes is invisible.
342  */
343 void
344 SVTK_MainWindow
345 ::AdjustActors()
346 {
347   GetRenderer()->AdjustActors();
348   Repaint();
349 }
350
351 /*!
352   Redirect the request to SVTK_Renderer::IsTrihedronDisplayed
353 */
354 bool
355 SVTK_MainWindow
356 ::IsTrihedronDisplayed()
357 {
358   return GetRenderer()->IsTrihedronDisplayed();
359 }
360
361 /*!
362   Redirect the request to SVTK_Renderer::IsCubeAxesDisplayed
363 */
364 bool
365 SVTK_MainWindow
366 ::IsCubeAxesDisplayed()
367 {
368   return GetRenderer()->IsCubeAxesDisplayed();
369 }
370
371 /*!
372   Redirect the request to SVTK_Renderer::GetTrihedron
373 */
374 VTKViewer_Trihedron*  
375 SVTK_MainWindow
376 ::GetTrihedron() 
377
378   return GetRenderer()->GetTrihedron(); 
379 }
380
381 /*!
382   Redirect the request to SVTK_Renderer::GetCubeAxes
383 */
384 SVTK_CubeAxesActor2D* 
385 SVTK_MainWindow
386 ::GetCubeAxes() 
387
388   return GetRenderer()->GetCubeAxes(); 
389 }
390
391 /*!
392   \return toolbar of svtk main window
393 */
394 QToolBar* 
395 SVTK_MainWindow
396 ::getToolBar()
397 {
398   return myToolBar;
399 }
400
401 void
402 SVTK_MainWindow
403 ::SetEventDispatcher(vtkObject* theDispatcher)
404 {
405   myEventDispatcher = theDispatcher;
406 }
407
408 #if defined(WIN32) && !defined(_DEBUG)
409 #pragma optimize( "", off )
410 #endif
411
412 /*!
413   Creates all actions of svtk main window
414 */
415 void
416 SVTK_MainWindow
417 ::createActions(SUIT_ResourceMgr* theResourceMgr)
418 {
419   if(!myActionsMap.isEmpty()) 
420     return;
421   
422   QtxAction* anAction;
423
424   // Dump view
425   anAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
426                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
427                            tr( "MNU_DUMP_VIEW" ), 0, this);
428   anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
429   connect(anAction, SIGNAL(activated()), myViewWindow, SLOT(onDumpView()));
430   myActionsMap[ DumpId ] = anAction;
431
432   // FitAll
433   anAction = new QtxAction(tr("MNU_FITALL"), 
434                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
435                            tr( "MNU_FITALL" ), 0, this);
436   anAction->setStatusTip(tr("DSC_FITALL"));
437   connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
438   myActionsMap[ FitAllId ] = anAction;
439
440   // FitRect
441   anAction = new QtxAction(tr("MNU_FITRECT"), 
442                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
443                            tr( "MNU_FITRECT" ), 0, this);
444   anAction->setStatusTip(tr("DSC_FITRECT"));
445   connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
446   myActionsMap[ FitRectId ] = anAction;
447
448   // Zoom
449   anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
450                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
451                            tr( "MNU_ZOOM_VIEW" ), 0, this);
452   anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
453   connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
454   myActionsMap[ ZoomId ] = anAction;
455
456   // Panning
457   anAction = new QtxAction(tr("MNU_PAN_VIEW"), 
458                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
459                            tr( "MNU_PAN_VIEW" ), 0, this);
460   anAction->setStatusTip(tr("DSC_PAN_VIEW"));
461   connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
462   myActionsMap[ PanId ] = anAction;
463
464   // Global Panning
465   anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), 
466                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
467                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
468   anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
469   connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
470   myActionsMap[ GlobalPanId ] = anAction;
471
472   // Change rotation point
473   anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), 
474                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATION_POINT" ) ),
475                            tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
476   anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
477   anAction->setToggleAction(true);
478   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
479   myActionsMap[ ChangeRotationPointId ] = anAction;
480
481   // Rotation
482   anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), 
483                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
484                            tr( "MNU_ROTATE_VIEW" ), 0, this);
485   anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
486   connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
487   myActionsMap[ RotationId ] = anAction;
488
489   // Projections
490   anAction = new QtxAction(tr("MNU_FRONT_VIEW"), 
491                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
492                            tr( "MNU_FRONT_VIEW" ), 0, this);
493   anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
494   connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
495   myActionsMap[ FrontId ] = anAction;
496
497   anAction = new QtxAction(tr("MNU_BACK_VIEW"), 
498                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
499                            tr( "MNU_BACK_VIEW" ), 0, this);
500   anAction->setStatusTip(tr("DSC_BACK_VIEW"));
501   connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
502   myActionsMap[ BackId ] = anAction;
503
504   anAction = new QtxAction(tr("MNU_TOP_VIEW"), 
505                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
506                            tr( "MNU_TOP_VIEW" ), 0, this);
507   anAction->setStatusTip(tr("DSC_TOP_VIEW"));
508   connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
509   myActionsMap[ TopId ] = anAction;
510
511   anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), 
512                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
513                            tr( "MNU_BOTTOM_VIEW" ), 0, this);
514   anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
515   connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
516   myActionsMap[ BottomId ] = anAction;
517
518   anAction = new QtxAction(tr("MNU_LEFT_VIEW"), 
519                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
520                            tr( "MNU_LEFT_VIEW" ), 0, this);
521   anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
522   connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
523   myActionsMap[ LeftId ] = anAction;
524
525   anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), 
526                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
527                            tr( "MNU_RIGHT_VIEW" ), 0, this);
528   anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
529   connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
530   myActionsMap[ RightId ] = anAction;
531
532   // Reset
533   anAction = new QtxAction(tr("MNU_RESET_VIEW"), 
534                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
535                            tr( "MNU_RESET_VIEW" ), 0, this);
536   anAction->setStatusTip(tr("DSC_RESET_VIEW"));
537   connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
538   myActionsMap[ ResetId ] = anAction;
539
540   // onViewTrihedron: Shows - Hides Trihedron
541   anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
542                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
543                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
544   anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
545   connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
546   myActionsMap[ ViewTrihedronId ] = anAction;
547
548   // onNonIsometric: Manage non-isometric params
549   anAction = new QtxAction(tr("MNU_SVTK_SCALING"), 
550                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
551                            tr( "MNU_SVTK_SCALING" ), 0, this);
552   anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
553   anAction->setToggleAction(true);
554   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
555   myActionsMap[ NonIsometric ] = anAction;
556
557   // onGraduatedAxes: Manage graduated axes params
558   anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"), 
559                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_GRADUATED_AXES" ) ),
560                            tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
561   anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
562   anAction->setToggleAction(true);
563   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
564   myActionsMap[ GraduatedAxes ] = anAction;
565
566   // onGraduatedAxes: Manage graduated axes params
567   anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"), 
568                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_UPDATE_RATE" ) ),
569                            tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
570   anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
571   anAction->setToggleAction(true);
572   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
573   myActionsMap[ UpdateRate ] = anAction;
574 }
575
576 #if defined(WIN32) && !defined(_DEBUG)
577 #pragma optimize( "", on )
578 #endif
579
580 /*!
581   Creates toolbar of svtk main window
582 */
583 void
584 SVTK_MainWindow
585 ::createToolBar()
586 {
587   myActionsMap[DumpId]->addTo(myToolBar);
588   myActionsMap[ViewTrihedronId]->addTo(myToolBar);
589
590   SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
591   aScaleBtn->AddAction(myActionsMap[FitAllId]);
592   aScaleBtn->AddAction(myActionsMap[FitRectId]);
593   aScaleBtn->AddAction(myActionsMap[ZoomId]);
594
595   SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
596   aPanningBtn->AddAction(myActionsMap[PanId]);
597   aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
598
599   myActionsMap[ChangeRotationPointId]->addTo(myToolBar);
600
601   myActionsMap[RotationId]->addTo(myToolBar);
602
603   SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
604   aViewsBtn->AddAction(myActionsMap[FrontId]);
605   aViewsBtn->AddAction(myActionsMap[BackId]);
606   aViewsBtn->AddAction(myActionsMap[TopId]);
607   aViewsBtn->AddAction(myActionsMap[BottomId]);
608   aViewsBtn->AddAction(myActionsMap[LeftId]);
609   aViewsBtn->AddAction(myActionsMap[RightId]);
610
611   myActionsMap[ResetId]->addTo(myToolBar);
612
613   myActionsMap[UpdateRate]->addTo(myToolBar);
614   myActionsMap[NonIsometric]->addTo(myToolBar);
615   myActionsMap[GraduatedAxes]->addTo(myToolBar);
616 }
617
618 /*!
619   Custom show event handler
620 */
621 void
622 SVTK_MainWindow
623 ::showEvent( QShowEvent * theEvent ) 
624 {
625   emit Show( theEvent );
626 }
627
628 /*!
629   Custom hide event handler
630 */
631 void
632 SVTK_MainWindow
633 ::hideEvent( QHideEvent * theEvent ) 
634 {
635   emit Hide( theEvent );
636 }
637
638 /*!
639   Starts zoom transformation
640 */
641 void
642 SVTK_MainWindow
643 ::activateZoom()
644 {
645   myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
646 }
647
648 /*!
649   Starts panning transformation
650 */
651 void
652 SVTK_MainWindow
653 ::activatePanning()
654 {
655   myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
656 }
657
658 /*!
659   Starts rotation transformation
660 */
661 void
662 SVTK_MainWindow
663 ::activateRotation()
664 {
665   myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
666 }
667
668 /*!
669   Change rotation point
670 */
671 void
672 SVTK_MainWindow
673 ::onChangeRotationPoint(bool theIsActivate)
674 {
675   if(theIsActivate){
676     mySetRotationPointDlg->addObserver();
677     if ( mySetRotationPointDlg->IsFirstShown() )
678       activateSetRotationGravity();
679     mySetRotationPointDlg->show();
680   }else
681     mySetRotationPointDlg->hide();
682 }
683
684 /*!
685   Set the gravity center as a rotation point
686 */
687 void
688 SVTK_MainWindow
689 ::activateSetRotationGravity()
690 {
691   myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
692 }
693
694 /*!
695   Set the selected point as a rotation point
696 */
697 void
698 SVTK_MainWindow
699 ::activateSetRotationSelected(void* theData)
700 {
701   myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
702 }
703
704 /*!
705   Set the point selected by user as a rotation point
706 */
707 void
708 SVTK_MainWindow
709 ::activateStartPointSelection()
710 {
711   myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
712 }
713
714 /*!
715   Starts global panning transformation
716 */
717 void
718 SVTK_MainWindow
719 ::activateGlobalPanning()
720 {
721   myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
722 }
723
724 /*!
725   Starts window fit transformation
726 */
727 void
728 SVTK_MainWindow
729 ::activateWindowFit()
730 {
731   myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
732 }
733
734 /*!
735   Processes transformation "front view"
736 */
737 void
738 SVTK_MainWindow
739 ::onFrontView()
740 {
741   GetRenderer()->OnFrontView();
742   Repaint();
743 }
744
745 /*!
746   Processes transformation "back view"
747 */
748 void
749 SVTK_MainWindow
750 ::onBackView()
751 {
752   GetRenderer()->OnBackView();
753   Repaint();
754 }
755
756 /*!
757   Processes transformation "top view"
758 */
759 void
760 SVTK_MainWindow
761 ::onTopView()
762 {
763   GetRenderer()->OnTopView();
764   Repaint();
765 }
766
767 /*!
768   Processes transformation "bottom view"
769 */
770 void
771 SVTK_MainWindow
772 ::onBottomView()
773 {
774   GetRenderer()->OnBottomView();
775   Repaint();
776 }
777
778 /*!
779   Processes transformation "left view"
780 */
781 void
782 SVTK_MainWindow
783 ::onLeftView()
784 {
785   GetRenderer()->OnLeftView();
786   Repaint();
787 }
788
789 /*!
790   Processes transformation "right view"
791 */
792 void
793 SVTK_MainWindow
794 ::onRightView()
795 {
796   GetRenderer()->OnRightView();
797   Repaint();
798 }
799
800 /*!
801   Processes transformation "reset view": sets default orientation of viewport camera
802 */
803 void
804 SVTK_MainWindow
805 ::onResetView()
806 {
807   GetRenderer()->OnResetView();
808   Repaint();
809 }
810
811 /*!
812   Processes transformation "fit all"
813 */
814 void
815 SVTK_MainWindow
816 ::onFitAll()
817 {
818   GetRenderer()->OnFitAll();
819   Repaint();
820 }
821
822 /*!
823   Shows trihedron
824 */
825 void 
826 SVTK_MainWindow
827 ::onViewTrihedron()
828 {
829   GetRenderer()->OnViewTrihedron();
830   Repaint();
831 }
832
833 /*!
834   Shows cube axes
835 */
836 void
837 SVTK_MainWindow
838 ::onViewCubeAxes()
839 {
840   GetRenderer()->OnViewCubeAxes();
841   Repaint();
842 }
843
844 void
845 SVTK_MainWindow
846 ::onUpdateRate(bool theIsActivate)
847 {
848   if(theIsActivate){
849     myUpdateRateDlg->Update();
850     myUpdateRateDlg->show();
851   }else
852     myUpdateRateDlg->hide();
853 }
854
855 void
856 SVTK_MainWindow
857 ::onNonIsometric(bool theIsActivate)
858 {
859   if(theIsActivate){
860     myNonIsometricDlg->Update();
861     myNonIsometricDlg->show();
862   }else
863     myNonIsometricDlg->hide();
864 }
865
866 void
867 SVTK_MainWindow
868 ::onGraduatedAxes(bool theIsActivate)
869 {
870   if(theIsActivate){
871     myCubeAxesDlg->Update();
872     myCubeAxesDlg->show();
873   }else
874     myCubeAxesDlg->hide();
875 }
876
877 void
878 SVTK_MainWindow
879 ::onAdjustTrihedron()
880 {   
881   GetRenderer()->OnAdjustTrihedron();
882 }
883
884 void
885 SVTK_MainWindow
886 ::onAdjustCubeAxes()
887 {   
888   GetRenderer()->OnAdjustCubeAxes();
889 }
890
891 /*!
892   \return QImage, containing all scene rendering in window
893 */
894 QImage
895 SVTK_MainWindow
896 ::dumpView()
897 {
898   QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
899   return px.convertToImage();
900 }