Salome HOME
0022378: EDF 2273 GEOM: Select a point/edge/face/solid in the "Set Rotation Point...
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.cxx
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 #include "SVTK_NonIsometricDlg.h"
24 #include "SVTK_UpdateRateDlg.h"
25 #include "SVTK_CubeAxesDlg.h"
26 #include "SVTK_SetRotationPointDlg.h"
27 #include "SVTK_ViewParameterDlg.h"
28 #include "SVTK_ViewModel.h"
29 #include "VTKViewer_Texture.h"
30 #include "VTKViewer_OpenGLRenderer.h"
31
32 #include "SALOME_Actor.h"
33
34 #include <QMenu>
35 #include <QToolBar>
36 #include <QEvent>
37 #include <QFileInfo>
38 #include <QSignalMapper>
39 #include <QXmlStreamWriter>
40 #include <QXmlStreamReader>
41 #include <QXmlStreamAttributes>
42
43 #include <vtkTextProperty.h>
44 #include <vtkActorCollection.h>
45 #include <vtkRenderWindow.h>
46 #include <vtkRenderer.h>
47 #include <vtkCamera.h>
48 #include <vtkPointPicker.h>
49 #include <vtkCellPicker.h>
50 #include <vtkAxisActor2D.h>
51 #include <vtkGL2PSExporter.h>
52 #include <vtkInteractorStyle.h>
53 #include <vtkProperty.h>
54 #include <vtkCallbackCommand.h>
55 #include <vtkJPEGReader.h>
56 #include <vtkBMPReader.h>
57 #include <vtkTIFFReader.h>
58 #include <vtkPNGReader.h>
59 #include <vtkMetaImageReader.h>
60 #include <vtkImageMapToColors.h>
61 #include <vtkTexture.h>
62
63 #include "QtxAction.h"
64
65 #include "SUIT_Session.h"
66 #include "SUIT_MessageBox.h"
67 #include "SUIT_Accel.h"
68 #include "SUIT_Tools.h"
69 #include "SUIT_ResourceMgr.h"
70 #include "SUIT_Accel.h"
71 #include "SUIT_OverrideCursor.h"
72 #include "SUIT_ViewManager.h"
73 #include "QtxActionToolMgr.h"
74 #include "QtxMultiAction.h"
75 #include "QtxActionGroup.h"
76
77 #include "VTKViewer_Utilities.h"
78 #include "VTKViewer_Trihedron.h"
79
80 #include "SVTK_View.h"
81 #include "SVTK_Selector.h"
82
83 #include "SVTK_Event.h"
84 #include "SVTK_Renderer.h"
85 #include "SVTK_ViewWindow.h"
86 #include "SVTK_InteractorStyle.h"
87 #include "SVTK_RenderWindowInteractor.h"
88 #include "SVTK_GenericRenderWindowInteractor.h"
89 #include "SVTK_CubeAxesActor2D.h"
90 #include "SVTK_ComboAction.h"
91 #include "SVTK_KeyFreeInteractorStyle.h"
92 #include "SVTK_Selector.h"
93 #include "SVTK_Recorder.h"
94 #include "SVTK_RecorderDlg.h"
95
96 #include "vtkPVAxesWidget.h"
97 #include "vtkPVAxesActor.h"
98
99 #include "SALOME_ListIteratorOfListIO.hxx"
100
101 #include "VTKViewer_Algorithm.h"
102 #include "SVTK_Functor.h"
103
104 #include <OpenGLUtils_FrameBuffer.h>
105
106
107 namespace SVTK
108 {
109   int convertAction( const int accelAction )
110   {
111     switch ( accelAction ) {
112     case SUIT_Accel::PanLeft     : return SVTK::PanLeftEvent;
113     case SUIT_Accel::PanRight    : return SVTK::PanRightEvent;
114     case SUIT_Accel::PanUp       : return SVTK::PanUpEvent;
115     case SUIT_Accel::PanDown     : return SVTK::PanDownEvent;
116     case SUIT_Accel::ZoomIn      : return SVTK::ZoomInEvent;
117     case SUIT_Accel::ZoomOut     : return SVTK::ZoomOutEvent;
118     case SUIT_Accel::RotateLeft  : return SVTK::RotateLeftEvent;
119     case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
120     case SUIT_Accel::RotateUp    : return SVTK::RotateUpEvent;
121     case SUIT_Accel::RotateDown  : return SVTK::RotateDownEvent;  
122     }
123     return accelAction;
124   }
125 }
126
127
128
129
130
131 /*!
132   Constructor
133 */
134 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
135   SUIT_ViewWindow(theDesktop),
136   myView(NULL),
137   myDumpImage(QImage()),
138   myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
139   myEventCallbackCommand(vtkCallbackCommand::New())
140 {
141   setWindowFlags( windowFlags() & ~Qt::Window );
142   // specific of vtkSmartPointer
143   myKeyFreeInteractorStyle->Delete();
144 }
145
146 /*!
147   To initialize #SVTK_ViewWindow instance
148 */
149 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
150 {
151   myModel = theModel;
152   myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
153   
154   SVTK_Selector* aSelector = SVTK_Selector::New();
155   int aPreselectionMode =  SUIT_Session::session()->resourceMgr()->
156     integerValue( "VTKViewer", "preselection", Standard_Preselection );
157   aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection );
158   aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled );
159   bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
160     booleanValue( "VTKViewer", "enable_selection", true );
161   aSelector->SetSelectionEnabled( isSelectionEnabled );
162     
163   SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
164   aDevice->SetRenderWidget(myInteractor);
165   aDevice->SetSelector(aSelector);
166   
167   SVTK_Renderer* aRenderer = SVTK_Renderer::New();
168   aRenderer->Initialize(aDevice,aSelector);
169   
170   myInteractor->Initialize(aDevice,aRenderer,aSelector);
171   
172   aDevice->Delete();
173   aRenderer->Delete();
174   aSelector->Delete();
175   
176   myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false, Qt::AllToolBarAreas, -1, this );
177   myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), false, Qt::AllToolBarAreas, -1, this );
178   
179   createActions( SUIT_Session::session()->resourceMgr() );
180   createToolBar();
181   
182   SetEventDispatcher(myInteractor->GetDevice());
183   myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
184   myInteractor->setFocusPolicy(Qt::StrongFocus);
185   myInteractor->setFocus();
186   setFocusProxy(myInteractor);
187   
188   myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
189   myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
190   myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
191   myCubeAxesDlg->initialize();
192   mySetRotationPointDlg = new SVTK_SetRotationPointDlg
193     ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
194   myViewParameterDlg = new SVTK_ViewParameterDlg
195     ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
196   
197   myDefaultInteractorStyle = SVTK_InteractorStyle::New();
198   myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
199   myDefaultInteractorStyle->Delete();
200   
201   myRecorder = SVTK_Recorder::New();
202   
203   myRecorder->SetNbFPS( 17.3 );
204   myRecorder->SetQuality( 100 );
205   myRecorder->SetProgressiveMode( true );
206   myRecorder->SetUseSkippedFrames( true );
207   myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
208   
209   setCentralWidget(myInteractor);
210   
211   myAxesWidget = vtkPVAxesWidget::New();
212   myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
213   myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
214   myAxesWidget->SetInteractor(myInteractor->GetDevice());
215   myAxesWidget->SetEnabled(1);
216   myAxesWidget->SetInteractive(0);
217
218   vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
219   anAxesActor->GetXAxisTipProperty()->SetColor(   1.0, 0.0, 0.0 );
220   anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
221   anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
222   anAxesActor->GetYAxisTipProperty()->SetColor(   0.0, 1.0, 0.0 );
223   anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
224   anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
225   anAxesActor->GetZAxisTipProperty()->SetColor(   0.0, 0.0, 1.0 );
226   anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
227   anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
228
229   myView = new SVTK_View(this);
230   Initialize(myView,theModel);
231
232
233   myEventCallbackCommand->SetClientData(this);
234   myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
235   myEventCallbackCommand->Delete();
236
237   GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished, 
238                                                      myEventCallbackCommand.GetPointer(), 0.0);
239   myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished, 
240                                         myEventCallbackCommand.GetPointer(), 0.0);
241
242
243   
244   myInteractor->getRenderWindow()->Render();
245   setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
246   onResetView();
247 }
248
249 /*!
250   To initialize #SVTK_ViewWindow instance
251 */
252 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
253                                  SVTK_ViewModelBase* theModel)
254 {
255   connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
256           this,SLOT(onKeyPressed(QKeyEvent*)) );
257   connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
258           this,SLOT(onKeyReleased(QKeyEvent*)));
259   connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
260           this,SLOT(onMousePressed(QMouseEvent*)));
261   connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
262           this,SLOT(onMouseReleased(QMouseEvent*)));
263   connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
264           this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
265   connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
266           this,SLOT(onMouseMoving(QMouseEvent*)));
267   connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
268           this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
269   connect(theView,SIGNAL(selectionChanged()),
270           theModel,SLOT(onSelectionChanged()));
271
272   connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
273 }
274
275 /*!
276   Destructor
277 */
278 SVTK_ViewWindow::~SVTK_ViewWindow()
279 {
280   myRecorder->Delete();
281   myAxesWidget->Delete();
282 }
283
284
285 /*!
286   \return corresponding view
287 */
288 SVTK_View* SVTK_ViewWindow::getView() 
289
290   return myView; 
291 }
292
293 /*!
294   \return corresponding vtk render window
295 */
296 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
297 {
298   return GetInteractor()->getRenderWindow();
299 }
300
301 /*!
302   \return corresponding vtk render window interactor
303 */
304 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
305 {
306   return myInteractor;
307 }
308
309 /*!
310   \return corresponding vtk render window interactor
311 */
312 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
313 {
314   return myInteractor->GetDevice();
315 }
316
317 /*!
318   \return corresponding vtk renderer
319 */
320 vtkRenderer* SVTK_ViewWindow::getRenderer() const
321 {
322   return GetInteractor()->getRenderer();
323 }
324
325 /*!
326   Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
327 */
328 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
329 {
330   return GetInteractor()->GetRenderer();
331 }
332
333 /*!
334   \return corresponding vtk selector
335 */
336 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
337
338   return GetInteractor()->GetSelector(); 
339 }
340
341 /*!
342   Processes transformation "front view"
343 */
344 void SVTK_ViewWindow::onFrontView()
345 {
346   GetRenderer()->OnFrontView();
347   Repaint();
348   emit transformed( this );
349 }
350
351 /*!
352   Processes transformation "back view"
353 */
354 void SVTK_ViewWindow::onBackView()
355 {
356   GetRenderer()->OnBackView();
357   Repaint();
358   emit transformed( this );
359 }
360
361 /*!
362   Processes transformation "top view"
363 */
364 void SVTK_ViewWindow::onTopView()
365 {
366   GetRenderer()->OnTopView();
367   Repaint();
368   emit transformed( this );
369 }
370
371 /*!
372   Processes transformation "bottom view"
373 */
374 void SVTK_ViewWindow::onBottomView()
375 {
376   GetRenderer()->OnBottomView();
377   Repaint();
378   emit transformed( this );
379 }
380
381 /*!
382   Processes transformation "left view"
383 */
384 void SVTK_ViewWindow::onLeftView()
385 {
386   GetRenderer()->OnLeftView();
387   Repaint();
388   emit transformed( this );
389 }
390
391 /*!
392   Processes transformation "right view"
393 */
394 void SVTK_ViewWindow::onRightView()
395 {
396   GetRenderer()->OnRightView();
397   Repaint();
398   emit transformed( this );
399 }
400
401 /*!
402   \brief Rotate view 90 degrees clockwise
403 */
404 void SVTK_ViewWindow::onClockWiseView()
405 {
406   GetRenderer()->onClockWiseView();
407   Repaint();
408   emit transformed( this );
409 }
410
411 /*!
412   \brief Rotate view 90 degrees conterclockwise
413 */
414 void SVTK_ViewWindow::onAntiClockWiseView()
415 {
416   GetRenderer()->onAntiClockWiseView();
417   Repaint();
418   emit transformed( this );
419 }
420
421 /*!
422   Processes transformation "reset view": sets default orientation of viewport camera
423 */
424 void SVTK_ViewWindow::onResetView()
425 {
426   GetRenderer()->OnResetView();
427   Repaint();
428   emit transformed( this );
429 }
430
431 /*!
432   Processes transformation "fit all"
433 */
434 void SVTK_ViewWindow::onFitAll()
435 {
436   GetRenderer()->OnFitAll();
437   Repaint();
438   emit transformed( this );
439 }
440
441 /*!
442   SLOT: called if selection is changed
443 */
444 void SVTK_ViewWindow::onSelectionChanged()
445 {
446   myView->onSelectionChanged();
447 }
448
449 /*!
450   Change selection mode
451   \param theMode - new selection mode
452 */
453 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
454 {
455   GetSelector()->SetSelectionMode(theMode);
456 }
457
458 /*!
459   \return selection mode
460 */
461 Selection_Mode SVTK_ViewWindow::SelectionMode() const
462 {
463   return GetSelector()->SelectionMode();
464 }
465
466 /*!
467   Unhilights all objects in viewer
468 */
469 void SVTK_ViewWindow::unHighlightAll() 
470 {
471   myView->unHighlightAll();
472 }
473
474 /*!
475   Hilights/unhilights object in viewer
476   \param theIO - object to be updated
477   \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
478   \param theIsUpdate - update current viewer
479 */
480 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO, 
481                                 bool theIsHighlight, 
482                                 bool theIsUpdate ) 
483 {
484   myView->highlight( theIO, theIsHighlight, theIsUpdate );
485 }
486
487 /*!
488   \return true if object is in viewer or in collector
489   \param theIO - object to be checked
490 */
491 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) 
492 {
493   return myView->isInViewer( theIO );
494 }
495
496 /*!
497   \return true if object is displayed in viewer
498   \param theIO - object to be checked
499 */
500 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) 
501 {
502   return myView->isVisible( theIO );
503 }
504
505 /*!
506   Display object
507   \param theEntry - entry that corresponds to intractive objects
508 */
509 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry) 
510 {
511   return myView->FindIObject(theEntry);
512 }
513
514 /*!
515   Display object
516   \param theIO - object
517   \param theImmediatly - update viewer
518 */
519 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
520                               bool theImmediatly) 
521 {
522   myView->Display(theIO,theImmediatly);
523 }
524
525 /*!
526   Erase object
527   \param theIO - object
528   \param theImmediatly - update viewer
529 */
530 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
531                             bool theImmediatly) 
532 {
533   myView->Erase(theIO,theImmediatly);
534 }
535
536 /*!
537   Display only passed object
538   \param theIO - object
539 */
540 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) 
541 {
542   myView->DisplayOnly(theIO);
543 }
544
545 /*!
546   Display all objects in view
547 */
548 void SVTK_ViewWindow::DisplayAll() 
549 {
550   myView->DisplayAll();
551 }
552
553 /*!
554   Erase all objects in view
555 */
556 void SVTK_ViewWindow::EraseAll() 
557 {
558   myView->EraseAll();
559 }
560
561 /*!
562   Sets background color [obsolete]
563   \param color - new background color
564 */
565 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
566 {
567   Qtx::BackgroundData bg = background();
568   bg.setColor( c );
569   setBackground( bg );
570 }
571
572 /*!
573   \return background color of viewer [obsolete]
574 */
575 QColor SVTK_ViewWindow::backgroundColor() const
576 {
577   return background().color();
578 }
579
580 /*!
581   Sets background data
582   \param bgData - new background data
583 */
584 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
585 {
586   bool ok = false;
587
588   if ( bgData.isValid() ) {
589     switch ( bgData.mode() ) {
590     case Qtx::ColorBackground:
591       {
592         QColor c = bgData.color();
593         if ( c.isValid() ) {
594           // show solid-colored background
595           getRenderer()->SetTexturedBackground( false );  // cancel texture mode
596           getRenderer()->SetGradientBackground( false );  // cancel gradient mode
597           getRenderer()->SetBackground( c.red()/255.0,
598                                         c.green()/255.0,
599                                         c.blue()/255.0 ); // set background color
600           ok = true;
601         }
602         break;
603       }
604     case Qtx::SimpleGradientBackground:
605       {
606         QColor c1, c2;
607         int type = bgData.gradient( c1, c2 );
608         if ( c1.isValid() )
609         {
610           if ( !c2.isValid() )
611             c2 = c1;
612
613           // show two-color gradient background
614           getRenderer()->SetTexturedBackground( false );    // cancel texture mode
615           getRenderer()->SetGradientBackground( true );     // switch to gradient mode
616
617           VTKViewer_OpenGLRenderer* aRenderer =
618             VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
619           if( aRenderer )
620           {
621             aRenderer->SetGradientType( type );
622             aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
623             aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
624             ok = true;
625           }
626         }
627         break;
628       }
629     case Qtx::CustomGradientBackground:
630       {
631         // NOT IMPLEMENTED YET
632         getRenderer()->SetTexturedBackground( false );  // cancel texture mode
633         getRenderer()->SetGradientBackground( false );  // cancel gradient mode
634         // .........
635         break;
636       }
637     default:
638       break;
639     }
640     if ( bgData.isTextureShown() ) {
641       QString fileName;
642       int textureMode = bgData.texture( fileName );
643       QFileInfo fi( fileName );
644       if ( !fileName.isEmpty() && fi.exists() ) {
645         // read texture from file
646         QString extension = fi.suffix().toLower();
647         vtkImageReader2* aReader = 0;
648         if ( extension == "jpg" || extension == "jpeg" )
649           aReader = vtkJPEGReader::New();
650         else if ( extension == "bmp" )
651           aReader = vtkBMPReader::New();
652         else if ( extension == "tif" || extension == "tiff" )
653           aReader = vtkTIFFReader::New();
654         else if ( extension == "png" )
655           aReader = vtkPNGReader::New();
656         else if ( extension == "mhd" || extension == "mha" )
657           aReader = vtkMetaImageReader::New();           
658         if ( aReader ) {
659           // create texture
660           aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
661           aReader->Update();      
662           VTKViewer_Texture* aTexture = VTKViewer_Texture::New();           
663           vtkImageMapToColors* aMap = 0;
664           vtkAlgorithmOutput* anOutput;
665           /*
666           // special processing for BMP reader
667           vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
668           if ( aBMPReader ) {
669           // Special processing for BMP file
670           aBMPReader->SetAllow8BitBMP(1);
671             
672           aMap = vtkImageMapToColors::New();
673           aMap->SetInputConnection( aBMPReader->GetOutputPort() );
674           aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
675           aMap->SetOutputFormatToRGB();
676             
677           anOutput = aMap->GetOutputPort();
678           }
679           else {
680           }
681           */
682           anOutput = aReader->GetOutputPort( 0 );
683           aTexture->SetInputConnection( anOutput );
684           // set texture mode
685           // VSR: Currently, VTK only supports Stretch mode, so below code will give
686           // the same results for all modes
687           switch ( textureMode ) {
688           case Qtx::TileTexture:
689             aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
690             break;
691           case Qtx::StretchTexture:
692             aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
693             break;
694           case Qtx::CenterTexture:
695             aTexture->SetPosition((int)VTKViewer_Texture::Centered);
696           default:
697             break;
698           }
699           // show textured background
700           getRenderer()->SetTexturedBackground( true );
701           getRenderer()->SetBackgroundTexture( aTexture );
702           
703           // clean-up resources
704           if ( aMap )
705             aMap->Delete();
706           aReader->Delete();
707           aTexture->Delete();
708           ok = true;
709         }
710       }
711     }
712   }
713   if ( ok )
714     myBackground = bgData;
715 }
716
717 /*!
718   \return background data of viewer
719 */
720 Qtx::BackgroundData SVTK_ViewWindow::background() const
721 {
722   return myBackground;
723 }
724
725
726 /*!
727   Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
728 */
729 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
730 {
731   return GetInteractor()->GetInteractorStyle();
732 }
733
734 /*!
735   Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
736 */
737 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
738 {
739   GetInteractor()->PushInteractorStyle(theStyle);
740 }
741
742 /*!
743   Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
744 */
745 void SVTK_ViewWindow::PopInteractorStyle()
746 {
747   GetInteractor()->PopInteractorStyle();
748 }
749
750 /*!
751   Updates current viewer
752 */
753 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
754 {
755   if(theUpdateTrihedron) 
756     GetRenderer()->OnAdjustTrihedron();
757
758   GetInteractor()->update();
759
760   SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
761   if ( aStyle )
762     aStyle->OnTimer();
763 }
764
765 /*!
766   Redirect the request to #SVTK_Renderer::GetScale
767 */
768 void SVTK_ViewWindow::GetScale( double theScale[3] ) 
769 {
770   GetRenderer()->GetScale( theScale );
771 }
772
773 /*!
774   Redirect the request to #SVTK_Renderer::SetScale
775 */
776 void SVTK_ViewWindow::SetScale( double theScale[3] ) 
777 {
778   GetRenderer()->SetScale( theScale );
779   Repaint();
780   emit transformed( this );
781 }
782
783 /*!
784   Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
785 */
786 bool SVTK_ViewWindow::isTrihedronDisplayed()
787 {
788   return GetRenderer()->IsTrihedronDisplayed();
789 }
790
791 /*!
792   Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
793 */
794 bool SVTK_ViewWindow::isCubeAxesDisplayed()
795 {
796   return GetRenderer()->IsCubeAxesDisplayed();
797 }
798
799 /*!
800   Redirect the request to #SVTK_Renderer::OnViewTrihedron
801 */
802 void SVTK_ViewWindow::onViewTrihedron()
803 {
804   GetRenderer()->OnViewTrihedron();
805   Repaint();
806 }
807
808 /*!
809   Redirect the request to #SVTK_Renderer::OnViewCubeAxes
810 */
811 void SVTK_ViewWindow::onViewCubeAxes()
812 {
813   GetRenderer()->OnViewCubeAxes();
814   Repaint();
815 }
816
817 /*!
818   Redirect the request to #SVTK_Renderer::GetTrihedron
819 */
820 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
821 {
822   return GetRenderer()->GetTrihedron();
823 }
824
825 /*!
826   Redirect the request to #SVTK_Renderer::GetCubeAxes
827 */
828 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
829 {
830   return GetRenderer()->GetCubeAxes();
831 }
832
833 /*!
834   \return trihedron size
835 */
836 double SVTK_ViewWindow::GetTrihedronSize() const
837 {
838   return GetRenderer()->GetTrihedronSize();
839 }
840
841 /*!
842   Sets projection mode
843   \param theMode - projection mode ( 0 - orthogonal, 1 - perspective )
844 */
845 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
846 {
847   activateProjectionMode( theMode );
848 }
849
850
851 /*!
852   Set the gravity center as a focal point
853 */
854 void SVTK_ViewWindow::activateSetFocalPointGravity()
855 {
856   myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
857 }
858
859 /*!
860   Set the selected point as a focal point
861 */
862 void SVTK_ViewWindow::activateSetFocalPointSelected()
863 {
864   myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
865 }
866
867 /*!
868   Set the point selected by user as a focal point
869 */
870 void SVTK_ViewWindow::activateStartFocalPointSelection()
871 {
872   myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
873 }
874
875 void SVTK_ViewWindow::activateProjectionMode(int theMode)
876 {
877   if (theMode)
878     toolMgr()->action( ProjectionModeId )->setChecked( true );
879   else
880     toolMgr()->action( ParallelModeId )->setChecked( true );
881 }
882
883 /*!
884   Sets actual interaction style
885   \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
886 */
887 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
888 {
889   onSwitchInteractionStyle( theStyle==1 );
890 }
891
892 /*!
893   Sets actual zooming style
894   \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) )
895 */
896 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
897 {
898   onSwitchZoomingStyle( theStyle==1 );
899 }
900
901 /*!
902   Set preselection mode.
903   \param theMode the mode to set (standard, dynamic or disabled)
904 */
905 void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
906 {
907   onSwitchPreSelectionMode( theMode );
908 }
909
910 /*!
911   Enables/disables selection.
912   \param theEnable if true - selection will be enabled
913 */
914 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
915 {
916   GetSelector()->SetSelectionEnabled( theEnable );
917   QtxAction* a = getAction( EnableSelectionId );
918   if ( a->isChecked() !=  theEnable)
919     a->setChecked( theEnable );
920   QtxActionGroup* aPreselectionGroup = 
921     dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
922   if ( aPreselectionGroup )
923     aPreselectionGroup->setEnabled( theEnable );
924 }
925
926 /*!
927   Switches "keyboard free" interaction style on/off
928 */
929 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
930 {
931   if (theOn) {
932     // check if style is already set
933     if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
934     {
935       // keep the same style extensions
936       SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
937       if ( aStyle ) {
938         myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
939         myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
940       }
941
942       PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
943     }
944   }
945   else {
946     // pop only key free  style
947     if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
948       PopInteractorStyle();
949   }
950
951   // update action state if method is called outside
952   QtxAction* a = getAction( SwitchInteractionStyleId );
953   if ( a->isChecked() != theOn ) a->setChecked( theOn );
954 }
955
956 /*!
957   Toogles advanced zooming style (relatively to the cursor position) on/off
958 */
959 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
960 {
961   if( myDefaultInteractorStyle.GetPointer() )
962     myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
963   if( myKeyFreeInteractorStyle.GetPointer() )
964     myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
965
966   // update action state if method is called outside
967   QtxAction* a = getAction( SwitchZoomingStyleId );
968   if ( a->isChecked() != theOn )
969     a->setChecked( theOn );
970 }
971
972 /*!
973   Switch preselection mode.
974   \param theMode the preselection mode
975 */
976 void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
977 {
978   GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection );
979   GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled );
980
981   // update action state if method is called outside
982   QtxAction* a = getAction( StandardPreselectionId + theMode );
983   if ( a && !a->isChecked() )
984     a->setChecked( true );
985 }
986
987 /*!
988   Enables/disables selection.
989   \param theOn if true - selection will be enabled
990 */
991 void SVTK_ViewWindow::onEnableSelection( bool on )
992 {
993   SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
994   if(aViewer)
995     aViewer->enableSelection(on);  
996 }
997
998 /*!
999   Sets incremental speed
1000   \param theValue - new incremental speed
1001   \param theMode - modification mode
1002 */
1003 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
1004 {
1005   if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
1006     ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
1007 }
1008
1009 /*!
1010   Sets spacemouse buttons for the functions
1011   \param theBtn1 - spacemouse button for the "decrease speed increment"
1012   \param theBtn2 - spacemouse button for the "increase speed increment"
1013   \param theBtn3 - spacemouse button for the "dominant combined switch"
1014 */
1015 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1, 
1016                                            const int theBtn2,
1017                                            const int theBtn3)
1018 {
1019   int val = theBtn1;
1020   myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
1021   val = theBtn2;
1022   myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
1023   val = theBtn3;
1024   myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
1025 }
1026
1027 /*!
1028   Sets trihedron size
1029   \param theSize - new trihedron size
1030   \param theRelative - trihedron relativeness
1031 */
1032 void SVTK_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative)
1033 {
1034   GetRenderer()->SetTrihedronSize(theSize, theRelative);
1035   Repaint();
1036 }
1037
1038 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
1039  *  trihedron and cube axes, even if trihedron and cube axes is invisible.
1040  */
1041 void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
1042 {
1043   GetRenderer()->AdjustActors();
1044   Repaint();
1045 }
1046
1047 /*!
1048   Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
1049 */
1050 void SVTK_ViewWindow::onAdjustTrihedron()
1051 {   
1052   GetRenderer()->OnAdjustTrihedron();
1053 }
1054
1055 /*!
1056   Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
1057 */
1058 void SVTK_ViewWindow::onAdjustCubeAxes()
1059 {   
1060   GetRenderer()->OnAdjustCubeAxes();
1061 }
1062
1063 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
1064 {
1065   if ( otherViewWindow ) {
1066     bool blocked = blockSignals( true );
1067     doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
1068     blockSignals( blocked );
1069   }
1070 }
1071
1072 /*!
1073   Emits key pressed
1074 */
1075 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
1076 {
1077   emit keyPressed( this, event );
1078 }
1079
1080 /*!
1081   Emits key released
1082 */
1083 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
1084 {
1085   emit keyReleased( this, event );
1086 }
1087
1088 /*!
1089   Emits mouse pressed
1090 */
1091 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
1092 {
1093   emit mousePressed(this, event);
1094 }
1095
1096 /*!
1097   Emits mouse released
1098 */
1099 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
1100 {
1101   emit mouseReleased( this, event );
1102 }
1103
1104 /*!
1105   Emits mouse moving
1106 */
1107 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
1108 {
1109   emit mouseMoving( this, event );
1110 }
1111
1112 /*!
1113   Emits mouse double clicked
1114 */
1115 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
1116 {
1117   emit mouseDoubleClicked( this, event );
1118 }
1119
1120 /*!
1121   Redirect the request to #SVTK_Renderer::AddActor
1122 */
1123 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, 
1124                                 bool theUpdate,
1125                                 bool theIsAdjustActors )
1126 {
1127   GetRenderer()->AddActor(theActor, theIsAdjustActors);
1128   if(theUpdate) 
1129     Repaint();
1130   emit actorAdded(theActor);
1131 }
1132
1133 /*!
1134   Redirect the request to #SVTK_Renderer::RemoveActor
1135 */
1136 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, 
1137                                    bool theUpdate,
1138                                    bool theIsAdjustActors )
1139 {
1140   GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
1141   if ( myDefaultInteractorStyle )
1142     myDefaultInteractorStyle->FreeActors();
1143   if ( myKeyFreeInteractorStyle )
1144     myKeyFreeInteractorStyle->FreeActors();
1145   if(theUpdate) 
1146     Repaint();
1147   emit actorRemoved(theActor);
1148 }
1149
1150 QImage SVTK_ViewWindow::dumpViewContent()
1151 {
1152   vtkRenderWindow* aWindow = getRenderWindow();
1153   int* aSize = aWindow->GetSize();
1154   int aWidth = aSize[0];
1155   int aHeight = aSize[1];
1156   
1157   OpenGLUtils_FrameBuffer aFrameBuffer;
1158   if( aFrameBuffer.init( aWidth, aHeight ) )
1159   {
1160     glPushAttrib( GL_VIEWPORT_BIT );
1161     glViewport( 0, 0, aWidth, aHeight );
1162     aFrameBuffer.bind();
1163
1164     // draw scene
1165     aWindow->Render();
1166
1167     aFrameBuffer.unbind();
1168     glPopAttrib();
1169
1170     QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1171
1172     aFrameBuffer.bind();
1173     glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1174     aFrameBuffer.unbind();
1175
1176     anImage = anImage.rgbSwapped();
1177     anImage = anImage.mirrored();
1178     return anImage;
1179   }
1180
1181   // if frame buffers are unsupported, use old functionality
1182   unsigned char *aData = 
1183     aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
1184   
1185   QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
1186
1187   anImage = anImage.rgbSwapped();
1188   anImage = anImage.mirrored();
1189   return anImage;
1190 }
1191
1192 /*!
1193   \return QImage, containing all scene rendering in window
1194 */
1195 QImage SVTK_ViewWindow::dumpView()
1196 {
1197   if( myDumpImage.isNull() )
1198     return dumpViewContent();
1199   
1200   RefreshDumpImage();
1201   return myDumpImage;
1202 }
1203
1204 QString SVTK_ViewWindow::filter() const
1205 {
1206   return tr( "SVTK_IMAGE_FILES" );
1207 }
1208
1209 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
1210 {
1211   if ( format != "PS" && format != "EPS" && format != "PDF" )
1212     return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1213
1214   SUIT_OverrideCursor wc;
1215
1216   vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
1217   anExporter->SetRenderWindow(getRenderWindow());
1218
1219   if ( format == "PS" ) {
1220     anExporter->SetFileFormatToPS();
1221     anExporter->CompressOff();
1222   }
1223
1224   if ( format == "EPS" ) {
1225     anExporter->SetFileFormatToEPS();
1226     anExporter->CompressOff();
1227   }
1228
1229   if ( format == "PDF" ) {
1230     anExporter->SetFileFormatToPDF();
1231   }
1232
1233   QString aFilePrefix(fileName);
1234   QString anExtension(SUIT_Tools::extension(fileName));
1235   aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
1236   anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
1237   anExporter->Write();
1238   anExporter->Delete();
1239
1240   return true;
1241 }
1242
1243 /*!
1244   \refresh QImage, containing all scene rendering in window
1245 */
1246 void SVTK_ViewWindow::RefreshDumpImage()
1247 {
1248   myDumpImage = dumpViewContent();
1249 }
1250
1251 /*!
1252   Redirect the request to #SVTK_Renderer::SetSelectionProp
1253 */
1254 void SVTK_ViewWindow::SetSelectionProp(const double& theRed, 
1255                                        const double& theGreen, 
1256                                        const double& theBlue, 
1257                                        const int& theWidth) 
1258 {
1259   myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
1260 }
1261
1262 /*!
1263   Redirect the request to #SVTK_Renderer::SetSelectionProp
1264 */
1265 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed, 
1266                                           const double& theGreen, 
1267                                           const double& theBlue, 
1268                                           const int& theWidth) 
1269 {
1270   myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
1271 }
1272
1273 /*!
1274   Redirect the request to #SVTK_Renderer::SetSelectionTolerance
1275 */
1276 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes, 
1277                                             const double& theTolItems,
1278                                             const double& theTolObjects)
1279 {
1280   myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
1281 }
1282
1283 /*!
1284   Get visibility status of the static trihedron
1285 */
1286 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
1287 {
1288   return (bool)myAxesWidget->GetEnabled();
1289 }
1290
1291 /*!
1292   Set visibility status of the static trihedron
1293 */
1294 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
1295 {
1296   myAxesWidget->SetEnabled( (int)theIsVisible );
1297 }
1298
1299 /*!
1300   Performs action
1301   \param accelAction - action
1302 */
1303 bool SVTK_ViewWindow::action( const int accelAction  )
1304 {
1305   if ( accelAction == SUIT_Accel::ZoomFit )
1306     onFitAll();
1307   else {
1308     int anEvent = SVTK::convertAction( accelAction );
1309     GetInteractor()->InvokeEvent(anEvent, 0);
1310   }
1311   return true;
1312 }
1313
1314 /*!
1315   \return action by it's id
1316 */
1317 QtxAction* SVTK_ViewWindow::getAction( int id ) const
1318 {
1319   return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
1320 }
1321
1322
1323 // old visual parameters had 13 values.  New format added additional 
1324 // 76 values for graduated axes, so both numbers are processed.
1325 const int nNormalParams = 13;   // number of view windows parameters excluding graduated axes params
1326 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
1327 const int nTrihedronParams = 3; // number of parameters for Trihedron
1328 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
1329
1330 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
1331  */
1332 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
1333 {
1334   //QString params;
1335   if ( !actor )
1336     return ;//params;
1337
1338   // Name
1339   bool isVisible = actor->GetTitleVisibility();
1340   QString title ( actor->GetTitle() );
1341   double color[ 3 ];
1342   int font = VTK_ARIAL;
1343   int bold = 0;
1344   int italic = 0;
1345   int shadow = 0;
1346
1347   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1348   if ( txtProp )
1349   {
1350     txtProp->GetColor( color );
1351     font = txtProp->GetFontFamily();
1352     bold = txtProp->GetBold();
1353     italic = txtProp->GetItalic();
1354     shadow = txtProp->GetShadow();
1355   }
1356   writer.writeStartElement("GraduatedAxis");
1357   writer.writeAttribute("Axis", theAxis);
1358
1359   writer.writeStartElement("Title");
1360   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1361   writer.writeAttribute("Text", title);
1362   writer.writeAttribute("Font", QString("%1").arg(font));
1363   writer.writeAttribute("Bold", QString("%1").arg(bold));
1364   writer.writeAttribute("Italic", QString("%1").arg(italic));
1365   writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1366
1367   writer.writeStartElement("Color");
1368   writer.writeAttribute("R", QString("%1").arg(color[0]));
1369   writer.writeAttribute("G", QString("%1").arg(color[1]));
1370   writer.writeAttribute("B", QString("%1").arg(color[2]));
1371   writer.writeEndElement();
1372   writer.writeEndElement();
1373
1374   //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, 
1375   //              title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1376
1377   // Labels
1378   isVisible = actor->GetLabelVisibility();
1379   int labels = actor->GetNumberOfLabels();
1380   int offset = actor->GetTickOffset();
1381   font = VTK_ARIAL;
1382   bold = false;
1383   italic = false;
1384   shadow = false;
1385
1386   txtProp = actor->GetLabelTextProperty();
1387   if ( txtProp )
1388   {
1389     txtProp->GetColor( color );
1390     font = txtProp->GetFontFamily();
1391     bold = txtProp->GetBold();
1392     italic = txtProp->GetItalic();
1393     shadow = txtProp->GetShadow();
1394   }
1395
1396   writer.writeStartElement("Labels");
1397   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1398   writer.writeAttribute("Number", QString("%1").arg(labels));
1399   writer.writeAttribute("Offset", QString("%1").arg(offset));
1400   writer.writeAttribute("Font", QString("%1").arg(font));
1401   writer.writeAttribute("Bold", QString("%1").arg(bold));
1402   writer.writeAttribute("Italic", QString("%1").arg(italic));
1403   writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1404
1405   writer.writeStartElement("Color");
1406   writer.writeAttribute("R", QString("%1").arg(color[0]));
1407   writer.writeAttribute("G", QString("%1").arg(color[1]));
1408   writer.writeAttribute("B", QString("%1").arg(color[2]));
1409   writer.writeEndElement();
1410   writer.writeEndElement();
1411   //  params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,  
1412   //                           color[0], color[1], color[2], font, bold, italic, shadow );
1413
1414   // Tick marks
1415   isVisible = actor->GetTickVisibility();
1416   int length = actor->GetTickLength();
1417   writer.writeStartElement("TickMarks");
1418   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1419   writer.writeAttribute("Length", QString("%1").arg(length));
1420   writer.writeEndElement();
1421   
1422   //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1423   
1424   writer.writeEndElement();
1425   //return params;
1426 }
1427
1428 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1429 {
1430   if ( !actor )
1431     return;
1432
1433   do {
1434     reader.readNext();
1435   } while (!reader.isStartElement());
1436
1437   // Read title params
1438   QXmlStreamAttributes aAttr = reader.attributes();
1439   bool isVisible = aAttr.value("isVisible").toString().toUShort();
1440   QString title = aAttr.value("Text").toString();
1441   int font = aAttr.value("Font").toString().toInt();
1442   int bold = aAttr.value("Bold").toString().toInt();
1443   int italic = aAttr.value("Italic").toString().toInt();
1444   int shadow = aAttr.value("Shadow").toString().toInt();
1445
1446   //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1447
1448   do {
1449     reader.readNext();
1450   } while (!reader.isStartElement());
1451   
1452   // Read title color
1453   aAttr = reader.attributes();
1454
1455   double color[3];
1456   color[0] = aAttr.value("R").toString().toDouble();
1457   color[1] = aAttr.value("G").toString().toDouble();
1458   color[2] = aAttr.value("B").toString().toDouble();
1459   //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1460
1461   actor->SetTitleVisibility( isVisible );
1462   actor->SetTitle( title.toLatin1() );
1463   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1464   if ( txtProp ) {
1465     txtProp->SetColor( color );
1466     txtProp->SetFontFamily( font );
1467     txtProp->SetBold( bold );
1468     txtProp->SetItalic( italic );
1469     txtProp->SetShadow( shadow );
1470   }
1471
1472   // Labels
1473
1474   do {
1475     reader.readNext();
1476   } while (!reader.isStartElement()); 
1477   // Read labels
1478   aAttr = reader.attributes();
1479   isVisible = aAttr.value("isVisible").toString().toUShort();
1480   int labels = aAttr.value("Number").toString().toInt();
1481   int offset = aAttr.value("Offset").toString().toInt();
1482   font = aAttr.value("Font").toString().toInt();
1483   bold = aAttr.value("Bold").toString().toInt();
1484   italic = aAttr.value("Italic").toString().toInt();
1485   shadow = aAttr.value("Shadow").toString().toInt();
1486
1487   do {
1488     reader.readNext();
1489   } while (!reader.isStartElement()); 
1490   // Read Color
1491   aAttr = reader.attributes();
1492
1493   color[0] = aAttr.value("R").toString().toDouble();
1494   color[1] = aAttr.value("G").toString().toDouble();
1495   color[2] = aAttr.value("B").toString().toDouble();
1496
1497   actor->SetLabelVisibility( isVisible );
1498   actor->SetNumberOfLabels( labels );
1499   actor->SetTickOffset( offset );
1500   txtProp = actor->GetLabelTextProperty();
1501   if ( txtProp ) {
1502     txtProp->SetColor( color );
1503     txtProp->SetFontFamily( font );
1504     txtProp->SetBold( bold );
1505     txtProp->SetItalic( italic );
1506     txtProp->SetShadow( shadow );
1507   }
1508
1509   // Tick Marks
1510   do {
1511     reader.readNext();
1512   } while (!reader.isStartElement()); 
1513   aAttr = reader.attributes();
1514
1515   // retrieve and set tick marks properties
1516   isVisible = aAttr.value("isVisible").toString().toUShort();
1517   int length = aAttr.value("Length").toString().toInt();
1518   
1519   actor->SetTickVisibility( isVisible );
1520   actor->SetTickLength( length );
1521 }
1522
1523 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1524  */
1525 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1526 {
1527   if ( !actor )
1528     return;
1529
1530   QStringList paramsLst = params.split( '*' );
1531
1532   if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1533
1534     // retrieve and set name parameters
1535     bool isVisible = paramsLst[2].toUShort();
1536     QString title = paramsLst[3];
1537     double color[3];
1538     color[0] = paramsLst[4].toDouble();
1539     color[1] = paramsLst[5].toDouble();
1540     color[2] = paramsLst[6].toDouble();
1541     int font = paramsLst[7].toInt();
1542     int bold = paramsLst[8].toInt();
1543     int italic = paramsLst[9].toInt();
1544     int shadow = paramsLst[10].toInt();
1545
1546     actor->SetTitleVisibility( isVisible );
1547     actor->SetTitle( title.toLatin1() );
1548     vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1549     if ( txtProp ) {
1550       txtProp->SetColor( color );
1551       txtProp->SetFontFamily( font );
1552       txtProp->SetBold( bold );
1553       txtProp->SetItalic( italic );
1554       txtProp->SetShadow( shadow );
1555     }
1556
1557     // retrieve and set lable parameters
1558     isVisible = paramsLst[12].toUShort();
1559     int labels = paramsLst[13].toInt();
1560     int offset = paramsLst[14].toInt();
1561     color[0] = paramsLst[15].toDouble();
1562     color[1] = paramsLst[16].toDouble();
1563     color[2] = paramsLst[17].toDouble();
1564     font = paramsLst[18].toInt();
1565     bold = paramsLst[19].toInt();
1566     italic = paramsLst[20].toInt();
1567     shadow = paramsLst[21].toInt();
1568
1569     actor->SetLabelVisibility( isVisible );
1570     actor->SetNumberOfLabels( labels );
1571     actor->SetTickOffset( offset );
1572     txtProp = actor->GetLabelTextProperty();
1573     if ( txtProp ) {
1574       txtProp->SetColor( color );
1575       txtProp->SetFontFamily( font );
1576       txtProp->SetBold( bold );
1577       txtProp->SetItalic( italic );
1578       txtProp->SetShadow( shadow );
1579     }
1580
1581     // retrieve and set tick marks properties
1582     isVisible = paramsLst[23].toUShort();
1583     int length = paramsLst[24].toInt();
1584
1585     actor->SetTickVisibility( isVisible );
1586     actor->SetTickLength( length );
1587   }
1588 }
1589
1590 /*! The method returns the visual parameters of this view as a formated string
1591  */
1592 QString SVTK_ViewWindow::getVisualParameters()
1593 {
1594   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1595   
1596   // save position, focal point, viewUp, scale
1597   vtkCamera* camera = getRenderer()->GetActiveCamera();
1598   camera->GetPosition( pos );
1599   camera->GetFocalPoint( focalPnt );
1600   camera->GetViewUp( viewUp );
1601   parScale = camera->GetParallelScale();
1602   GetScale( scale );
1603
1604   // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1605   // view up values (3 digits), parallel scale (1 digit), scale (3 digits, 
1606   // Graduated axes parameters (X, Y, Z axes parameters)
1607   QString retStr;
1608   QXmlStreamWriter aWriter(&retStr);
1609   aWriter.setAutoFormatting(true);
1610
1611   aWriter.writeStartDocument();
1612   aWriter.writeStartElement("ViewState");
1613
1614   aWriter.writeStartElement("Position");
1615   aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1616   aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1617   aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1618   aWriter.writeEndElement();
1619
1620   aWriter.writeStartElement("FocalPoint");
1621   aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1622   aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1623   aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1624   aWriter.writeEndElement();
1625
1626   aWriter.writeStartElement("ViewUp");
1627   aWriter.writeAttribute("X", QString::number(viewUp[0]));
1628   aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1629   aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1630   aWriter.writeEndElement();
1631
1632   aWriter.writeStartElement("ViewScale");
1633   aWriter.writeAttribute("Parallel", QString::number(parScale));
1634   aWriter.writeAttribute("X", QString::number(scale[0]));
1635   aWriter.writeAttribute("Y", QString::number(scale[1]));
1636   aWriter.writeAttribute("Z", QString::number(scale[2]));
1637   aWriter.writeEndElement();
1638
1639   if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1640     aWriter.writeStartElement("DisplayCubeAxis");
1641     aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1642     aWriter.writeEndElement();
1643
1644     getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1645     getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1646     getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1647   }
1648
1649   aWriter.writeStartElement("Trihedron");
1650   aWriter.writeAttribute("isShown",  QString( "%1" ).arg( isTrihedronDisplayed()));
1651   aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1652   aWriter.writeEndElement();
1653
1654   aWriter.writeStartElement("Background");
1655   aWriter.writeAttribute("Value",  QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
1656   aWriter.writeEndElement();
1657
1658   aWriter.writeEndElement();
1659   aWriter.writeEndDocument();
1660
1661   return retStr;
1662 }
1663
1664 /*!
1665   The method restores visual parameters of this view or postpones it untill the view is shown
1666 */ 
1667 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1668 {
1669   //printf("#### %s\n", qPrintable(parameters));
1670   SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1671   if ( anInteractor->isVisible() ) {
1672     doSetVisualParameters( parameters ); 
1673   }
1674   else {
1675     myVisualParams = parameters;
1676     anInteractor->installEventFilter(this);
1677   }
1678 }
1679
1680 /*!
1681   The method restores visual parameters of this view from a formated string
1682 */
1683 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
1684 {
1685   
1686   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1687
1688   QXmlStreamReader aReader(parameters);
1689   SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1690
1691   while(!aReader.atEnd()) {
1692     aReader.readNext();
1693     if (aReader.isStartElement()) {
1694       QXmlStreamAttributes aAttr = aReader.attributes();
1695       //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1696       if (aReader.name() == "Position") {       
1697         pos[0] = aAttr.value("X").toString().toDouble();
1698         pos[1] = aAttr.value("Y").toString().toDouble();
1699         pos[2] = aAttr.value("Z").toString().toDouble();
1700         //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1701       }
1702       else if (aReader.name() == "FocalPoint") {
1703         focalPnt[0] = aAttr.value("X").toString().toDouble();
1704         focalPnt[1] = aAttr.value("Y").toString().toDouble();
1705         focalPnt[2] = aAttr.value("Z").toString().toDouble();
1706         //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1707       }
1708       else if (aReader.name() == "ViewUp") {
1709         viewUp[0] = aAttr.value("X").toString().toDouble();
1710         viewUp[1] = aAttr.value("Y").toString().toDouble();
1711         viewUp[2] = aAttr.value("Z").toString().toDouble();
1712         //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1713       }
1714       else if (aReader.name() == "ViewScale") {
1715         parScale = aAttr.value("Parallel").toString().toDouble();
1716         scale[0] = aAttr.value("X").toString().toDouble();
1717         scale[1] = aAttr.value("Y").toString().toDouble();
1718         scale[2] = aAttr.value("Z").toString().toDouble();
1719         //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1720       } 
1721       else if (aReader.name() == "DisplayCubeAxis") {
1722         if ( !baseParamsOnly ) {
1723           if (aAttr.value("Show") == "0")
1724             gradAxesActor->VisibilityOff();
1725           else
1726             gradAxesActor->VisibilityOn();
1727         }
1728       }
1729       else if (aReader.name() == "GraduatedAxis") {
1730         if ( !baseParamsOnly ) {
1731           if(aAttr.value("Axis") == "X") 
1732             setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1733           else if(aAttr.value("Axis") == "Y")
1734             setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1735           else if(aAttr.value("Axis") == "Z")
1736             setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1737         }
1738       } 
1739       else if (aReader.name() == "Trihedron") {
1740         if ( !baseParamsOnly ) {
1741           if (aAttr.value("isShown") == "0")
1742             GetTrihedron()->VisibilityOff();
1743           else
1744             GetTrihedron()->VisibilityOn();
1745           SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1746         }
1747       }
1748       else if (aReader.name() == "Background") {
1749         if ( !baseParamsOnly ) {
1750           setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
1751         }
1752       }
1753     }
1754   }
1755   if (!aReader.hasError()) {
1756     vtkCamera* camera = getRenderer()->GetActiveCamera();
1757     camera->SetPosition( pos );
1758     camera->SetFocalPoint( focalPnt );
1759     camera->SetViewUp( viewUp );
1760     camera->SetParallelScale( parScale );
1761     GetRenderer()->SetScale( scale );
1762     //SetScale( scale );
1763   }
1764   else {
1765     QStringList paramsLst = parameters.split( '*' );
1766     if ( paramsLst.size() >= nNormalParams ) {
1767       // 'reading' list of parameters
1768       pos[0] = paramsLst[0].toDouble();
1769       pos[1] = paramsLst[1].toDouble();
1770       pos[2] = paramsLst[2].toDouble();
1771       focalPnt[0] = paramsLst[3].toDouble();
1772       focalPnt[1] = paramsLst[4].toDouble();
1773       focalPnt[2] = paramsLst[5].toDouble();
1774       viewUp[0] = paramsLst[6].toDouble();
1775       viewUp[1] = paramsLst[7].toDouble();
1776       viewUp[2] = paramsLst[8].toDouble();
1777       parScale = paramsLst[9].toDouble();
1778       scale[0] = paramsLst[10].toDouble();
1779       scale[1] = paramsLst[11].toDouble();
1780       scale[2] = paramsLst[12].toDouble();
1781       
1782       // applying parameters
1783       vtkCamera* camera = getRenderer()->GetActiveCamera();
1784       camera->SetPosition( pos );
1785       camera->SetFocalPoint( focalPnt );
1786       camera->SetViewUp( viewUp );
1787       camera->SetParallelScale( parScale );
1788       GetRenderer()->SetScale( scale );
1789       //SetScale( scale );
1790       
1791       // apply graduated axes parameters
1792       if ( !baseParamsOnly ) {
1793         SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1794         if ( gradAxesActor && paramsLst.size() == nAllParams ) {
1795           int i = nNormalParams+1, j = i + nGradAxisParams - 1;
1796           ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
1797           i = j + 1; j += nGradAxisParams;
1798           ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); 
1799           i = j + 1; j += nGradAxisParams;
1800           ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); 
1801         
1802           if ( paramsLst[13].toUShort() )
1803             gradAxesActor->VisibilityOn();
1804           else
1805             gradAxesActor->VisibilityOff();
1806         }
1807         else if ( paramsLst.size() == nAllParams ) {
1808           if ( paramsLst[90].toUShort() )
1809             GetTrihedron()->VisibilityOn();
1810           else
1811             GetTrihedron()->VisibilityOff();
1812         
1813           SetTrihedronSize(paramsLst[91].toDouble());
1814         }
1815       }
1816     }
1817   }
1818   Repaint();
1819 }
1820
1821
1822 /*!
1823   Delayed setVisualParameters
1824 */
1825 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
1826 {
1827   if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
1828     SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
1829     if ( anInteractor->isVisible() ) {
1830       doSetVisualParameters( myVisualParams );
1831       anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
1832     }
1833   }
1834   return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
1835 }
1836
1837
1838 /*!
1839   Change rotation point
1840 */
1841 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
1842 {
1843   if(theIsActivate){
1844     mySetRotationPointDlg->addObserver();
1845     if ( mySetRotationPointDlg->IsFirstShown() )
1846       activateSetRotationGravity();
1847     mySetRotationPointDlg->show();
1848   }else
1849     mySetRotationPointDlg->hide();
1850 }
1851
1852 /*!
1853   Set the gravity center as a rotation point
1854 */
1855 void SVTK_ViewWindow::activateSetRotationGravity()
1856 {
1857   myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
1858 }
1859
1860 /*!
1861   Set the selected point as a rotation point
1862 */
1863 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
1864 {
1865   myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
1866 }
1867
1868 /*!
1869   Set the gravity center of element selected by user as a rotation point
1870 */
1871 void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
1872 {
1873   SetSelectionMode( theSelectionMode );
1874   myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
1875 }
1876
1877 /*!
1878   Set the view projection mode: orthogonal or perspective
1879 */
1880 void SVTK_ViewWindow::onPerspectiveMode()
1881 {
1882   bool anIsParallelMode = toolMgr()->action( ParallelModeId )->isChecked();
1883
1884   // advanced zooming is not available in perspective mode
1885   if( QtxAction* anAction = getAction( SwitchZoomingStyleId ) )
1886     anAction->setEnabled( anIsParallelMode );
1887
1888   vtkCamera* aCamera = getRenderer()->GetActiveCamera();
1889   aCamera->SetParallelProjection(anIsParallelMode);
1890   GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
1891
1892   emit transformed( this );
1893 }
1894
1895 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
1896 {
1897   myEventDispatcher = theDispatcher;
1898 }
1899
1900 /*!
1901   Creates all actions of svtk main window
1902 */
1903 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
1904 {
1905   QtxAction* anAction;
1906   QtxActionToolMgr* mgr = toolMgr();
1907
1908   // Dump view
1909   anAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
1910                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
1911                            tr( "MNU_DUMP_VIEW" ), 0, this);
1912   anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
1913   connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
1914   mgr->registerAction( anAction, DumpId );
1915
1916   // FitAll
1917   anAction = new QtxAction(tr("MNU_FITALL"), 
1918                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
1919                            tr( "MNU_FITALL" ), 0, this);
1920   anAction->setStatusTip(tr("DSC_FITALL"));
1921   connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
1922   mgr->registerAction( anAction, FitAllId );
1923
1924   // FitRect
1925   anAction = new QtxAction(tr("MNU_FITRECT"), 
1926                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
1927                            tr( "MNU_FITRECT" ), 0, this);
1928   anAction->setStatusTip(tr("DSC_FITRECT"));
1929   connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
1930   mgr->registerAction( anAction, FitRectId );
1931
1932   // Zoom
1933   anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
1934                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
1935                            tr( "MNU_ZOOM_VIEW" ), 0, this);
1936   anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
1937   connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
1938   mgr->registerAction( anAction, ZoomId );
1939
1940   // Panning
1941   anAction = new QtxAction(tr("MNU_PAN_VIEW"), 
1942                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
1943                            tr( "MNU_PAN_VIEW" ), 0, this);
1944   anAction->setStatusTip(tr("DSC_PAN_VIEW"));
1945   connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
1946   mgr->registerAction( anAction, PanId );
1947
1948   // Global Panning
1949   anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), 
1950                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
1951                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
1952   anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
1953   connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
1954   mgr->registerAction( anAction, GlobalPanId );
1955
1956   // Change rotation point
1957   anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), 
1958                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
1959                            tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
1960   anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
1961   anAction->setCheckable(true);
1962   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
1963   mgr->registerAction( anAction, ChangeRotationPointId );
1964
1965   // Rotation
1966   anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), 
1967                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
1968                            tr( "MNU_ROTATE_VIEW" ), 0, this);
1969   anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
1970   connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
1971   mgr->registerAction( anAction, RotationId );
1972
1973   // Projections
1974   anAction = new QtxAction(tr("MNU_FRONT_VIEW"), 
1975                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
1976                            tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
1977   anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
1978   connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
1979   this->addAction(anAction);
1980   mgr->registerAction( anAction, FrontId );
1981
1982   anAction = new QtxAction(tr("MNU_BACK_VIEW"), 
1983                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
1984                            tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
1985   anAction->setStatusTip(tr("DSC_BACK_VIEW"));
1986   connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
1987   this->addAction(anAction);
1988   mgr->registerAction( anAction, BackId );
1989
1990   anAction = new QtxAction(tr("MNU_TOP_VIEW"), 
1991                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
1992                            tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
1993   anAction->setStatusTip(tr("DSC_TOP_VIEW"));
1994   connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
1995   this->addAction(anAction);
1996   mgr->registerAction( anAction, TopId );
1997
1998   anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), 
1999                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
2000                            tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
2001   anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
2002   connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
2003   this->addAction(anAction);
2004   mgr->registerAction( anAction, BottomId );
2005
2006   anAction = new QtxAction(tr("MNU_LEFT_VIEW"), 
2007                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
2008                            tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
2009   anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
2010   connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
2011   this->addAction(anAction);
2012   mgr->registerAction( anAction, LeftId );
2013
2014   anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), 
2015                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
2016                            tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
2017   anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
2018   connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
2019   this->addAction(anAction);
2020   mgr->registerAction( anAction, RightId );
2021
2022   // rotate anticlockwise
2023   anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
2024                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
2025                            tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
2026   anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
2027   connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
2028   this->addAction(anAction);
2029   mgr->registerAction( anAction, AntiClockWiseId );
2030
2031   // rotate clockwise
2032   anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
2033                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
2034                            tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
2035   anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
2036   connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
2037   this->addAction(anAction);
2038   mgr->registerAction( anAction, ClockWiseId );
2039
2040   // Reset
2041   anAction = new QtxAction(tr("MNU_RESET_VIEW"), 
2042                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
2043                            tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
2044   anAction->setStatusTip(tr("DSC_RESET_VIEW"));
2045   connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
2046   this->addAction(anAction);
2047   mgr->registerAction( anAction, ResetId );
2048
2049   // onViewTrihedron: Shows - Hides Trihedron
2050   anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
2051                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
2052                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
2053   anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
2054   connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
2055   mgr->registerAction( anAction, ViewTrihedronId );
2056
2057   // onNonIsometric: Manage non-isometric params
2058   anAction = new QtxAction(tr("MNU_SVTK_SCALING"), 
2059                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
2060                            tr( "MNU_SVTK_SCALING" ), 0, this);
2061   anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
2062   anAction->setCheckable(true);
2063   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
2064   mgr->registerAction( anAction, NonIsometric );
2065
2066   // onGraduatedAxes: Manage graduated axes params
2067   anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"), 
2068                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
2069                            tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
2070   anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
2071   anAction->setCheckable(true);
2072   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
2073   mgr->registerAction( anAction, GraduatedAxes );
2074
2075   // onGraduatedAxes: Manage graduated axes params
2076   anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"), 
2077                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
2078                            tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
2079   anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
2080   anAction->setCheckable(true);
2081   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
2082   mgr->registerAction( anAction, UpdateRate );
2083
2084   // Set perspective mode group
2085   anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"), 
2086                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
2087                            tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
2088   anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
2089   anAction->setCheckable(true);
2090   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
2091   mgr->registerAction( anAction, ParallelModeId );
2092
2093   anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"), 
2094                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
2095                            tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
2096   anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
2097   anAction->setCheckable(true);
2098   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
2099   mgr->registerAction( anAction, ProjectionModeId );
2100
2101   QActionGroup* aPerspectiveGroup = new QActionGroup( this );
2102   aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
2103   aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
2104
2105   // View Parameters
2106   anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), 
2107                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
2108                            tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
2109   anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
2110   anAction->setCheckable(true);
2111   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
2112   mgr->registerAction( anAction, ViewParametersId );
2113
2114   // Synchronize View 
2115   mgr->registerAction( synchronizeAction(), SynchronizeId );
2116
2117   // Switch between interaction styles
2118   anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"), 
2119                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
2120                            tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
2121   anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
2122   anAction->setCheckable(true);
2123   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
2124   mgr->registerAction( anAction, SwitchInteractionStyleId );
2125
2126   // Switch between zooming styles
2127   anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"), 
2128                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
2129                            tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
2130   anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
2131   anAction->setCheckable(true);
2132   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
2133   mgr->registerAction( anAction, SwitchZoomingStyleId );
2134
2135   // Pre-selection
2136   QSignalMapper* aSignalMapper = new QSignalMapper( this );
2137   connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int)));
2138
2139   anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_STANDARD"), 
2140                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ),
2141                            tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
2142   anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
2143   anAction->setCheckable(true);
2144   connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
2145   aSignalMapper->setMapping( anAction, Standard_Preselection );
2146   mgr->registerAction( anAction, StandardPreselectionId );
2147   
2148   anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DYNAMIC"), 
2149                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DYNAMIC" ) ),
2150                            tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
2151   anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
2152   anAction->setCheckable(true);
2153   connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
2154   aSignalMapper->setMapping( anAction, Dynamic_Preselection );
2155   mgr->registerAction( anAction, DynamicPreselectionId );
2156
2157   anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DISABLED"), 
2158                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DISABLED" ) ),
2159                            tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
2160   anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
2161   anAction->setCheckable(true);
2162   connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
2163   aSignalMapper->setMapping( anAction, Preselection_Disabled );
2164   mgr->registerAction( anAction, DisablePreselectionId );
2165
2166   QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true );
2167   aPreselectionAction->add( getAction( StandardPreselectionId ) );
2168   aPreselectionAction->add( getAction( DynamicPreselectionId ) );
2169   aPreselectionAction->add( getAction( DisablePreselectionId ) );
2170   mgr->registerAction( aPreselectionAction, PreselectionId );
2171
2172   // Selection
2173   anAction = new QtxAction(tr("MNU_SVTK_ENABLE_SELECTION"), 
2174                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SELECTION" ) ),
2175                            tr( "MNU_SVTK_ENABLE_SELECTION" ), 0, this);
2176   anAction->setStatusTip(tr("DSC_SVTK_ENABLE_SELECTION"));
2177   anAction->setCheckable(true);
2178   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool)));
2179   mgr->registerAction( anAction, EnableSelectionId );
2180
2181   // Start recording
2182   myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), 
2183                                 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
2184                                 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
2185   myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
2186   connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
2187   mgr->registerAction( myStartAction, StartRecordingId );
2188
2189   // Play recording
2190   myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"), 
2191                                theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
2192                                tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
2193   myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
2194   myPlayAction->setEnabled( false );
2195   connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
2196   mgr->registerAction( myPlayAction, PlayRecordingId );
2197
2198   // Pause recording
2199   myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"), 
2200                                 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
2201                                 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
2202   myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
2203   myPauseAction->setEnabled( false );
2204   connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
2205   mgr->registerAction( myPauseAction, PauseRecordingId );
2206
2207   // Stop recording
2208   myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"), 
2209                                theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
2210                                tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
2211   myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
2212   myStopAction->setEnabled( false );
2213   connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
2214   mgr->registerAction( myStopAction, StopRecordingId );
2215 }
2216
2217 /*!
2218   Creates toolbar of svtk main window
2219 */
2220 void SVTK_ViewWindow::createToolBar()
2221 {
2222   QtxActionToolMgr* mgr = toolMgr();
2223   
2224   mgr->append( DumpId, myToolBar );
2225   mgr->append( SwitchInteractionStyleId, myToolBar );
2226   mgr->append( SwitchZoomingStyleId, myToolBar );
2227
2228   mgr->append( mgr->separator(), myToolBar );
2229  
2230   mgr->append( PreselectionId, myToolBar );
2231   mgr->append( EnableSelectionId, myToolBar );
2232
2233   mgr->append( mgr->separator(), myToolBar );
2234
2235   mgr->append( ViewTrihedronId, myToolBar );
2236
2237   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
2238   aScaleAction->insertAction( getAction( FitAllId ) );
2239   aScaleAction->insertAction( getAction( FitRectId ) );
2240   aScaleAction->insertAction( getAction( ZoomId ) );
2241   mgr->append( aScaleAction, myToolBar );
2242
2243   QtxMultiAction* aPanningAction = new QtxMultiAction( this );
2244   aPanningAction->insertAction( getAction( PanId ) );
2245   aPanningAction->insertAction( getAction( GlobalPanId ) );
2246   mgr->append( aPanningAction, myToolBar );
2247
2248   mgr->append( ChangeRotationPointId, myToolBar );
2249
2250   mgr->append( RotationId, myToolBar );
2251
2252   QtxMultiAction* aViewsAction = new QtxMultiAction( this );
2253   aViewsAction->insertAction( getAction( FrontId ) );
2254   aViewsAction->insertAction( getAction( BackId ) );
2255   aViewsAction->insertAction( getAction( TopId ) );
2256   aViewsAction->insertAction( getAction( BottomId ) );
2257   aViewsAction->insertAction( getAction( LeftId ) );
2258   aViewsAction->insertAction( getAction( RightId ) );
2259   mgr->append( aViewsAction, myToolBar );
2260
2261   mgr->append( AntiClockWiseId, myToolBar );
2262   mgr->append( ClockWiseId, myToolBar );
2263
2264   mgr->append( ResetId, myToolBar );
2265
2266   mgr->append( UpdateRate, myToolBar );
2267   mgr->append( NonIsometric, myToolBar );
2268   mgr->append( GraduatedAxes, myToolBar );
2269
2270   mgr->append( ViewParametersId, myToolBar );
2271   mgr->append( SynchronizeId, myToolBar );
2272
2273   mgr->append( toolMgr()->separator(), myToolBar );
2274
2275   mgr->append( ParallelModeId, myToolBar );
2276   mgr->append( ProjectionModeId, myToolBar );
2277
2278   mgr->append( StartRecordingId, myRecordingToolBar );
2279   mgr->append( PlayRecordingId, myRecordingToolBar );
2280   mgr->append( PauseRecordingId, myRecordingToolBar );
2281   mgr->append( StopRecordingId, myRecordingToolBar );
2282 }
2283
2284 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
2285 {
2286   if(theIsActivate){
2287     myUpdateRateDlg->Update();
2288     myUpdateRateDlg->show();
2289   }else
2290     myUpdateRateDlg->hide();
2291 }
2292
2293 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
2294 {
2295   if(theIsActivate){
2296     myNonIsometricDlg->Update();
2297     myNonIsometricDlg->show();
2298   }else
2299     myNonIsometricDlg->hide();
2300 }
2301
2302 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
2303 {
2304   if(theIsActivate){
2305     myCubeAxesDlg->Update();
2306     myCubeAxesDlg->show();
2307   }else
2308     myCubeAxesDlg->hide();
2309 }
2310
2311 /*!
2312   Starts rotation transformation
2313 */
2314 void SVTK_ViewWindow::activateRotation()
2315 {
2316   myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
2317 }
2318
2319
2320 /*!
2321   Starts panning transformation
2322 */
2323 void SVTK_ViewWindow::activatePanning()
2324 {
2325   myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
2326 }
2327
2328 /*!
2329   Starts zoom transformation
2330 */
2331 void SVTK_ViewWindow::activateZoom()
2332 {
2333   myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
2334 }
2335
2336 /*!
2337   Starts window fit transformation
2338 */
2339 void SVTK_ViewWindow::activateWindowFit()
2340 {
2341   myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
2342 }
2343
2344 /*!
2345   Starts global panning transformation
2346 */
2347 void SVTK_ViewWindow::activateGlobalPanning()
2348 {
2349   myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
2350 }
2351
2352 void SVTK_ViewWindow::onStartRecording()
2353 {
2354   myRecorder->CheckExistAVIMaker();
2355   if (myRecorder->ErrorStatus()) {
2356     SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
2357   }
2358   else {
2359     SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
2360
2361     if( !aRecorderDlg->exec() )
2362       return;
2363
2364     myStartAction->setEnabled( false );
2365     myPlayAction->setEnabled( false );
2366     myPauseAction->setEnabled( true );
2367     myStopAction->setEnabled( true );
2368
2369     // to prevent resizing the window while recording
2370     myPreRecordingMinSize = minimumSize();
2371     myPreRecordingMaxSize = maximumSize();
2372     setFixedSize( size() );
2373
2374     myRecorder->Record();
2375   }
2376 }
2377
2378 void SVTK_ViewWindow::onPlayRecording()
2379 {
2380   myStartAction->setEnabled( false );
2381   myPlayAction->setEnabled( false );
2382   myPauseAction->setEnabled( true );
2383   myStopAction->setEnabled( true );
2384
2385   myRecorder->Pause();
2386 }
2387
2388 void SVTK_ViewWindow::onPauseRecording()
2389 {
2390   myStartAction->setEnabled( false );
2391   myPlayAction->setEnabled( true );
2392   myPauseAction->setEnabled( false );
2393   myStopAction->setEnabled( true );
2394
2395   myRecorder->Pause();
2396 }
2397
2398 void SVTK_ViewWindow::onStopRecording()
2399 {
2400   myStartAction->setEnabled( true );
2401   myPlayAction->setEnabled( false );
2402   myPauseAction->setEnabled( false );
2403   myStopAction->setEnabled( false );
2404
2405   myRecorder->Stop();
2406
2407   setMinimumSize( myPreRecordingMinSize );
2408   setMaximumSize( myPreRecordingMaxSize );
2409 }
2410
2411 /*!
2412   To invoke a VTK event on SVTK_RenderWindowInteractor instance
2413 */
2414 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
2415 {
2416   GetInteractor()->InvokeEvent(theEvent,theCallData);
2417 }
2418
2419 /*!
2420   Modify view parameters
2421 */
2422 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
2423 {
2424   if(theIsActivate){
2425     myViewParameterDlg->addObserver();
2426     myViewParameterDlg->show();
2427   }else
2428     myViewParameterDlg->hide();
2429 }
2430
2431 /*!
2432   Custom show event handler
2433 */
2434 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent ) 
2435 {
2436   emit Show( theEvent );
2437 }
2438
2439 /*!
2440   Custom hide event handler
2441 */
2442 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent ) 
2443 {
2444   emit Hide( theEvent );
2445 }
2446
2447 /*!
2448   Emit transformed signal.
2449 */
2450 void SVTK_ViewWindow::emitTransformed() {
2451   transformed(this);
2452 }
2453
2454 /*!
2455   Processes events
2456 */
2457 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
2458                                     unsigned long theEvent,
2459                                     void* theClientData,
2460                                     void* theCallData)
2461 {
2462   SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
2463   if(self)
2464     self->emitTransformed();
2465 }
2466
2467 /*!
2468   Get camera properties for the SVTK view window.
2469   \return shared pointer on camera properties.
2470 */
2471 SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
2472 {
2473   SUIT_CameraProperties aProps;
2474
2475   // get vtk camera
2476   vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2477   if ( !aCamera )
2478     return aProps;
2479   
2480   aProps.setDimension( SUIT_CameraProperties::Dim3D );
2481   if ( toolMgr()->action( ParallelModeId ) ) {
2482     if ( toolMgr()->action( ParallelModeId )->isChecked() )
2483       aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
2484     else
2485       aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
2486   }
2487
2488   double aFocalPoint[3];
2489   double aPosition[3];
2490   double aViewUp[3];
2491   double anAxialScale[3];
2492
2493   aCamera->OrthogonalizeViewUp();
2494   aCamera->GetFocalPoint( aFocalPoint );
2495   aCamera->GetPosition( aPosition );
2496   aCamera->GetViewUp( aViewUp );
2497   
2498   aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2499   aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
2500   aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2501   aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
2502
2503   if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2504   {
2505     aProps.setViewAngle( aCamera->GetViewAngle() );
2506   }
2507
2508   GetRenderer()->GetScale( anAxialScale );
2509   aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2510   
2511   return aProps;
2512 }
2513
2514 /*!
2515   Synchronize views.
2516   This implementation synchronizes camera propreties.
2517 */
2518 void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2519 {
2520   bool blocked = blockSignals( true );
2521
2522   SUIT_CameraProperties aProps = theView->cameraProperties();
2523   if ( !cameraProperties().isCompatible( aProps ) ) {
2524     // other view, this one is being currently synchronized to, seems has become incompatible
2525     // we have to break synchronization
2526     updateSyncViews();
2527     return;
2528   }
2529
2530   // get camera
2531   vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2532   
2533   double aFocalPoint[3];
2534   double aPosition[3];
2535   double aViewUp[3];
2536   double anAxialScale[3];
2537
2538   // get common properties
2539   aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2540   aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
2541   aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2542   aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2543   
2544   // restore properties to the camera
2545   aCamera->SetViewUp( aViewUp );
2546   aCamera->SetPosition( aPosition );
2547   aCamera->SetFocalPoint( aFocalPoint );
2548   aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
2549
2550   if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2551   {
2552     aCamera->SetViewAngle( aProps.getViewAngle() );
2553   }
2554
2555   GetRenderer()->SetScale( anAxialScale );
2556
2557   getRenderer()->ResetCameraClippingRange();
2558   Repaint( false );
2559
2560   blockSignals( blocked );
2561 }