Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.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 "SVTK_NonIsometricDlg.h"
23 #include "SVTK_UpdateRateDlg.h"
24 #include "SVTK_CubeAxesDlg.h"
25 #include "SVTK_SetRotationPointDlg.h"
26 #include "SVTK_ViewParameterDlg.h"
27
28 #include "SALOME_Actor.h"
29
30 #include <QToolBar>
31 #include <QEvent>
32 #include <QXmlStreamWriter>
33 #include <QXmlStreamReader>
34 #include <QXmlStreamAttributes>
35
36 #include <vtkTextProperty.h>
37 #include <vtkActorCollection.h>
38 #include <vtkRenderWindow.h>
39 #include <vtkRenderer.h>
40 #include <vtkCamera.h>
41 #include <vtkPointPicker.h>
42 #include <vtkCellPicker.h>
43 #include <vtkAxisActor2D.h>
44 #include <vtkGL2PSExporter.h>
45 #include <vtkInteractorStyle.h>
46
47 #include "QtxAction.h"
48
49 #include "SUIT_Session.h"
50 #include "SUIT_MessageBox.h"
51 #include "SUIT_Accel.h"
52 #include "SUIT_Tools.h"
53 #include "SUIT_ResourceMgr.h"
54 #include "SUIT_Accel.h"
55 #include "SUIT_OverrideCursor.h"
56 #include "QtxActionToolMgr.h"
57 #include "QtxMultiAction.h"
58
59 #include "VTKViewer_Utilities.h"
60 #include "VTKViewer_Trihedron.h"
61
62 #include "SVTK_View.h"
63 //#include "SVTK_MainWindow.h"
64 #include "SVTK_Selector.h"
65
66 #include "SVTK_Event.h"
67 #include "SVTK_Renderer.h"
68 #include "SVTK_ViewWindow.h"
69 #include "SVTK_ViewModelBase.h"
70 #include "SVTK_InteractorStyle.h"
71 #include "SVTK_RenderWindowInteractor.h"
72 #include "SVTK_GenericRenderWindowInteractor.h"
73 #include "SVTK_CubeAxesActor2D.h"
74 #include "SVTK_ComboAction.h"
75 #include "SVTK_KeyFreeInteractorStyle.h"
76 #include "SVTK_Selector.h"
77 #include "SVTK_Recorder.h"
78 #include "SVTK_RecorderDlg.h"
79
80 #include "SALOME_ListIteratorOfListIO.hxx"
81
82 #include "VTKViewer_Algorithm.h"
83 #include "SVTK_Functor.h"
84
85
86 namespace SVTK
87 {
88   int convertAction( const int accelAction )
89   {
90     switch ( accelAction ) {
91     case SUIT_Accel::PanLeft     : return SVTK::PanLeftEvent;
92     case SUIT_Accel::PanRight    : return SVTK::PanRightEvent;
93     case SUIT_Accel::PanUp       : return SVTK::PanUpEvent;
94     case SUIT_Accel::PanDown     : return SVTK::PanDownEvent;
95     case SUIT_Accel::ZoomIn      : return SVTK::ZoomInEvent;
96     case SUIT_Accel::ZoomOut     : return SVTK::ZoomOutEvent;
97     case SUIT_Accel::RotateLeft  : return SVTK::RotateLeftEvent;
98     case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
99     case SUIT_Accel::RotateUp    : return SVTK::RotateUpEvent;
100     case SUIT_Accel::RotateDown  : return SVTK::RotateDownEvent;  
101     }
102     return accelAction;
103   }
104 }
105
106
107
108
109
110 /*!
111   Constructor
112 */
113 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
114   SUIT_ViewWindow(theDesktop),
115   myView(NULL),
116   myDumpImage(QImage()),
117   myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New())
118 {
119   setWindowFlags( windowFlags() & ~Qt::Window );
120   // specific of vtkSmartPointer
121   myKeyFreeInteractorStyle->Delete();
122 }
123
124 /*!
125   To initialize #SVTK_ViewWindow instance
126 */
127 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
128 {
129   myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
130   
131   SVTK_Selector* aSelector = SVTK_Selector::New();
132   
133   SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
134   aDevice->SetRenderWidget(myInteractor);
135   aDevice->SetSelector(aSelector);
136   
137   SVTK_Renderer* aRenderer = SVTK_Renderer::New();
138   aRenderer->Initialize(aDevice,aSelector);
139   
140   myInteractor->Initialize(aDevice,aRenderer,aSelector);
141   
142   aDevice->Delete();
143   aRenderer->Delete();
144   aSelector->Delete();
145   
146   myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this );
147   myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), -1, this );
148   
149   createActions( SUIT_Session::session()->activeApplication()->resourceMgr() );
150   createToolBar();
151   
152   SetEventDispatcher(myInteractor->GetDevice());
153   myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
154   myInteractor->setFocusPolicy(Qt::StrongFocus);
155   myInteractor->setFocus();
156   setFocusProxy(myInteractor);
157   
158   myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
159   myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
160   myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
161   mySetRotationPointDlg = new SVTK_SetRotationPointDlg
162     ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
163   myViewParameterDlg = new SVTK_ViewParameterDlg
164     ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
165   
166   SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
167   myInteractor->PushInteractorStyle(aStyle);
168   aStyle->Delete();
169   
170   myRecorder = SVTK_Recorder::New();
171   
172   myRecorder->SetNbFPS( 17.3 );
173   myRecorder->SetQuality( 100 );
174   myRecorder->SetProgressiveMode( true );
175   myRecorder->SetUseSkippedFrames( true );
176   myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
177   
178   setCentralWidget(myInteractor);
179   
180   myView = new SVTK_View(this);
181   Initialize(myView,theModel);
182   
183   myInteractor->getRenderWindow()->Render();
184   onResetView();
185 }
186
187 /*!
188   To initialize #SVTK_ViewWindow instance
189 */
190 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
191                                  SVTK_ViewModelBase* theModel)
192 {
193   connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
194           this,SLOT(onKeyPressed(QKeyEvent*)) );
195   connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
196           this,SLOT(onKeyReleased(QKeyEvent*)));
197   connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
198           this,SLOT(onMousePressed(QMouseEvent*)));
199   connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
200           this,SLOT(onMouseReleased(QMouseEvent*)));
201   connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
202           this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
203   connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
204           this,SLOT(onMouseMoving(QMouseEvent*)));
205   connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
206           this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
207   connect(theView,SIGNAL(selectionChanged()),
208           theModel,SLOT(onSelectionChanged()));
209 }
210
211 /*!
212   Destructor
213 */
214 SVTK_ViewWindow::~SVTK_ViewWindow()
215 {}
216
217
218 /*!
219   \return corresponding view
220 */
221 SVTK_View* SVTK_ViewWindow::getView() 
222
223   return myView; 
224 }
225
226 /*!
227   \return corresponding vtk render window
228 */
229 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
230 {
231   return GetInteractor()->getRenderWindow();
232 }
233
234 /*!
235   \return corresponding vtk render window interactor
236 */
237 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
238 {
239   return myInteractor;
240 }
241
242 /*!
243   \return corresponding vtk render window interactor
244 */
245 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
246 {
247   return myInteractor->GetDevice();
248 }
249
250 /*!
251   \return corresponding vtk renderer
252 */
253 vtkRenderer* SVTK_ViewWindow::getRenderer() const
254 {
255   return GetInteractor()->getRenderer();
256 }
257
258 /*!
259   Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
260 */
261 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
262 {
263   return GetInteractor()->GetRenderer();
264 }
265
266 /*!
267   \return corresponding vtk selector
268 */
269 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
270
271   return GetInteractor()->GetSelector(); 
272 }
273
274 /*!
275   Processes transformation "front view"
276 */
277 void SVTK_ViewWindow::onFrontView()
278 {
279   GetRenderer()->OnFrontView();
280   Repaint();
281 }
282
283 /*!
284   Processes transformation "back view"
285 */
286 void SVTK_ViewWindow::onBackView()
287 {
288   GetRenderer()->OnBackView();
289   Repaint();
290 }
291
292 /*!
293   Processes transformation "top view"
294 */
295 void SVTK_ViewWindow::onTopView()
296 {
297   GetRenderer()->OnTopView();
298   Repaint();
299 }
300
301 /*!
302   Processes transformation "bottom view"
303 */
304 void SVTK_ViewWindow::onBottomView()
305 {
306   GetRenderer()->OnBottomView();
307   Repaint();
308 }
309
310 /*!
311   Processes transformation "left view"
312 */
313 void SVTK_ViewWindow::onLeftView()
314 {
315   GetRenderer()->OnLeftView();
316   Repaint();
317 }
318
319 /*!
320   Processes transformation "right view"
321 */
322 void SVTK_ViewWindow::onRightView()
323 {
324   GetRenderer()->OnRightView();
325   Repaint();
326 }
327
328 /*!
329   Processes transformation "reset view": sets default orientation of viewport camera
330 */
331 void SVTK_ViewWindow::onResetView()
332 {
333   GetRenderer()->OnResetView();
334   Repaint();
335 }
336
337 /*!
338   Processes transformation "fit all"
339 */
340 void SVTK_ViewWindow::onFitAll()
341 {
342   GetRenderer()->OnFitAll();
343   Repaint();
344 }
345
346 /*!
347   SLOT: called if selection is changed
348 */
349 void SVTK_ViewWindow::onSelectionChanged()
350 {
351   myView->onSelectionChanged();
352 }
353
354 /*!
355   Change selection mode
356   \param theMode - new selection mode
357 */
358 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
359 {
360   GetSelector()->SetSelectionMode(theMode);
361 }
362
363 /*!
364   \return selection mode
365 */
366 Selection_Mode SVTK_ViewWindow::SelectionMode() const
367 {
368   return GetSelector()->SelectionMode();
369 }
370
371 /*!
372   Unhilights all objects in viewer
373 */
374 void SVTK_ViewWindow::unHighlightAll() 
375 {
376   myView->unHighlightAll();
377 }
378
379 /*!
380   Hilights/unhilights object in viewer
381   \param theIO - object to be updated
382   \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
383   \param theIsUpdate - update current viewer
384 */
385 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO, 
386                                 bool theIsHighlight, 
387                                 bool theIsUpdate ) 
388 {
389   myView->highlight( theIO, theIsHighlight, theIsUpdate );
390 }
391
392 /*!
393   \return true if object is in viewer or in collector
394   \param theIO - object to be checked
395 */
396 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) 
397 {
398   return myView->isInViewer( theIO );
399 }
400
401 /*!
402   \return true if object is displayed in viewer
403   \param theIO - object to be checked
404 */
405 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) 
406 {
407   return myView->isVisible( theIO );
408 }
409
410 /*!
411   Display object
412   \param theEntry - entry that corresponds to intractive objects
413 */
414 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry) 
415 {
416   return myView->FindIObject(theEntry);
417 }
418
419 /*!
420   Display object
421   \param theIO - object
422   \param theImmediatly - update viewer
423 */
424 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
425                               bool theImmediatly) 
426 {
427   myView->Display(theIO,theImmediatly);
428 }
429
430 /*!
431   Erase object
432   \param theIO - object
433   \param theImmediatly - update viewer
434 */
435 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
436                             bool theImmediatly) 
437 {
438   myView->Erase(theIO,theImmediatly);
439 }
440
441 /*!
442   Display only passed object
443   \param theIO - object
444 */
445 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) 
446 {
447   myView->DisplayOnly(theIO);
448 }
449
450 /*!
451   Display all objects in view
452 */
453 void SVTK_ViewWindow::DisplayAll() 
454 {
455   myView->DisplayAll();
456 }
457
458 /*!
459   Erase all objects in view
460 */
461 void SVTK_ViewWindow::EraseAll() 
462 {
463   myView->EraseAll();
464 }
465
466 /*!
467   Sets background color
468   \param color - new background color
469 */
470 void SVTK_ViewWindow::setBackgroundColor( const QColor& theColor )
471 {
472   getRenderer()->SetBackground(theColor.red()/255.0, 
473                                theColor.green()/255.0,
474                                theColor.blue()/255.0);
475 }
476
477 /*!
478   \return background color of viewer
479 */
480 QColor SVTK_ViewWindow::backgroundColor() const
481 {
482   vtkFloatingPointType aBackgroundColor[3];
483   getRenderer()->GetBackground(aBackgroundColor);
484   return QColor(int(aBackgroundColor[0]*255), 
485                 int(aBackgroundColor[1]*255), 
486                 int(aBackgroundColor[2]*255));
487 }
488
489
490 /*!
491   Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
492 */
493 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
494 {
495   return GetInteractor()->GetInteractorStyle();
496 }
497
498 /*!
499   Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
500 */
501 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
502 {
503   GetInteractor()->PushInteractorStyle(theStyle);
504 }
505
506 /*!
507   Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
508 */
509 void SVTK_ViewWindow::PopInteractorStyle()
510 {
511   GetInteractor()->PopInteractorStyle();
512 }
513
514 /*!
515   Updates current viewer
516 */
517 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
518 {
519   if(theUpdateTrihedron) 
520     GetRenderer()->OnAdjustTrihedron();
521
522   GetInteractor()->update();
523
524   SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
525   if ( aStyle )
526     aStyle->OnTimer();
527 }
528
529 /*!
530   Redirect the request to #SVTK_Renderer::GetScale
531 */
532 void SVTK_ViewWindow::GetScale( double theScale[3] ) 
533 {
534   GetRenderer()->GetScale( theScale );
535 }
536
537 /*!
538   Redirect the request to #SVTK_Renderer::SetScale
539 */
540 void SVTK_ViewWindow::SetScale( double theScale[3] ) 
541 {
542   GetRenderer()->SetScale( theScale );
543   Repaint();
544 }
545
546 /*!
547   Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
548 */
549 bool SVTK_ViewWindow::isTrihedronDisplayed()
550 {
551   return GetRenderer()->IsTrihedronDisplayed();
552 }
553
554 /*!
555   Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
556 */
557 bool SVTK_ViewWindow::isCubeAxesDisplayed()
558 {
559   return GetRenderer()->IsCubeAxesDisplayed();
560 }
561
562 /*!
563   Redirect the request to #SVTK_Renderer::OnViewTrihedron
564 */
565 void SVTK_ViewWindow::onViewTrihedron()
566 {
567   GetRenderer()->OnViewTrihedron();
568   Repaint();
569 }
570
571 /*!
572   Redirect the request to #SVTK_Renderer::OnViewCubeAxes
573 */
574 void SVTK_ViewWindow::onViewCubeAxes()
575 {
576   GetRenderer()->OnViewCubeAxes();
577   Repaint();
578 }
579
580 /*!
581   Redirect the request to #SVTK_Renderer::GetTrihedron
582 */
583 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
584 {
585   return GetRenderer()->GetTrihedron();
586 }
587
588 /*!
589   Redirect the request to #SVTK_Renderer::GetCubeAxes
590 */
591 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
592 {
593   return GetRenderer()->GetCubeAxes();
594 }
595
596 /*!
597   \return trihedron size
598 */
599 vtkFloatingPointType SVTK_ViewWindow::GetTrihedronSize() const
600 {
601   return GetRenderer()->GetTrihedronSize();
602 }
603
604 /*!
605   Sets projection mode
606   \param theMode - projection mode ( 0 - orthogonal, 1 - perspective )
607 */
608 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
609 {
610   activateProjectionMode( theMode );
611 }
612
613
614 /*!
615   Set the gravity center as a focal point
616 */
617 void SVTK_ViewWindow::activateSetFocalPointGravity()
618 {
619   myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
620 }
621
622 /*!
623   Set the selected point as a focal point
624 */
625 void SVTK_ViewWindow::activateSetFocalPointSelected()
626 {
627   myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
628 }
629
630 /*!
631   Set the point selected by user as a focal point
632 */
633 void SVTK_ViewWindow::activateStartFocalPointSelection()
634 {
635   myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
636 }
637
638 void SVTK_ViewWindow::activateProjectionMode(int theMode)
639 {
640   if (theMode)
641     toolMgr()->action( ProjectionModeId )->setChecked( true );
642   else
643     toolMgr()->action( ParallelModeId )->setChecked( true );
644 }
645
646 /*!
647   Sets actual interaction style
648   \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
649 */
650 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
651 {
652   onSwitchInteractionStyle( theStyle==1 );
653 }
654
655 /*!
656   Switches "keyboard free" interaction style on/off
657 */
658 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
659 {
660   if (theOn) {
661     // check if style is already set
662     if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
663     {
664       // keep the same style extensions
665       SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
666       if ( aStyle ) {
667         myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
668         myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
669       }
670
671       PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
672     }
673   }
674   else {
675     // pop only key free  style
676     if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
677       PopInteractorStyle();
678   }
679
680   // update action state if method is called outside
681   QtxAction* a = getAction( SwitchInteractionStyleId );
682   if ( a->isChecked() != theOn ) a->setChecked( theOn );
683 }
684
685 /*!
686   Sets incremental speed
687   \param theValue - new incremental speed
688   \param theMode - modification mode
689 */
690 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
691 {
692   if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
693     ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
694 }
695
696 /*!
697   Sets spacemouse buttons for the functions
698   \param theBtn1 - spacemouse button for the "decrease speed increment"
699   \param theBtn2 - spacemouse button for the "increase speed increment"
700   \param theBtn3 - spacemouse button for the "dominant combined switch"
701 */
702 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1, 
703                                            const int theBtn2,
704                                            const int theBtn3)
705 {
706   int val = theBtn1;
707   myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
708   val = theBtn2;
709   myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
710   val = theBtn3;
711   myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
712 }
713
714 /*!
715   Sets trihedron size
716   \param theSize - new trihedron size
717   \param theRelative - trihedron relativeness
718 */
719 void SVTK_ViewWindow::SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative)
720 {
721   GetRenderer()->SetTrihedronSize(theSize, theRelative);
722   Repaint();
723 }
724
725 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
726  *  trihedron and cube axes, even if trihedron and cube axes is invisible.
727  */
728 void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
729 {
730   GetRenderer()->AdjustActors();
731   Repaint();
732 }
733
734 /*!
735   Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
736 */
737 void SVTK_ViewWindow::onAdjustTrihedron()
738 {   
739   GetRenderer()->OnAdjustTrihedron();
740 }
741
742 /*!
743   Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
744 */
745 void SVTK_ViewWindow::onAdjustCubeAxes()
746 {   
747   GetRenderer()->OnAdjustCubeAxes();
748 }
749
750 /*!
751   Emits key pressed
752 */
753 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
754 {
755   emit keyPressed( this, event );
756 }
757
758 /*!
759   Emits key released
760 */
761 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
762 {
763   emit keyReleased( this, event );
764 }
765
766 /*!
767   Emits mouse pressed
768 */
769 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
770 {
771   emit mousePressed(this, event);
772 }
773
774 /*!
775   Emits mouse released
776 */
777 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
778 {
779   emit mouseReleased( this, event );
780 }
781
782 /*!
783   Emits mouse moving
784 */
785 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
786 {
787   emit mouseMoving( this, event );
788 }
789
790 /*!
791   Emits mouse double clicked
792 */
793 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
794 {
795   emit mouseDoubleClicked( this, event );
796 }
797
798 /*!
799   Redirect the request to #SVTK_Renderer::AddActor
800 */
801 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, 
802                                 bool theUpdate )
803 {
804   GetRenderer()->AddActor(theActor);
805   if(theUpdate) 
806     Repaint();
807   emit actorAdded(theActor);
808 }
809
810 /*!
811   Redirect the request to #SVTK_Renderer::RemoveActor
812 */
813 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, 
814                                    bool theUpdate )
815 {
816   GetRenderer()->RemoveActor(theActor);
817   if(theUpdate) 
818     Repaint();
819   emit actorRemoved(theActor);
820 }
821
822 QImage SVTK_ViewWindow::dumpViewContent()
823 {
824   vtkRenderWindow* aWindow = getRenderWindow();
825   int* aSize = aWindow->GetSize();
826   int aWidth = aSize[0];
827   int aHeight = aSize[1];
828   
829   unsigned char *aData = 
830     aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
831   
832   QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
833
834   anImage = anImage.rgbSwapped();
835   anImage = anImage.mirrored();
836   return anImage;
837 }
838
839 /*!
840   \return QImage, containing all scene rendering in window
841 */
842 QImage SVTK_ViewWindow::dumpView()
843 {
844   if( myDumpImage.isNull() )
845     return dumpViewContent();
846   
847   return myDumpImage;
848 }
849
850 QString SVTK_ViewWindow::filter() const
851 {
852   return tr( "SVTK_IMAGE_FILES" );
853 }
854
855 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
856 {
857   if ( format != "PS" && format != "EPS" && format != "PDF" )
858     return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
859
860   SUIT_OverrideCursor wc;
861
862   vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
863   anExporter->SetRenderWindow(getRenderWindow());
864
865   if ( format == "PS" ) {
866     anExporter->SetFileFormatToPS();
867     anExporter->CompressOff();
868   }
869
870   if ( format == "EPS" ) {
871     anExporter->SetFileFormatToEPS();
872     anExporter->CompressOff();
873   }
874
875   if ( format == "PDF" ) {
876     anExporter->SetFileFormatToPDF();
877   }
878
879   QString aFilePrefix(fileName);
880   QString anExtension(SUIT_Tools::extension(fileName));
881   aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
882   anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
883   anExporter->Write();
884   anExporter->Delete();
885
886   return true;
887 }
888
889 /*!
890   \refresh QImage, containing all scene rendering in window
891 */
892 void SVTK_ViewWindow::RefreshDumpImage()
893 {
894   myDumpImage = dumpViewContent();
895 }
896
897 /*!
898   Redirect the request to #SVTK_Renderer::SetSelectionProp
899 */
900 void SVTK_ViewWindow::SetSelectionProp(const double& theRed, 
901                                        const double& theGreen, 
902                                        const double& theBlue, 
903                                        const int& theWidth) 
904 {
905   myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
906 }
907
908 /*!
909   Redirect the request to #SVTK_Renderer::SetSelectionProp
910 */
911 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed, 
912                                           const double& theGreen, 
913                                           const double& theBlue, 
914                                           const int& theWidth) 
915 {
916   myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
917 }
918
919 /*!
920   Redirect the request to #SVTK_Renderer::SetSelectionTolerance
921 */
922 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes, 
923                                             const double& theTolItems,
924                                             const double& theTolObjects)
925 {
926   myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
927 }
928
929 /*!
930   Performs action
931   \param accelAction - action
932 */
933 bool SVTK_ViewWindow::action( const int accelAction  )
934 {
935   if ( accelAction == SUIT_Accel::ZoomFit )
936     onFitAll();
937   else {
938     int anEvent = SVTK::convertAction( accelAction );
939     GetInteractor()->InvokeEvent(anEvent, 0);
940   }
941   return true;
942 }
943
944 /*!
945   \return action by it's id
946 */
947 QtxAction* SVTK_ViewWindow::getAction( int id ) const
948 {
949   return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
950 }
951
952
953 // old visual parameters had 13 values.  New format added additional 
954 // 76 values for graduated axes, so both numbers are processed.
955 const int nNormalParams = 13;   // number of view windows parameters excluding graduated axes params
956 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
957 const int nTrihedronParams = 3; // number of parameters for Trihedron
958 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
959
960 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
961  */
962 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
963 {
964   //QString params;
965   if ( !actor )
966     return ;//params;
967
968   // Name
969   bool isVisible = actor->GetTitleVisibility();
970   QString title ( actor->GetTitle() );
971   vtkFloatingPointType color[ 3 ];
972   int font = VTK_ARIAL;
973   int bold = 0;
974   int italic = 0;
975   int shadow = 0;
976
977   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
978   if ( txtProp )
979   {
980     txtProp->GetColor( color );
981     font = txtProp->GetFontFamily();
982     bold = txtProp->GetBold();
983     italic = txtProp->GetItalic();
984     shadow = txtProp->GetShadow();
985   }
986   writer.writeStartElement("GraduatedAxis");
987   writer.writeAttribute("Axis", theAxis);
988
989   writer.writeStartElement("Title");
990   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
991   writer.writeAttribute("Text", title);
992   writer.writeAttribute("Font", QString("%1").arg(font));
993   writer.writeAttribute("Bold", QString("%1").arg(bold));
994   writer.writeAttribute("Italic", QString("%1").arg(italic));
995   writer.writeAttribute("Shadow", QString("%1").arg(shadow));
996
997   writer.writeStartElement("Color");
998   writer.writeAttribute("R", QString("%1").arg(color[0]));
999   writer.writeAttribute("G", QString("%1").arg(color[1]));
1000   writer.writeAttribute("B", QString("%1").arg(color[2]));
1001   writer.writeEndElement();
1002   writer.writeEndElement();
1003
1004   //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, 
1005   //              title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1006
1007   // Labels
1008   isVisible = actor->GetLabelVisibility();
1009   int labels = actor->GetNumberOfLabels();
1010   int offset = actor->GetTickOffset();
1011   font = VTK_ARIAL;
1012   bold = false;
1013   italic = false;
1014   shadow = false;
1015
1016   txtProp = actor->GetLabelTextProperty();
1017   if ( txtProp )
1018   {
1019     txtProp->GetColor( color );
1020     font = txtProp->GetFontFamily();
1021     bold = txtProp->GetBold();
1022     italic = txtProp->GetItalic();
1023     shadow = txtProp->GetShadow();
1024   }
1025
1026   writer.writeStartElement("Labels");
1027   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1028   writer.writeAttribute("Number", QString("%1").arg(labels));
1029   writer.writeAttribute("Offset", QString("%1").arg(offset));
1030   writer.writeAttribute("Font", QString("%1").arg(font));
1031   writer.writeAttribute("Bold", QString("%1").arg(bold));
1032   writer.writeAttribute("Italic", QString("%1").arg(italic));
1033   writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1034
1035   writer.writeStartElement("Color");
1036   writer.writeAttribute("R", QString("%1").arg(color[0]));
1037   writer.writeAttribute("G", QString("%1").arg(color[1]));
1038   writer.writeAttribute("B", QString("%1").arg(color[2]));
1039   writer.writeEndElement();
1040   writer.writeEndElement();
1041   //  params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,  
1042   //                           color[0], color[1], color[2], font, bold, italic, shadow );
1043
1044   // Tick marks
1045   isVisible = actor->GetTickVisibility();
1046   int length = actor->GetTickLength();
1047   writer.writeStartElement("TickMarks");
1048   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1049   writer.writeAttribute("Length", QString("%1").arg(length));
1050   writer.writeEndElement();
1051   
1052   //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1053   
1054   writer.writeEndElement();
1055   //return params;
1056 }
1057
1058 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1059 {
1060   if ( !actor )
1061     return;
1062
1063   do {
1064     reader.readNext();
1065   } while (!reader.isStartElement());
1066
1067   // Read title params
1068   QXmlStreamAttributes aAttr = reader.attributes();
1069   bool isVisible = aAttr.value("isVisible").toString().toUShort();
1070   QString title = aAttr.value("Text").toString();
1071   int font = aAttr.value("Font").toString().toInt();
1072   int bold = aAttr.value("Bold").toString().toInt();
1073   int italic = aAttr.value("Italic").toString().toInt();
1074   int shadow = aAttr.value("Shadow").toString().toInt();
1075
1076   //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1077
1078   do {
1079     reader.readNext();
1080   } while (!reader.isStartElement());
1081   
1082   // Read title color
1083   aAttr = reader.attributes();
1084
1085   vtkFloatingPointType color[3];
1086   color[0] = aAttr.value("R").toString().toDouble();
1087   color[1] = aAttr.value("G").toString().toDouble();
1088   color[2] = aAttr.value("B").toString().toDouble();
1089   //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1090
1091   actor->SetTitleVisibility( isVisible );
1092   actor->SetTitle( title.toLatin1() );
1093   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1094   if ( txtProp ) {
1095     txtProp->SetColor( color );
1096     txtProp->SetFontFamily( font );
1097     txtProp->SetBold( bold );
1098     txtProp->SetItalic( italic );
1099     txtProp->SetShadow( shadow );
1100   }
1101
1102   // Labels
1103
1104   do {
1105     reader.readNext();
1106   } while (!reader.isStartElement()); 
1107   // Read labels
1108   aAttr = reader.attributes();
1109   isVisible = aAttr.value("isVisible").toString().toUShort();
1110   int labels = aAttr.value("Number").toString().toInt();
1111   int offset = aAttr.value("Offset").toString().toInt();
1112   font = aAttr.value("Font").toString().toInt();
1113   bold = aAttr.value("Bold").toString().toInt();
1114   italic = aAttr.value("Italic").toString().toInt();
1115   shadow = aAttr.value("Shadow").toString().toInt();
1116
1117   do {
1118     reader.readNext();
1119   } while (!reader.isStartElement()); 
1120   // Read Color
1121   aAttr = reader.attributes();
1122
1123   color[0] = aAttr.value("R").toString().toDouble();
1124   color[1] = aAttr.value("G").toString().toDouble();
1125   color[2] = aAttr.value("B").toString().toDouble();
1126
1127   actor->SetLabelVisibility( isVisible );
1128   actor->SetNumberOfLabels( labels );
1129   actor->SetTickOffset( offset );
1130   txtProp = actor->GetLabelTextProperty();
1131   if ( txtProp ) {
1132     txtProp->SetColor( color );
1133     txtProp->SetFontFamily( font );
1134     txtProp->SetBold( bold );
1135     txtProp->SetItalic( italic );
1136     txtProp->SetShadow( shadow );
1137   }
1138
1139   // Tick Marks
1140   do {
1141     reader.readNext();
1142   } while (!reader.isStartElement()); 
1143   aAttr = reader.attributes();
1144
1145   // retrieve and set tick marks properties
1146   isVisible = aAttr.value("isVisible").toString().toUShort();
1147   int length = aAttr.value("Length").toString().toInt();
1148   
1149   actor->SetTickVisibility( isVisible );
1150   actor->SetTickLength( length );
1151 }
1152
1153 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1154  */
1155 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1156 {
1157   if ( !actor )
1158     return;
1159
1160   QStringList paramsLst = params.split( '*' );
1161
1162   if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1163
1164     // retrieve and set name parameters
1165     bool isVisible = paramsLst[2].toUShort();
1166     QString title = paramsLst[3];
1167     vtkFloatingPointType color[3];
1168     color[0] = paramsLst[4].toDouble();
1169     color[1] = paramsLst[5].toDouble();
1170     color[2] = paramsLst[6].toDouble();
1171     int font = paramsLst[7].toInt();
1172     int bold = paramsLst[8].toInt();
1173     int italic = paramsLst[9].toInt();
1174     int shadow = paramsLst[10].toInt();
1175
1176     actor->SetTitleVisibility( isVisible );
1177     actor->SetTitle( title.toLatin1() );
1178     vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1179     if ( txtProp ) {
1180       txtProp->SetColor( color );
1181       txtProp->SetFontFamily( font );
1182       txtProp->SetBold( bold );
1183       txtProp->SetItalic( italic );
1184       txtProp->SetShadow( shadow );
1185     }
1186
1187     // retrieve and set lable parameters
1188     isVisible = paramsLst[12].toUShort();
1189     int labels = paramsLst[13].toInt();
1190     int offset = paramsLst[14].toInt();
1191     color[0] = paramsLst[15].toDouble();
1192     color[1] = paramsLst[16].toDouble();
1193     color[2] = paramsLst[17].toDouble();
1194     font = paramsLst[18].toInt();
1195     bold = paramsLst[19].toInt();
1196     italic = paramsLst[20].toInt();
1197     shadow = paramsLst[21].toInt();
1198
1199     actor->SetLabelVisibility( isVisible );
1200     actor->SetNumberOfLabels( labels );
1201     actor->SetTickOffset( offset );
1202     txtProp = actor->GetLabelTextProperty();
1203     if ( txtProp ) {
1204       txtProp->SetColor( color );
1205       txtProp->SetFontFamily( font );
1206       txtProp->SetBold( bold );
1207       txtProp->SetItalic( italic );
1208       txtProp->SetShadow( shadow );
1209     }
1210
1211     // retrieve and set tick marks properties
1212     isVisible = paramsLst[23].toUShort();
1213     int length = paramsLst[24].toInt();
1214
1215     actor->SetTickVisibility( isVisible );
1216     actor->SetTickLength( length );
1217   }
1218 }
1219
1220 /*! The method returns the visual parameters of this view as a formated string
1221  */
1222 QString SVTK_ViewWindow::getVisualParameters()
1223 {
1224   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1225   
1226   // save position, focal point, viewUp, scale
1227   vtkCamera* camera = getRenderer()->GetActiveCamera();
1228   camera->GetPosition( pos );
1229   camera->GetFocalPoint( focalPnt );
1230   camera->GetViewUp( viewUp );
1231   parScale = camera->GetParallelScale();
1232   GetScale( scale );
1233
1234   // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1235   // view up values (3 digits), parallel scale (1 digit), scale (3 digits, 
1236   // Graduated axes parameters (X, Y, Z axes parameters)
1237   QString retStr;
1238   QXmlStreamWriter aWriter(&retStr);
1239   aWriter.setAutoFormatting(true);
1240
1241   aWriter.writeStartDocument();
1242   aWriter.writeStartElement("ViewState");
1243
1244   aWriter.writeStartElement("Position");
1245   aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1246   aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1247   aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1248   aWriter.writeEndElement();
1249
1250   aWriter.writeStartElement("FocalPoint");
1251   aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1252   aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1253   aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1254   aWriter.writeEndElement();
1255
1256   aWriter.writeStartElement("ViewUp");
1257   aWriter.writeAttribute("X", QString::number(viewUp[0]));
1258   aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1259   aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1260   aWriter.writeEndElement();
1261
1262   aWriter.writeStartElement("ViewScale");
1263   aWriter.writeAttribute("Parallel", QString::number(parScale));
1264   aWriter.writeAttribute("X", QString::number(scale[0]));
1265   aWriter.writeAttribute("Y", QString::number(scale[1]));
1266   aWriter.writeAttribute("Z", QString::number(scale[2]));
1267   aWriter.writeEndElement();
1268
1269   if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1270     aWriter.writeStartElement("DisplayCubeAxis");
1271     aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1272     aWriter.writeEndElement();
1273
1274     getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1275     getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1276     getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1277   }
1278
1279   aWriter.writeStartElement("Trihedron");
1280   aWriter.writeAttribute("isShown",  QString( "%1" ).arg( isTrihedronDisplayed()));
1281   aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1282   aWriter.writeEndElement();
1283
1284   aWriter.writeEndElement();
1285   aWriter.writeEndDocument();
1286
1287   return retStr;
1288 }
1289
1290 /*!
1291   The method restores visual parameters of this view or postpones it untill the view is shown
1292 */ 
1293 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1294 {
1295   //printf("#### %s\n", qPrintable(parameters));
1296   SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1297   if ( anInteractor->isVisible() ) {
1298     doSetVisualParameters( parameters ); 
1299   }
1300   else {
1301     myVisualParams = parameters;
1302     anInteractor->installEventFilter(this);
1303   }
1304 }
1305
1306 /*!
1307   The method restores visual parameters of this view from a formated string
1308 */
1309 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
1310 {
1311   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1312
1313   QXmlStreamReader aReader(parameters);
1314   SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1315
1316   while(!aReader.atEnd()) {
1317     aReader.readNext();
1318     if (aReader.isStartElement()) {
1319       QXmlStreamAttributes aAttr = aReader.attributes();
1320       //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1321       if (aReader.name() == "Position") {       
1322         pos[0] = aAttr.value("X").toString().toDouble();
1323         pos[1] = aAttr.value("Y").toString().toDouble();
1324         pos[2] = aAttr.value("Z").toString().toDouble();
1325         //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1326       } else if (aReader.name() == "FocalPoint") {
1327         focalPnt[0] = aAttr.value("X").toString().toDouble();
1328         focalPnt[1] = aAttr.value("Y").toString().toDouble();
1329         focalPnt[2] = aAttr.value("Z").toString().toDouble();
1330         //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1331       } else if (aReader.name() == "ViewUp") {
1332         viewUp[0] = aAttr.value("X").toString().toDouble();
1333         viewUp[1] = aAttr.value("Y").toString().toDouble();
1334         viewUp[2] = aAttr.value("Z").toString().toDouble();
1335         //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1336       } else if (aReader.name() == "ViewScale") {
1337         parScale = aAttr.value("Parallel").toString().toDouble();
1338         scale[0] = aAttr.value("X").toString().toDouble();
1339         scale[1] = aAttr.value("Y").toString().toDouble();
1340         scale[2] = aAttr.value("Z").toString().toDouble();
1341         //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1342       } else if (aReader.name() == "DisplayCubeAxis") {
1343         if (aAttr.value("Show") == "0")
1344           gradAxesActor->VisibilityOff();
1345         else
1346           gradAxesActor->VisibilityOn();
1347       } else if (aReader.name() == "GraduatedAxis") {
1348         if(aAttr.value("Axis") == "X") 
1349           setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1350         else if(aAttr.value("Axis") == "Y")
1351           setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1352         else if(aAttr.value("Axis") == "Z")
1353           setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1354       } else if (aReader.name() == "Trihedron") {
1355         if (aAttr.value("isShown") == "0")
1356           GetTrihedron()->VisibilityOff();
1357         else
1358           GetTrihedron()->VisibilityOn();
1359         SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1360       }
1361     } 
1362   }
1363   if (!aReader.hasError()) {
1364     vtkCamera* camera = getRenderer()->GetActiveCamera();
1365     camera->SetPosition( pos );
1366     camera->SetFocalPoint( focalPnt );
1367     camera->SetViewUp( viewUp );
1368     camera->SetParallelScale( parScale );
1369     SetScale( scale );
1370   } else {
1371     QStringList paramsLst = parameters.split( '*' );
1372     if ( paramsLst.size() >= nNormalParams ) {
1373       // 'reading' list of parameters
1374       pos[0] = paramsLst[0].toDouble();
1375       pos[1] = paramsLst[1].toDouble();
1376       pos[2] = paramsLst[2].toDouble();
1377       focalPnt[0] = paramsLst[3].toDouble();
1378       focalPnt[1] = paramsLst[4].toDouble();
1379       focalPnt[2] = paramsLst[5].toDouble();
1380       viewUp[0] = paramsLst[6].toDouble();
1381       viewUp[1] = paramsLst[7].toDouble();
1382       viewUp[2] = paramsLst[8].toDouble();
1383       parScale = paramsLst[9].toDouble();
1384       scale[0] = paramsLst[10].toDouble();
1385       scale[1] = paramsLst[11].toDouble();
1386       scale[2] = paramsLst[12].toDouble();
1387       
1388       // applying parameters
1389       vtkCamera* camera = getRenderer()->GetActiveCamera();
1390       camera->SetPosition( pos );
1391       camera->SetFocalPoint( focalPnt );
1392       camera->SetViewUp( viewUp );
1393       camera->SetParallelScale( parScale );
1394       SetScale( scale );
1395       
1396       // apply graduated axes parameters
1397       SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1398       if ( gradAxesActor && paramsLst.size() == nAllParams ) {
1399         int i = nNormalParams+1, j = i + nGradAxisParams - 1;
1400         ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
1401         i = j + 1; j += nGradAxisParams;
1402         ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); 
1403         i = j + 1; j += nGradAxisParams;
1404         ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); 
1405         
1406         if ( paramsLst[13].toUShort() )
1407           gradAxesActor->VisibilityOn();
1408         else
1409           gradAxesActor->VisibilityOff();
1410       } else if ( paramsLst.size() == nAllParams ) {
1411         if ( paramsLst[90].toUShort() )
1412           GetTrihedron()->VisibilityOn();
1413         else
1414           GetTrihedron()->VisibilityOff();
1415         
1416         SetTrihedronSize(paramsLst[91].toDouble());
1417       }
1418     }
1419   }
1420 }
1421
1422
1423 /*!
1424   Delayed setVisualParameters
1425 */
1426 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
1427 {
1428   if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
1429     SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
1430     if ( anInteractor->isVisible() ) {
1431       doSetVisualParameters( myVisualParams );
1432       anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
1433     }
1434   }
1435   return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
1436 }
1437
1438
1439 /*!
1440   Change rotation point
1441 */
1442 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
1443 {
1444   if(theIsActivate){
1445     mySetRotationPointDlg->addObserver();
1446     if ( mySetRotationPointDlg->IsFirstShown() )
1447       activateSetRotationGravity();
1448     mySetRotationPointDlg->show();
1449   }else
1450     mySetRotationPointDlg->hide();
1451 }
1452
1453 /*!
1454   Set the gravity center as a rotation point
1455 */
1456 void SVTK_ViewWindow::activateSetRotationGravity()
1457 {
1458   myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
1459 }
1460
1461 /*!
1462   Set the selected point as a rotation point
1463 */
1464 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
1465 {
1466   myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
1467 }
1468
1469 /*!
1470   Set the point selected by user as a rotation point
1471 */
1472 void SVTK_ViewWindow::activateStartPointSelection()
1473 {
1474   myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
1475 }
1476
1477 /*!
1478   Set the view projection mode: orthogonal or perspective
1479 */
1480 void SVTK_ViewWindow::onPerspectiveMode()
1481 {
1482   vtkCamera* aCamera = getRenderer()->GetActiveCamera();
1483   aCamera->SetParallelProjection(toolMgr()->action( ParallelModeId )->isChecked());
1484   GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
1485 }
1486
1487 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
1488 {
1489   myEventDispatcher = theDispatcher;
1490 }
1491
1492 /*!
1493   Creates all actions of svtk main window
1494 */
1495 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
1496 {
1497   QtxAction* anAction;
1498   QtxActionToolMgr* mgr = toolMgr();
1499
1500   // Dump view
1501   anAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
1502                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
1503                            tr( "MNU_DUMP_VIEW" ), 0, this);
1504   anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
1505   connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
1506   mgr->registerAction( anAction, DumpId );
1507
1508   // FitAll
1509   anAction = new QtxAction(tr("MNU_FITALL"), 
1510                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
1511                            tr( "MNU_FITALL" ), 0, this);
1512   anAction->setStatusTip(tr("DSC_FITALL"));
1513   connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
1514   mgr->registerAction( anAction, FitAllId );
1515
1516   // FitRect
1517   anAction = new QtxAction(tr("MNU_FITRECT"), 
1518                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
1519                            tr( "MNU_FITRECT" ), 0, this);
1520   anAction->setStatusTip(tr("DSC_FITRECT"));
1521   connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
1522   mgr->registerAction( anAction, FitRectId );
1523
1524   // Zoom
1525   anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
1526                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
1527                            tr( "MNU_ZOOM_VIEW" ), 0, this);
1528   anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
1529   connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
1530   mgr->registerAction( anAction, ZoomId );
1531
1532   // Panning
1533   anAction = new QtxAction(tr("MNU_PAN_VIEW"), 
1534                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
1535                            tr( "MNU_PAN_VIEW" ), 0, this);
1536   anAction->setStatusTip(tr("DSC_PAN_VIEW"));
1537   connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
1538   mgr->registerAction( anAction, PanId );
1539
1540   // Global Panning
1541   anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), 
1542                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
1543                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
1544   anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
1545   connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
1546   mgr->registerAction( anAction, GlobalPanId );
1547
1548   // Change rotation point
1549   anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), 
1550                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
1551                            tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
1552   anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
1553   anAction->setCheckable(true);
1554   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
1555   mgr->registerAction( anAction, ChangeRotationPointId );
1556
1557   // Rotation
1558   anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), 
1559                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
1560                            tr( "MNU_ROTATE_VIEW" ), 0, this);
1561   anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
1562   connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
1563   mgr->registerAction( anAction, RotationId );
1564
1565   // Projections
1566   anAction = new QtxAction(tr("MNU_FRONT_VIEW"), 
1567                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
1568                            tr( "MNU_FRONT_VIEW" ), 0, this);
1569   anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
1570   connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
1571   mgr->registerAction( anAction, FrontId );
1572
1573   anAction = new QtxAction(tr("MNU_BACK_VIEW"), 
1574                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
1575                            tr( "MNU_BACK_VIEW" ), 0, this);
1576   anAction->setStatusTip(tr("DSC_BACK_VIEW"));
1577   connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
1578   mgr->registerAction( anAction, BackId );
1579
1580   anAction = new QtxAction(tr("MNU_TOP_VIEW"), 
1581                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
1582                            tr( "MNU_TOP_VIEW" ), 0, this);
1583   anAction->setStatusTip(tr("DSC_TOP_VIEW"));
1584   connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
1585   mgr->registerAction( anAction, TopId );
1586
1587   anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), 
1588                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
1589                            tr( "MNU_BOTTOM_VIEW" ), 0, this);
1590   anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
1591   connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
1592   mgr->registerAction( anAction, BottomId );
1593
1594   anAction = new QtxAction(tr("MNU_LEFT_VIEW"), 
1595                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
1596                            tr( "MNU_LEFT_VIEW" ), 0, this);
1597   anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
1598   connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
1599   mgr->registerAction( anAction, LeftId );
1600
1601   anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), 
1602                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
1603                            tr( "MNU_RIGHT_VIEW" ), 0, this);
1604   anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
1605   connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
1606   mgr->registerAction( anAction, RightId );
1607
1608   // Reset
1609   anAction = new QtxAction(tr("MNU_RESET_VIEW"), 
1610                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
1611                            tr( "MNU_RESET_VIEW" ), 0, this);
1612   anAction->setStatusTip(tr("DSC_RESET_VIEW"));
1613   connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
1614   mgr->registerAction( anAction, ResetId );
1615
1616   // onViewTrihedron: Shows - Hides Trihedron
1617   anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
1618                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
1619                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
1620   anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
1621   connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
1622   mgr->registerAction( anAction, ViewTrihedronId );
1623
1624   // onNonIsometric: Manage non-isometric params
1625   anAction = new QtxAction(tr("MNU_SVTK_SCALING"), 
1626                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
1627                            tr( "MNU_SVTK_SCALING" ), 0, this);
1628   anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
1629   anAction->setCheckable(true);
1630   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
1631   mgr->registerAction( anAction, NonIsometric );
1632
1633   // onGraduatedAxes: Manage graduated axes params
1634   anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"), 
1635                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
1636                            tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
1637   anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
1638   anAction->setCheckable(true);
1639   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
1640   mgr->registerAction( anAction, GraduatedAxes );
1641
1642   // onGraduatedAxes: Manage graduated axes params
1643   anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"), 
1644                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
1645                            tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
1646   anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
1647   anAction->setCheckable(true);
1648   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
1649   mgr->registerAction( anAction, UpdateRate );
1650
1651   // Set perspective mode group
1652   anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"), 
1653                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
1654                            tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
1655   anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
1656   anAction->setCheckable(true);
1657   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
1658   mgr->registerAction( anAction, ParallelModeId );
1659
1660   anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"), 
1661                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
1662                            tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
1663   anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
1664   anAction->setCheckable(true);
1665   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
1666   mgr->registerAction( anAction, ProjectionModeId );
1667
1668   QActionGroup* aPerspectiveGroup = new QActionGroup( this );
1669   aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
1670   aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
1671
1672   // View Parameters
1673   anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), 
1674                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
1675                            tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
1676   anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
1677   anAction->setCheckable(true);
1678   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
1679   mgr->registerAction( anAction, ViewParametersId );
1680
1681   // Switch between interaction styles
1682   anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"), 
1683                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
1684                            tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
1685   anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
1686   anAction->setCheckable(true);
1687   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
1688   mgr->registerAction( anAction, SwitchInteractionStyleId );
1689
1690   // Start recording
1691   myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), 
1692                                 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
1693                                 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
1694   myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
1695   connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
1696   mgr->registerAction( myStartAction, StartRecordingId );
1697
1698   // Play recording
1699   myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"), 
1700                                theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
1701                                tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
1702   myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
1703   myPlayAction->setEnabled( false );
1704   connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
1705   mgr->registerAction( myPlayAction, PlayRecordingId );
1706
1707   // Pause recording
1708   myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"), 
1709                                 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
1710                                 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
1711   myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
1712   myPauseAction->setEnabled( false );
1713   connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
1714   mgr->registerAction( myPauseAction, PauseRecordingId );
1715
1716   // Stop recording
1717   myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"), 
1718                                theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
1719                                tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
1720   myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
1721   myStopAction->setEnabled( false );
1722   connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
1723   mgr->registerAction( myStopAction, StopRecordingId );
1724 }
1725
1726 /*!
1727   Creates toolbar of svtk main window
1728 */
1729 void SVTK_ViewWindow::createToolBar()
1730 {
1731   QtxActionToolMgr* mgr = toolMgr();
1732   
1733   mgr->append( DumpId, myToolBar );
1734   mgr->append( SwitchInteractionStyleId, myToolBar );
1735   mgr->append( ViewTrihedronId, myToolBar );
1736
1737   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
1738   aScaleAction->insertAction( getAction( FitAllId ) );
1739   aScaleAction->insertAction( getAction( FitRectId ) );
1740   aScaleAction->insertAction( getAction( ZoomId ) );
1741   mgr->append( aScaleAction, myToolBar );
1742
1743   QtxMultiAction* aPanningAction = new QtxMultiAction( this );
1744   aPanningAction->insertAction( getAction( PanId ) );
1745   aPanningAction->insertAction( getAction( GlobalPanId ) );
1746   mgr->append( aPanningAction, myToolBar );
1747
1748   mgr->append( ChangeRotationPointId, myToolBar );
1749
1750   mgr->append( RotationId, myToolBar );
1751
1752   QtxMultiAction* aViewsAction = new QtxMultiAction( this );
1753   aViewsAction->insertAction( getAction( FrontId ) );
1754   aViewsAction->insertAction( getAction( BackId ) );
1755   aViewsAction->insertAction( getAction( TopId ) );
1756   aViewsAction->insertAction( getAction( BottomId ) );
1757   aViewsAction->insertAction( getAction( LeftId ) );
1758   aViewsAction->insertAction( getAction( RightId ) );
1759   mgr->append( aViewsAction, myToolBar );
1760
1761   mgr->append( ResetId, myToolBar );
1762
1763   mgr->append( UpdateRate, myToolBar );
1764   mgr->append( NonIsometric, myToolBar );
1765   mgr->append( GraduatedAxes, myToolBar );
1766
1767   mgr->append( ViewParametersId, myToolBar );
1768   mgr->append( toolMgr()->separator(), myToolBar );
1769   mgr->append( ParallelModeId, myToolBar );
1770   mgr->append( ProjectionModeId, myToolBar );
1771
1772   mgr->append( StartRecordingId, myRecordingToolBar );
1773   mgr->append( PlayRecordingId, myRecordingToolBar );
1774   mgr->append( PauseRecordingId, myRecordingToolBar );
1775   mgr->append( StopRecordingId, myRecordingToolBar );
1776 }
1777
1778 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
1779 {
1780   if(theIsActivate){
1781     myUpdateRateDlg->Update();
1782     myUpdateRateDlg->show();
1783   }else
1784     myUpdateRateDlg->hide();
1785 }
1786
1787 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
1788 {
1789   if(theIsActivate){
1790     myNonIsometricDlg->Update();
1791     myNonIsometricDlg->show();
1792   }else
1793     myNonIsometricDlg->hide();
1794 }
1795
1796 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
1797 {
1798   if(theIsActivate){
1799     myCubeAxesDlg->Update();
1800     myCubeAxesDlg->show();
1801   }else
1802     myCubeAxesDlg->hide();
1803 }
1804
1805 /*!
1806   Starts rotation transformation
1807 */
1808 void SVTK_ViewWindow::activateRotation()
1809 {
1810   myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
1811 }
1812
1813
1814 /*!
1815   Starts panning transformation
1816 */
1817 void SVTK_ViewWindow::activatePanning()
1818 {
1819   myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
1820 }
1821
1822 /*!
1823   Starts zoom transformation
1824 */
1825 void SVTK_ViewWindow::activateZoom()
1826 {
1827   myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
1828 }
1829
1830 /*!
1831   Starts window fit transformation
1832 */
1833 void SVTK_ViewWindow::activateWindowFit()
1834 {
1835   myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
1836 }
1837
1838 /*!
1839   Starts global panning transformation
1840 */
1841 void SVTK_ViewWindow::activateGlobalPanning()
1842 {
1843   myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
1844 }
1845
1846 void SVTK_ViewWindow::onStartRecording()
1847 {
1848   myRecorder->CheckExistAVIMaker();
1849   if (myRecorder->ErrorStatus()) {
1850     SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
1851   }
1852   else {
1853     SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
1854
1855     if( !aRecorderDlg->exec() )
1856       return;
1857
1858     myStartAction->setEnabled( false );
1859     myPlayAction->setEnabled( false );
1860     myPauseAction->setEnabled( true );
1861     myStopAction->setEnabled( true );
1862
1863     // to prevent resizing the window while recording
1864     myPreRecordingMinSize = minimumSize();
1865     myPreRecordingMaxSize = maximumSize();
1866     setFixedSize( size() );
1867
1868     myRecorder->Record();
1869   }
1870 }
1871
1872 void SVTK_ViewWindow::onPlayRecording()
1873 {
1874   myStartAction->setEnabled( false );
1875   myPlayAction->setEnabled( false );
1876   myPauseAction->setEnabled( true );
1877   myStopAction->setEnabled( true );
1878
1879   myRecorder->Pause();
1880 }
1881
1882 void SVTK_ViewWindow::onPauseRecording()
1883 {
1884   myStartAction->setEnabled( false );
1885   myPlayAction->setEnabled( true );
1886   myPauseAction->setEnabled( false );
1887   myStopAction->setEnabled( true );
1888
1889   myRecorder->Pause();
1890 }
1891
1892 void SVTK_ViewWindow::onStopRecording()
1893 {
1894   myStartAction->setEnabled( true );
1895   myPlayAction->setEnabled( false );
1896   myPauseAction->setEnabled( false );
1897   myStopAction->setEnabled( false );
1898
1899   myRecorder->Stop();
1900
1901   setMinimumSize( myPreRecordingMinSize );
1902   setMaximumSize( myPreRecordingMaxSize );
1903 }
1904
1905 /*!
1906   To invoke a VTK event on SVTK_RenderWindowInteractor instance
1907 */
1908 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
1909 {
1910   GetInteractor()->InvokeEvent(theEvent,theCallData);
1911 }
1912
1913 /*!
1914   Modify view parameters
1915 */
1916 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
1917 {
1918   if(theIsActivate){
1919     myViewParameterDlg->addObserver();
1920     myViewParameterDlg->show();
1921   }else
1922     myViewParameterDlg->hide();
1923 }
1924
1925 /*!
1926   Custom show event handler
1927 */
1928 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent ) 
1929 {
1930   emit Show( theEvent );
1931 }
1932
1933 /*!
1934   Custom hide event handler
1935 */
1936 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent ) 
1937 {
1938   emit Hide( theEvent );
1939 }
1940