Back to index

salome-gui  6.5.0
SVTK_ViewWindow.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "SVTK_NonIsometricDlg.h"
00024 #include "SVTK_UpdateRateDlg.h"
00025 #include "SVTK_CubeAxesDlg.h"
00026 #include "SVTK_SetRotationPointDlg.h"
00027 #include "SVTK_ViewParameterDlg.h"
00028 #include "SVTK_ViewModel.h"
00029 #include "VTKViewer_Texture.h"
00030 #include "VTKViewer_OpenGLRenderer.h"
00031 
00032 #include "SALOME_Actor.h"
00033 
00034 #include <QMenu>
00035 #include <QToolBar>
00036 #include <QEvent>
00037 #include <QFileInfo>
00038 #include <QXmlStreamWriter>
00039 #include <QXmlStreamReader>
00040 #include <QXmlStreamAttributes>
00041 
00042 #include <vtkTextProperty.h>
00043 #include <vtkActorCollection.h>
00044 #include <vtkRenderWindow.h>
00045 #include <vtkRenderer.h>
00046 #include <vtkCamera.h>
00047 #include <vtkPointPicker.h>
00048 #include <vtkCellPicker.h>
00049 #include <vtkAxisActor2D.h>
00050 #include <vtkGL2PSExporter.h>
00051 #include <vtkInteractorStyle.h>
00052 #include <vtkProperty.h>
00053 #include <vtkCallbackCommand.h>
00054 #include <vtkJPEGReader.h>
00055 #include <vtkBMPReader.h>
00056 #include <vtkTIFFReader.h>
00057 #include <vtkPNGReader.h>
00058 #include <vtkMetaImageReader.h>
00059 #include <vtkImageMapToColors.h>
00060 #include <vtkTexture.h>
00061 
00062 #include "QtxAction.h"
00063 
00064 #include "SUIT_Session.h"
00065 #include "SUIT_MessageBox.h"
00066 #include "SUIT_Accel.h"
00067 #include "SUIT_Tools.h"
00068 #include "SUIT_ResourceMgr.h"
00069 #include "SUIT_Accel.h"
00070 #include "SUIT_OverrideCursor.h"
00071 #include "SUIT_ViewManager.h"
00072 #include "QtxActionToolMgr.h"
00073 #include "QtxMultiAction.h"
00074 
00075 #include "VTKViewer_Utilities.h"
00076 #include "VTKViewer_Trihedron.h"
00077 
00078 #include "SVTK_View.h"
00079 //#include "SVTK_MainWindow.h"
00080 #include "SVTK_Selector.h"
00081 
00082 #include "SVTK_Event.h"
00083 #include "SVTK_Renderer.h"
00084 #include "SVTK_ViewWindow.h"
00085 #include "SVTK_InteractorStyle.h"
00086 #include "SVTK_RenderWindowInteractor.h"
00087 #include "SVTK_GenericRenderWindowInteractor.h"
00088 #include "SVTK_CubeAxesActor2D.h"
00089 #include "SVTK_ComboAction.h"
00090 #include "SVTK_KeyFreeInteractorStyle.h"
00091 #include "SVTK_Selector.h"
00092 #include "SVTK_Recorder.h"
00093 #include "SVTK_RecorderDlg.h"
00094 
00095 #include "vtkPVAxesWidget.h"
00096 #include "vtkPVAxesActor.h"
00097 
00098 #include "SALOME_ListIteratorOfListIO.hxx"
00099 
00100 #include "VTKViewer_Algorithm.h"
00101 #include "SVTK_Functor.h"
00102 
00103 #include <OpenGLUtils_FrameBuffer.h>
00104 
00105 
00106 namespace SVTK
00107 {
00108   int convertAction( const int accelAction )
00109   {
00110     switch ( accelAction ) {
00111     case SUIT_Accel::PanLeft     : return SVTK::PanLeftEvent;
00112     case SUIT_Accel::PanRight    : return SVTK::PanRightEvent;
00113     case SUIT_Accel::PanUp       : return SVTK::PanUpEvent;
00114     case SUIT_Accel::PanDown     : return SVTK::PanDownEvent;
00115     case SUIT_Accel::ZoomIn      : return SVTK::ZoomInEvent;
00116     case SUIT_Accel::ZoomOut     : return SVTK::ZoomOutEvent;
00117     case SUIT_Accel::RotateLeft  : return SVTK::RotateLeftEvent;
00118     case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
00119     case SUIT_Accel::RotateUp    : return SVTK::RotateUpEvent;
00120     case SUIT_Accel::RotateDown  : return SVTK::RotateDownEvent;  
00121     }
00122     return accelAction;
00123   }
00124 }
00125 
00126 
00127 
00128 
00129 
00133 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
00134   SUIT_ViewWindow(theDesktop),
00135   myView(NULL),
00136   myDumpImage(QImage()),
00137   myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
00138   myEventCallbackCommand(vtkCallbackCommand::New())
00139 {
00140   setWindowFlags( windowFlags() & ~Qt::Window );
00141   // specific of vtkSmartPointer
00142   myKeyFreeInteractorStyle->Delete();
00143 }
00144 
00148 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
00149 {
00150   myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
00151   
00152   SVTK_Selector* aSelector = SVTK_Selector::New(); 
00153   aSelector->SetDynamicPreSelection( SUIT_Session::session()->resourceMgr()->
00154                                  booleanValue( "VTKViewer", "dynamic_preselection", true ) );
00155   
00156   SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
00157   aDevice->SetRenderWidget(myInteractor);
00158   aDevice->SetSelector(aSelector);
00159   
00160   SVTK_Renderer* aRenderer = SVTK_Renderer::New();
00161   aRenderer->Initialize(aDevice,aSelector);
00162   
00163   myInteractor->Initialize(aDevice,aRenderer,aSelector);
00164   
00165   aDevice->Delete();
00166   aRenderer->Delete();
00167   aSelector->Delete();
00168   
00169   myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false, Qt::AllToolBarAreas, -1, this );
00170   myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), false, Qt::AllToolBarAreas, -1, this );
00171   
00172   createActions( SUIT_Session::session()->resourceMgr() );
00173   createToolBar();
00174   
00175   SetEventDispatcher(myInteractor->GetDevice());
00176   myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
00177   myInteractor->setFocusPolicy(Qt::StrongFocus);
00178   myInteractor->setFocus();
00179   setFocusProxy(myInteractor);
00180   
00181   myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
00182   myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
00183   myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
00184   myCubeAxesDlg->initialize();
00185   mySetRotationPointDlg = new SVTK_SetRotationPointDlg
00186     ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
00187   myViewParameterDlg = new SVTK_ViewParameterDlg
00188     ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
00189   
00190   myDefaultInteractorStyle = SVTK_InteractorStyle::New();
00191   myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
00192   myDefaultInteractorStyle->Delete();
00193   
00194   myRecorder = SVTK_Recorder::New();
00195   
00196   myRecorder->SetNbFPS( 17.3 );
00197   myRecorder->SetQuality( 100 );
00198   myRecorder->SetProgressiveMode( true );
00199   myRecorder->SetUseSkippedFrames( true );
00200   myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
00201   
00202   setCentralWidget(myInteractor);
00203   
00204   myAxesWidget = vtkPVAxesWidget::New();
00205   myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
00206   myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
00207   myAxesWidget->SetInteractor(myInteractor->GetDevice());
00208   myAxesWidget->SetEnabled(1);
00209   myAxesWidget->SetInteractive(0);
00210 
00211   vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
00212   anAxesActor->GetXAxisTipProperty()->SetColor(   1.0, 0.0, 0.0 );
00213   anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
00214   anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
00215   anAxesActor->GetYAxisTipProperty()->SetColor(   0.0, 1.0, 0.0 );
00216   anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
00217   anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
00218   anAxesActor->GetZAxisTipProperty()->SetColor(   0.0, 0.0, 1.0 );
00219   anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
00220   anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
00221 
00222   myView = new SVTK_View(this);
00223   Initialize(myView,theModel);
00224 
00225 
00226   myEventCallbackCommand->SetClientData(this);
00227   myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
00228   myEventCallbackCommand->Delete();
00229 
00230   GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished, 
00231                                                myEventCallbackCommand.GetPointer(), 0.0);
00232 
00233 
00234   
00235   myInteractor->getRenderWindow()->Render();
00236   setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
00237   onResetView();
00238 }
00239 
00243 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
00244                                  SVTK_ViewModelBase* theModel)
00245 {
00246   connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
00247           this,SLOT(onKeyPressed(QKeyEvent*)) );
00248   connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
00249           this,SLOT(onKeyReleased(QKeyEvent*)));
00250   connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
00251           this,SLOT(onMousePressed(QMouseEvent*)));
00252   connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
00253           this,SLOT(onMouseReleased(QMouseEvent*)));
00254   connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
00255           this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
00256   connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
00257           this,SLOT(onMouseMoving(QMouseEvent*)));
00258   connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
00259           this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
00260   connect(theView,SIGNAL(selectionChanged()),
00261           theModel,SLOT(onSelectionChanged()));
00262 }
00263 
00267 SVTK_ViewWindow::~SVTK_ViewWindow()
00268 {
00269   myRecorder->Delete();
00270   myAxesWidget->Delete();
00271 }
00272 
00273 
00277 SVTK_View* SVTK_ViewWindow::getView() 
00278 { 
00279   return myView; 
00280 }
00281 
00285 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
00286 {
00287   return GetInteractor()->getRenderWindow();
00288 }
00289 
00293 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
00294 {
00295   return myInteractor;
00296 }
00297 
00301 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
00302 {
00303   return myInteractor->GetDevice();
00304 }
00305 
00309 vtkRenderer* SVTK_ViewWindow::getRenderer() const
00310 {
00311   return GetInteractor()->getRenderer();
00312 }
00313 
00317 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
00318 {
00319   return GetInteractor()->GetRenderer();
00320 }
00321 
00325 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
00326 { 
00327   return GetInteractor()->GetSelector(); 
00328 }
00329 
00333 void SVTK_ViewWindow::onFrontView()
00334 {
00335   GetRenderer()->OnFrontView();
00336   Repaint();
00337   emit transformed( this );
00338 }
00339 
00343 void SVTK_ViewWindow::onBackView()
00344 {
00345   GetRenderer()->OnBackView();
00346   Repaint();
00347   emit transformed( this );
00348 }
00349 
00353 void SVTK_ViewWindow::onTopView()
00354 {
00355   GetRenderer()->OnTopView();
00356   Repaint();
00357   emit transformed( this );
00358 }
00359 
00363 void SVTK_ViewWindow::onBottomView()
00364 {
00365   GetRenderer()->OnBottomView();
00366   Repaint();
00367   emit transformed( this );
00368 }
00369 
00373 void SVTK_ViewWindow::onLeftView()
00374 {
00375   GetRenderer()->OnLeftView();
00376   Repaint();
00377   emit transformed( this );
00378 }
00379 
00383 void SVTK_ViewWindow::onRightView()
00384 {
00385   GetRenderer()->OnRightView();
00386   Repaint();
00387   emit transformed( this );
00388 }
00389 
00393 void SVTK_ViewWindow::onClockWiseView()
00394 {
00395   GetRenderer()->onClockWiseView();
00396   Repaint();
00397   emit transformed( this );
00398 }
00399 
00403 void SVTK_ViewWindow::onAntiClockWiseView()
00404 {
00405   GetRenderer()->onAntiClockWiseView();
00406   Repaint();
00407   emit transformed( this );
00408 }
00409 
00413 void SVTK_ViewWindow::onResetView()
00414 {
00415   GetRenderer()->OnResetView();
00416   Repaint();
00417   emit transformed( this );
00418 }
00419 
00423 void SVTK_ViewWindow::onFitAll()
00424 {
00425   GetRenderer()->OnFitAll();
00426   Repaint();
00427   emit transformed( this );
00428 }
00429 
00433 void SVTK_ViewWindow::onSelectionChanged()
00434 {
00435   myView->onSelectionChanged();
00436 }
00437 
00442 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
00443 {
00444   GetSelector()->SetSelectionMode(theMode);
00445 }
00446 
00450 Selection_Mode SVTK_ViewWindow::SelectionMode() const
00451 {
00452   return GetSelector()->SelectionMode();
00453 }
00454 
00458 void SVTK_ViewWindow::unHighlightAll() 
00459 {
00460   myView->unHighlightAll();
00461 }
00462 
00469 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO, 
00470                                 bool theIsHighlight, 
00471                                 bool theIsUpdate ) 
00472 {
00473   myView->highlight( theIO, theIsHighlight, theIsUpdate );
00474 }
00475 
00480 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) 
00481 {
00482   return myView->isInViewer( theIO );
00483 }
00484 
00489 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) 
00490 {
00491   return myView->isVisible( theIO );
00492 }
00493 
00498 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry) 
00499 {
00500   return myView->FindIObject(theEntry);
00501 }
00502 
00508 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
00509                               bool theImmediatly) 
00510 {
00511   myView->Display(theIO,theImmediatly);
00512 }
00513 
00519 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
00520                             bool theImmediatly) 
00521 {
00522   myView->Erase(theIO,theImmediatly);
00523 }
00524 
00529 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) 
00530 {
00531   myView->DisplayOnly(theIO);
00532 }
00533 
00537 void SVTK_ViewWindow::DisplayAll() 
00538 {
00539   myView->DisplayAll();
00540 }
00541 
00545 void SVTK_ViewWindow::EraseAll() 
00546 {
00547   myView->EraseAll();
00548 }
00549 
00554 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
00555 {
00556   Qtx::BackgroundData bg = background();
00557   bg.setColor( c );
00558   setBackground( bg );
00559 }
00560 
00564 QColor SVTK_ViewWindow::backgroundColor() const
00565 {
00566   return background().color();
00567 }
00568 
00573 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
00574 {
00575   bool ok = false;
00576 
00577   if ( bgData.isValid() ) {
00578     switch ( bgData.mode() ) {
00579     case Qtx::ColorBackground:
00580       {
00581        QColor c = bgData.color();
00582        if ( c.isValid() ) {
00583          // show solid-colored background
00584          getRenderer()->SetTexturedBackground( false );  // cancel texture mode
00585          getRenderer()->SetGradientBackground( false );  // cancel gradient mode
00586          getRenderer()->SetBackground( c.red()/255.0,
00587                                    c.green()/255.0,
00588                                    c.blue()/255.0 ); // set background color
00589          ok = true;
00590        }
00591        break;
00592       }
00593     case Qtx::SimpleGradientBackground:
00594       {
00595         QColor c1, c2;
00596         int type = bgData.gradient( c1, c2 );
00597         if ( c1.isValid() )
00598         {
00599           if ( !c2.isValid() )
00600             c2 = c1;
00601 
00602           // show two-color gradient background
00603           getRenderer()->SetTexturedBackground( false );    // cancel texture mode
00604           getRenderer()->SetGradientBackground( true );     // switch to gradient mode
00605 
00606           VTKViewer_OpenGLRenderer* aRenderer =
00607             VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
00608           if( aRenderer )
00609           {
00610             aRenderer->SetGradientType( type );
00611             aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
00612             aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
00613             ok = true;
00614           }
00615         }
00616         break;
00617       }
00618     case Qtx::CustomGradientBackground:
00619       {
00620        // NOT IMPLEMENTED YET
00621        getRenderer()->SetTexturedBackground( false );  // cancel texture mode
00622        getRenderer()->SetGradientBackground( false );  // cancel gradient mode
00623        // .........
00624        break;
00625       }
00626     default:
00627       break;
00628     }
00629     if ( bgData.isTextureShown() ) {
00630       QString fileName;
00631       int textureMode = bgData.texture( fileName );
00632       QFileInfo fi( fileName );
00633       if ( !fileName.isEmpty() && fi.exists() ) {
00634        // read texture from file
00635        QString extension = fi.suffix().toLower();
00636        vtkImageReader2* aReader = 0;
00637        if ( extension == "jpg" || extension == "jpeg" )
00638          aReader = vtkJPEGReader::New();
00639        else if ( extension == "bmp" )
00640          aReader = vtkBMPReader::New();
00641        else if ( extension == "tif" || extension == "tiff" )
00642          aReader = vtkTIFFReader::New();
00643        else if ( extension == "png" )
00644          aReader = vtkPNGReader::New();
00645        else if ( extension == "mhd" || extension == "mha" )
00646          aReader = vtkMetaImageReader::New();           
00647        if ( aReader ) {
00648          // create texture
00649          aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
00650          aReader->Update();   
00651          VTKViewer_Texture* aTexture = VTKViewer_Texture::New();          
00652          vtkImageMapToColors* aMap = 0;
00653          vtkAlgorithmOutput* anOutput;
00654          /*
00655          // special processing for BMP reader
00656          vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
00657          if ( aBMPReader ) {
00658          // Special processing for BMP file
00659          aBMPReader->SetAllow8BitBMP(1);
00660            
00661          aMap = vtkImageMapToColors::New();
00662          aMap->SetInputConnection( aBMPReader->GetOutputPort() );
00663          aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
00664          aMap->SetOutputFormatToRGB();
00665            
00666          anOutput = aMap->GetOutputPort();
00667          }
00668          else {
00669          }
00670          */
00671          anOutput = aReader->GetOutputPort( 0 );
00672          aTexture->SetInputConnection( anOutput );
00673          // set texture mode
00674          // VSR: Currently, VTK only supports Stretch mode, so below code will give
00675          // the same results for all modes
00676          switch ( textureMode ) {
00677          case Qtx::TileTexture:
00678            aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
00679            break;
00680          case Qtx::StretchTexture:
00681            aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
00682            break;
00683          case Qtx::CenterTexture:
00684            aTexture->SetPosition((int)VTKViewer_Texture::Centered);
00685          default:
00686            break;
00687          }
00688          // show textured background
00689          getRenderer()->SetTexturedBackground( true );
00690          getRenderer()->SetBackgroundTexture( aTexture );
00691          
00692          // clean-up resources
00693          if ( aMap )
00694            aMap->Delete();
00695          aReader->Delete();
00696          aTexture->Delete();
00697          ok = true;
00698        }
00699       }
00700     }
00701   }
00702   if ( ok )
00703     myBackground = bgData;
00704 }
00705 
00709 Qtx::BackgroundData SVTK_ViewWindow::background() const
00710 {
00711   return myBackground;
00712 }
00713 
00714 
00718 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
00719 {
00720   return GetInteractor()->GetInteractorStyle();
00721 }
00722 
00726 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
00727 {
00728   GetInteractor()->PushInteractorStyle(theStyle);
00729 }
00730 
00734 void SVTK_ViewWindow::PopInteractorStyle()
00735 {
00736   GetInteractor()->PopInteractorStyle();
00737 }
00738 
00742 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
00743 {
00744   if(theUpdateTrihedron) 
00745     GetRenderer()->OnAdjustTrihedron();
00746 
00747   GetInteractor()->update();
00748 
00749   SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
00750   if ( aStyle )
00751     aStyle->OnTimer();
00752 }
00753 
00757 void SVTK_ViewWindow::GetScale( double theScale[3] ) 
00758 {
00759   GetRenderer()->GetScale( theScale );
00760 }
00761 
00765 void SVTK_ViewWindow::SetScale( double theScale[3] ) 
00766 {
00767   GetRenderer()->SetScale( theScale );
00768   Repaint();
00769   emit transformed( this );
00770 }
00771 
00775 bool SVTK_ViewWindow::isTrihedronDisplayed()
00776 {
00777   return GetRenderer()->IsTrihedronDisplayed();
00778 }
00779 
00783 bool SVTK_ViewWindow::isCubeAxesDisplayed()
00784 {
00785   return GetRenderer()->IsCubeAxesDisplayed();
00786 }
00787 
00791 void SVTK_ViewWindow::onViewTrihedron()
00792 {
00793   GetRenderer()->OnViewTrihedron();
00794   Repaint();
00795 }
00796 
00800 void SVTK_ViewWindow::onViewCubeAxes()
00801 {
00802   GetRenderer()->OnViewCubeAxes();
00803   Repaint();
00804 }
00805 
00809 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
00810 {
00811   return GetRenderer()->GetTrihedron();
00812 }
00813 
00817 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
00818 {
00819   return GetRenderer()->GetCubeAxes();
00820 }
00821 
00825 vtkFloatingPointType SVTK_ViewWindow::GetTrihedronSize() const
00826 {
00827   return GetRenderer()->GetTrihedronSize();
00828 }
00829 
00834 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
00835 {
00836   activateProjectionMode( theMode );
00837 }
00838 
00839 
00843 void SVTK_ViewWindow::activateSetFocalPointGravity()
00844 {
00845   myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
00846 }
00847 
00851 void SVTK_ViewWindow::activateSetFocalPointSelected()
00852 {
00853   myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
00854 }
00855 
00859 void SVTK_ViewWindow::activateStartFocalPointSelection()
00860 {
00861   myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
00862 }
00863 
00864 void SVTK_ViewWindow::activateProjectionMode(int theMode)
00865 {
00866   if (theMode)
00867     toolMgr()->action( ProjectionModeId )->setChecked( true );
00868   else
00869     toolMgr()->action( ParallelModeId )->setChecked( true );
00870 }
00871 
00876 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
00877 {
00878   onSwitchInteractionStyle( theStyle==1 );
00879 }
00880 
00885 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
00886 {
00887   onSwitchZoomingStyle( theStyle==1 );
00888 }
00889 
00894 void SVTK_ViewWindow::SetDynamicPreSelection( bool theDynPreselection )
00895 {
00896   onSwitchDynamicPreSelection( theDynPreselection );
00897 }
00898 
00902 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
00903 {
00904   if (theOn) {
00905     // check if style is already set
00906     if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
00907     {
00908       // keep the same style extensions
00909       SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
00910       if ( aStyle ) {
00911         myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
00912         myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
00913       }
00914 
00915       PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
00916     }
00917   }
00918   else {
00919     // pop only key free  style
00920     if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
00921       PopInteractorStyle();
00922   }
00923 
00924   // update action state if method is called outside
00925   QtxAction* a = getAction( SwitchInteractionStyleId );
00926   if ( a->isChecked() != theOn ) a->setChecked( theOn );
00927 }
00928 
00932 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
00933 {
00934   if( myDefaultInteractorStyle.GetPointer() )
00935     myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
00936   if( myKeyFreeInteractorStyle.GetPointer() )
00937     myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
00938 
00939   // update action state if method is called outside
00940   QtxAction* a = getAction( SwitchZoomingStyleId );
00941   if ( a->isChecked() != theOn )
00942     a->setChecked( theOn );
00943 }
00944 
00948 void SVTK_ViewWindow::onSwitchDynamicPreSelection( bool theOn )
00949 {
00950   GetSelector()->SetDynamicPreSelection( theOn );
00951 
00952   // update action state if method is called outside
00953   QtxAction* a = getAction( SwitchDynamicPreselectionId );
00954   if ( a->isChecked() != theOn )
00955     a->setChecked( theOn );
00956 }
00957 
00963 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
00964 {
00965   if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
00966     ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
00967 }
00968 
00975 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1, 
00976                                            const int theBtn2,
00977                                            const int theBtn3)
00978 {
00979   int val = theBtn1;
00980   myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
00981   val = theBtn2;
00982   myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
00983   val = theBtn3;
00984   myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
00985 }
00986 
00992 void SVTK_ViewWindow::SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative)
00993 {
00994   GetRenderer()->SetTrihedronSize(theSize, theRelative);
00995   Repaint();
00996 }
00997 
01001 void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
01002 {
01003   GetRenderer()->AdjustActors();
01004   Repaint();
01005 }
01006 
01010 void SVTK_ViewWindow::onAdjustTrihedron()
01011 {   
01012   GetRenderer()->OnAdjustTrihedron();
01013 }
01014 
01018 void SVTK_ViewWindow::onAdjustCubeAxes()
01019 {   
01020   GetRenderer()->OnAdjustCubeAxes();
01021 }
01022 
01023 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
01024 {
01025   if ( otherViewWindow ) {
01026     bool blocked = blockSignals( true );
01027     doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
01028     blockSignals( blocked );
01029   }
01030 }
01031 
01035 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
01036 {
01037   emit keyPressed( this, event );
01038 }
01039 
01043 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
01044 {
01045   emit keyReleased( this, event );
01046 }
01047 
01051 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
01052 {
01053   emit mousePressed(this, event);
01054 }
01055 
01059 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
01060 {
01061   emit mouseReleased( this, event );
01062 }
01063 
01067 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
01068 {
01069   emit mouseMoving( this, event );
01070 }
01071 
01075 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
01076 {
01077   emit mouseDoubleClicked( this, event );
01078 }
01079 
01083 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, 
01084                                 bool theUpdate,
01085                                 bool theIsAdjustActors )
01086 {
01087   GetRenderer()->AddActor(theActor, theIsAdjustActors);
01088   if(theUpdate) 
01089     Repaint();
01090   emit actorAdded(theActor);
01091 }
01092 
01096 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, 
01097                                    bool theUpdate,
01098                                    bool theIsAdjustActors )
01099 {
01100   GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
01101   if(theUpdate) 
01102     Repaint();
01103   emit actorRemoved(theActor);
01104 }
01105 
01106 QImage SVTK_ViewWindow::dumpViewContent()
01107 {
01108   vtkRenderWindow* aWindow = getRenderWindow();
01109   int* aSize = aWindow->GetSize();
01110   int aWidth = aSize[0];
01111   int aHeight = aSize[1];
01112   
01113   OpenGLUtils_FrameBuffer aFrameBuffer;
01114   if( aFrameBuffer.init( aWidth, aHeight ) )
01115   {
01116     glPushAttrib( GL_VIEWPORT_BIT );
01117     glViewport( 0, 0, aWidth, aHeight );
01118     aFrameBuffer.bind();
01119 
01120     // draw scene
01121     aWindow->Render();
01122 
01123     aFrameBuffer.unbind();
01124     glPopAttrib();
01125 
01126     QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
01127 
01128     aFrameBuffer.bind();
01129     glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
01130     aFrameBuffer.unbind();
01131 
01132     anImage = anImage.rgbSwapped();
01133     anImage = anImage.mirrored();
01134     return anImage;
01135   }
01136 
01137   // if frame buffers are unsupported, use old functionality
01138   unsigned char *aData = 
01139     aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
01140   
01141   QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
01142 
01143   anImage = anImage.rgbSwapped();
01144   anImage = anImage.mirrored();
01145   return anImage;
01146 }
01147 
01151 QImage SVTK_ViewWindow::dumpView()
01152 {
01153   if( myDumpImage.isNull() )
01154     return dumpViewContent();
01155   
01156   RefreshDumpImage();
01157   return myDumpImage;
01158 }
01159 
01160 QString SVTK_ViewWindow::filter() const
01161 {
01162   return tr( "SVTK_IMAGE_FILES" );
01163 }
01164 
01165 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
01166 {
01167   if ( format != "PS" && format != "EPS" && format != "PDF" )
01168     return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
01169 
01170   SUIT_OverrideCursor wc;
01171 
01172   vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
01173   anExporter->SetRenderWindow(getRenderWindow());
01174 
01175   if ( format == "PS" ) {
01176     anExporter->SetFileFormatToPS();
01177     anExporter->CompressOff();
01178   }
01179 
01180   if ( format == "EPS" ) {
01181     anExporter->SetFileFormatToEPS();
01182     anExporter->CompressOff();
01183   }
01184 
01185   if ( format == "PDF" ) {
01186     anExporter->SetFileFormatToPDF();
01187   }
01188 
01189   QString aFilePrefix(fileName);
01190   QString anExtension(SUIT_Tools::extension(fileName));
01191   aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
01192   anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
01193   anExporter->Write();
01194   anExporter->Delete();
01195 
01196   return true;
01197 }
01198 
01202 void SVTK_ViewWindow::RefreshDumpImage()
01203 {
01204   myDumpImage = dumpViewContent();
01205 }
01206 
01210 void SVTK_ViewWindow::SetSelectionProp(const double& theRed, 
01211                                        const double& theGreen, 
01212                                        const double& theBlue, 
01213                                        const int& theWidth) 
01214 {
01215   myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
01216 }
01217 
01221 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed, 
01222                                           const double& theGreen, 
01223                                           const double& theBlue, 
01224                                           const int& theWidth) 
01225 {
01226   myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
01227 }
01228 
01232 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes, 
01233                                             const double& theTolItems,
01234                                             const double& theTolObjects)
01235 {
01236   myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
01237 }
01238 
01242 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
01243 {
01244   return (bool)myAxesWidget->GetEnabled();
01245 }
01246 
01250 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
01251 {
01252   myAxesWidget->SetEnabled( (int)theIsVisible );
01253 }
01254 
01259 bool SVTK_ViewWindow::action( const int accelAction  )
01260 {
01261   if ( accelAction == SUIT_Accel::ZoomFit )
01262     onFitAll();
01263   else {
01264     int anEvent = SVTK::convertAction( accelAction );
01265     GetInteractor()->InvokeEvent(anEvent, 0);
01266   }
01267   return true;
01268 }
01269 
01273 QtxAction* SVTK_ViewWindow::getAction( int id ) const
01274 {
01275   return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
01276 }
01277 
01278 
01279 // old visual parameters had 13 values.  New format added additional 
01280 // 76 values for graduated axes, so both numbers are processed.
01281 const int nNormalParams = 13;   // number of view windows parameters excluding graduated axes params
01282 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
01283 const int nTrihedronParams = 3; // number of parameters for Trihedron
01284 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
01285 
01288 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
01289 {
01290   //QString params;
01291   if ( !actor )
01292     return ;//params;
01293 
01294   // Name
01295   bool isVisible = actor->GetTitleVisibility();
01296   QString title ( actor->GetTitle() );
01297   vtkFloatingPointType color[ 3 ];
01298   int font = VTK_ARIAL;
01299   int bold = 0;
01300   int italic = 0;
01301   int shadow = 0;
01302 
01303   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
01304   if ( txtProp )
01305   {
01306     txtProp->GetColor( color );
01307     font = txtProp->GetFontFamily();
01308     bold = txtProp->GetBold();
01309     italic = txtProp->GetItalic();
01310     shadow = txtProp->GetShadow();
01311   }
01312   writer.writeStartElement("GraduatedAxis");
01313   writer.writeAttribute("Axis", theAxis);
01314 
01315   writer.writeStartElement("Title");
01316   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
01317   writer.writeAttribute("Text", title);
01318   writer.writeAttribute("Font", QString("%1").arg(font));
01319   writer.writeAttribute("Bold", QString("%1").arg(bold));
01320   writer.writeAttribute("Italic", QString("%1").arg(italic));
01321   writer.writeAttribute("Shadow", QString("%1").arg(shadow));
01322 
01323   writer.writeStartElement("Color");
01324   writer.writeAttribute("R", QString("%1").arg(color[0]));
01325   writer.writeAttribute("G", QString("%1").arg(color[1]));
01326   writer.writeAttribute("B", QString("%1").arg(color[2]));
01327   writer.writeEndElement();
01328   writer.writeEndElement();
01329 
01330   //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, 
01331   //              title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
01332 
01333   // Labels
01334   isVisible = actor->GetLabelVisibility();
01335   int labels = actor->GetNumberOfLabels();
01336   int offset = actor->GetTickOffset();
01337   font = VTK_ARIAL;
01338   bold = false;
01339   italic = false;
01340   shadow = false;
01341 
01342   txtProp = actor->GetLabelTextProperty();
01343   if ( txtProp )
01344   {
01345     txtProp->GetColor( color );
01346     font = txtProp->GetFontFamily();
01347     bold = txtProp->GetBold();
01348     italic = txtProp->GetItalic();
01349     shadow = txtProp->GetShadow();
01350   }
01351 
01352   writer.writeStartElement("Labels");
01353   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
01354   writer.writeAttribute("Number", QString("%1").arg(labels));
01355   writer.writeAttribute("Offset", QString("%1").arg(offset));
01356   writer.writeAttribute("Font", QString("%1").arg(font));
01357   writer.writeAttribute("Bold", QString("%1").arg(bold));
01358   writer.writeAttribute("Italic", QString("%1").arg(italic));
01359   writer.writeAttribute("Shadow", QString("%1").arg(shadow));
01360 
01361   writer.writeStartElement("Color");
01362   writer.writeAttribute("R", QString("%1").arg(color[0]));
01363   writer.writeAttribute("G", QString("%1").arg(color[1]));
01364   writer.writeAttribute("B", QString("%1").arg(color[2]));
01365   writer.writeEndElement();
01366   writer.writeEndElement();
01367   //  params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,  
01368   //                           color[0], color[1], color[2], font, bold, italic, shadow );
01369 
01370   // Tick marks
01371   isVisible = actor->GetTickVisibility();
01372   int length = actor->GetTickLength();
01373   writer.writeStartElement("TickMarks");
01374   writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
01375   writer.writeAttribute("Length", QString("%1").arg(length));
01376   writer.writeEndElement();
01377   
01378   //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
01379   
01380   writer.writeEndElement();
01381   //return params;
01382 }
01383 
01384 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
01385 {
01386   if ( !actor )
01387     return;
01388 
01389   do {
01390     reader.readNext();
01391   } while (!reader.isStartElement());
01392 
01393   // Read title params
01394   QXmlStreamAttributes aAttr = reader.attributes();
01395   bool isVisible = aAttr.value("isVisible").toString().toUShort();
01396   QString title = aAttr.value("Text").toString();
01397   int font = aAttr.value("Font").toString().toInt();
01398   int bold = aAttr.value("Bold").toString().toInt();
01399   int italic = aAttr.value("Italic").toString().toInt();
01400   int shadow = aAttr.value("Shadow").toString().toInt();
01401 
01402   //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
01403 
01404   do {
01405     reader.readNext();
01406   } while (!reader.isStartElement());
01407   
01408   // Read title color
01409   aAttr = reader.attributes();
01410 
01411   vtkFloatingPointType color[3];
01412   color[0] = aAttr.value("R").toString().toDouble();
01413   color[1] = aAttr.value("G").toString().toDouble();
01414   color[2] = aAttr.value("B").toString().toDouble();
01415   //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
01416 
01417   actor->SetTitleVisibility( isVisible );
01418   actor->SetTitle( title.toLatin1() );
01419   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
01420   if ( txtProp ) {
01421     txtProp->SetColor( color );
01422     txtProp->SetFontFamily( font );
01423     txtProp->SetBold( bold );
01424     txtProp->SetItalic( italic );
01425     txtProp->SetShadow( shadow );
01426   }
01427 
01428   // Labels
01429 
01430   do {
01431     reader.readNext();
01432   } while (!reader.isStartElement()); 
01433   // Read labels
01434   aAttr = reader.attributes();
01435   isVisible = aAttr.value("isVisible").toString().toUShort();
01436   int labels = aAttr.value("Number").toString().toInt();
01437   int offset = aAttr.value("Offset").toString().toInt();
01438   font = aAttr.value("Font").toString().toInt();
01439   bold = aAttr.value("Bold").toString().toInt();
01440   italic = aAttr.value("Italic").toString().toInt();
01441   shadow = aAttr.value("Shadow").toString().toInt();
01442 
01443   do {
01444     reader.readNext();
01445   } while (!reader.isStartElement()); 
01446   // Read Color
01447   aAttr = reader.attributes();
01448 
01449   color[0] = aAttr.value("R").toString().toDouble();
01450   color[1] = aAttr.value("G").toString().toDouble();
01451   color[2] = aAttr.value("B").toString().toDouble();
01452 
01453   actor->SetLabelVisibility( isVisible );
01454   actor->SetNumberOfLabels( labels );
01455   actor->SetTickOffset( offset );
01456   txtProp = actor->GetLabelTextProperty();
01457   if ( txtProp ) {
01458     txtProp->SetColor( color );
01459     txtProp->SetFontFamily( font );
01460     txtProp->SetBold( bold );
01461     txtProp->SetItalic( italic );
01462     txtProp->SetShadow( shadow );
01463   }
01464 
01465   // Tick Marks
01466   do {
01467     reader.readNext();
01468   } while (!reader.isStartElement()); 
01469   aAttr = reader.attributes();
01470 
01471   // retrieve and set tick marks properties
01472   isVisible = aAttr.value("isVisible").toString().toUShort();
01473   int length = aAttr.value("Length").toString().toInt();
01474   
01475   actor->SetTickVisibility( isVisible );
01476   actor->SetTickLength( length );
01477 }
01478 
01481 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
01482 {
01483   if ( !actor )
01484     return;
01485 
01486   QStringList paramsLst = params.split( '*' );
01487 
01488   if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
01489 
01490     // retrieve and set name parameters
01491     bool isVisible = paramsLst[2].toUShort();
01492     QString title = paramsLst[3];
01493     vtkFloatingPointType color[3];
01494     color[0] = paramsLst[4].toDouble();
01495     color[1] = paramsLst[5].toDouble();
01496     color[2] = paramsLst[6].toDouble();
01497     int font = paramsLst[7].toInt();
01498     int bold = paramsLst[8].toInt();
01499     int italic = paramsLst[9].toInt();
01500     int shadow = paramsLst[10].toInt();
01501 
01502     actor->SetTitleVisibility( isVisible );
01503     actor->SetTitle( title.toLatin1() );
01504     vtkTextProperty* txtProp = actor->GetTitleTextProperty();
01505     if ( txtProp ) {
01506       txtProp->SetColor( color );
01507       txtProp->SetFontFamily( font );
01508       txtProp->SetBold( bold );
01509       txtProp->SetItalic( italic );
01510       txtProp->SetShadow( shadow );
01511     }
01512 
01513     // retrieve and set lable parameters
01514     isVisible = paramsLst[12].toUShort();
01515     int labels = paramsLst[13].toInt();
01516     int offset = paramsLst[14].toInt();
01517     color[0] = paramsLst[15].toDouble();
01518     color[1] = paramsLst[16].toDouble();
01519     color[2] = paramsLst[17].toDouble();
01520     font = paramsLst[18].toInt();
01521     bold = paramsLst[19].toInt();
01522     italic = paramsLst[20].toInt();
01523     shadow = paramsLst[21].toInt();
01524 
01525     actor->SetLabelVisibility( isVisible );
01526     actor->SetNumberOfLabels( labels );
01527     actor->SetTickOffset( offset );
01528     txtProp = actor->GetLabelTextProperty();
01529     if ( txtProp ) {
01530       txtProp->SetColor( color );
01531       txtProp->SetFontFamily( font );
01532       txtProp->SetBold( bold );
01533       txtProp->SetItalic( italic );
01534       txtProp->SetShadow( shadow );
01535     }
01536 
01537     // retrieve and set tick marks properties
01538     isVisible = paramsLst[23].toUShort();
01539     int length = paramsLst[24].toInt();
01540 
01541     actor->SetTickVisibility( isVisible );
01542     actor->SetTickLength( length );
01543   }
01544 }
01545 
01548 QString SVTK_ViewWindow::getVisualParameters()
01549 {
01550   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
01551   
01552   // save position, focal point, viewUp, scale
01553   vtkCamera* camera = getRenderer()->GetActiveCamera();
01554   camera->GetPosition( pos );
01555   camera->GetFocalPoint( focalPnt );
01556   camera->GetViewUp( viewUp );
01557   parScale = camera->GetParallelScale();
01558   GetScale( scale );
01559 
01560   // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
01561   // view up values (3 digits), parallel scale (1 digit), scale (3 digits, 
01562   // Graduated axes parameters (X, Y, Z axes parameters)
01563   QString retStr;
01564   QXmlStreamWriter aWriter(&retStr);
01565   aWriter.setAutoFormatting(true);
01566 
01567   aWriter.writeStartDocument();
01568   aWriter.writeStartElement("ViewState");
01569 
01570   aWriter.writeStartElement("Position");
01571   aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
01572   aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
01573   aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
01574   aWriter.writeEndElement();
01575 
01576   aWriter.writeStartElement("FocalPoint");
01577   aWriter.writeAttribute("X", QString::number(focalPnt[0]));
01578   aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
01579   aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
01580   aWriter.writeEndElement();
01581 
01582   aWriter.writeStartElement("ViewUp");
01583   aWriter.writeAttribute("X", QString::number(viewUp[0]));
01584   aWriter.writeAttribute("Y", QString::number(viewUp[1]));
01585   aWriter.writeAttribute("Z", QString::number(viewUp[2]));
01586   aWriter.writeEndElement();
01587 
01588   aWriter.writeStartElement("ViewScale");
01589   aWriter.writeAttribute("Parallel", QString::number(parScale));
01590   aWriter.writeAttribute("X", QString::number(scale[0]));
01591   aWriter.writeAttribute("Y", QString::number(scale[1]));
01592   aWriter.writeAttribute("Z", QString::number(scale[2]));
01593   aWriter.writeEndElement();
01594 
01595   if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
01596     aWriter.writeStartElement("DisplayCubeAxis");
01597     aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
01598     aWriter.writeEndElement();
01599 
01600     getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
01601     getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
01602     getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
01603   }
01604 
01605   aWriter.writeStartElement("Trihedron");
01606   aWriter.writeAttribute("isShown",  QString( "%1" ).arg( isTrihedronDisplayed()));
01607   aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
01608   aWriter.writeEndElement();
01609 
01610   aWriter.writeStartElement("Background");
01611   aWriter.writeAttribute("Value",  QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
01612   aWriter.writeEndElement();
01613 
01614   aWriter.writeEndElement();
01615   aWriter.writeEndDocument();
01616 
01617   return retStr;
01618 }
01619 
01623 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
01624 {
01625   //printf("#### %s\n", qPrintable(parameters));
01626   SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
01627   if ( anInteractor->isVisible() ) {
01628     doSetVisualParameters( parameters ); 
01629   }
01630   else {
01631     myVisualParams = parameters;
01632     anInteractor->installEventFilter(this);
01633   }
01634 }
01635 
01639 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
01640 {
01641   
01642   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
01643 
01644   QXmlStreamReader aReader(parameters);
01645   SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
01646 
01647   while(!aReader.atEnd()) {
01648     aReader.readNext();
01649     if (aReader.isStartElement()) {
01650       QXmlStreamAttributes aAttr = aReader.attributes();
01651       //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
01652       if (aReader.name() == "Position") {       
01653         pos[0] = aAttr.value("X").toString().toDouble();
01654         pos[1] = aAttr.value("Y").toString().toDouble();
01655         pos[2] = aAttr.value("Z").toString().toDouble();
01656         //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
01657       }
01658       else if (aReader.name() == "FocalPoint") {
01659         focalPnt[0] = aAttr.value("X").toString().toDouble();
01660         focalPnt[1] = aAttr.value("Y").toString().toDouble();
01661         focalPnt[2] = aAttr.value("Z").toString().toDouble();
01662         //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
01663       }
01664       else if (aReader.name() == "ViewUp") {
01665         viewUp[0] = aAttr.value("X").toString().toDouble();
01666         viewUp[1] = aAttr.value("Y").toString().toDouble();
01667         viewUp[2] = aAttr.value("Z").toString().toDouble();
01668         //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
01669       }
01670       else if (aReader.name() == "ViewScale") {
01671         parScale = aAttr.value("Parallel").toString().toDouble();
01672         scale[0] = aAttr.value("X").toString().toDouble();
01673         scale[1] = aAttr.value("Y").toString().toDouble();
01674         scale[2] = aAttr.value("Z").toString().toDouble();
01675         //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
01676       } 
01677       else if (aReader.name() == "DisplayCubeAxis") {
01678        if ( !baseParamsOnly ) {
01679          if (aAttr.value("Show") == "0")
01680            gradAxesActor->VisibilityOff();
01681          else
01682            gradAxesActor->VisibilityOn();
01683        }
01684       }
01685       else if (aReader.name() == "GraduatedAxis") {
01686        if ( !baseParamsOnly ) {
01687          if(aAttr.value("Axis") == "X") 
01688            setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
01689          else if(aAttr.value("Axis") == "Y")
01690            setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
01691          else if(aAttr.value("Axis") == "Z")
01692            setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
01693        }
01694       } 
01695       else if (aReader.name() == "Trihedron") {
01696        if ( !baseParamsOnly ) {
01697          if (aAttr.value("isShown") == "0")
01698            GetTrihedron()->VisibilityOff();
01699          else
01700            GetTrihedron()->VisibilityOn();
01701          SetTrihedronSize(aAttr.value("Size").toString().toDouble());
01702        }
01703       }
01704       else if (aReader.name() == "Background") {
01705        if ( !baseParamsOnly ) {
01706          setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
01707        }
01708       }
01709     }
01710   }
01711   if (!aReader.hasError()) {
01712     vtkCamera* camera = getRenderer()->GetActiveCamera();
01713     camera->SetPosition( pos );
01714     camera->SetFocalPoint( focalPnt );
01715     camera->SetViewUp( viewUp );
01716     camera->SetParallelScale( parScale );
01717     GetRenderer()->SetScale( scale );
01718     //SetScale( scale );
01719   }
01720   else {
01721     QStringList paramsLst = parameters.split( '*' );
01722     if ( paramsLst.size() >= nNormalParams ) {
01723       // 'reading' list of parameters
01724       pos[0] = paramsLst[0].toDouble();
01725       pos[1] = paramsLst[1].toDouble();
01726       pos[2] = paramsLst[2].toDouble();
01727       focalPnt[0] = paramsLst[3].toDouble();
01728       focalPnt[1] = paramsLst[4].toDouble();
01729       focalPnt[2] = paramsLst[5].toDouble();
01730       viewUp[0] = paramsLst[6].toDouble();
01731       viewUp[1] = paramsLst[7].toDouble();
01732       viewUp[2] = paramsLst[8].toDouble();
01733       parScale = paramsLst[9].toDouble();
01734       scale[0] = paramsLst[10].toDouble();
01735       scale[1] = paramsLst[11].toDouble();
01736       scale[2] = paramsLst[12].toDouble();
01737       
01738       // applying parameters
01739       vtkCamera* camera = getRenderer()->GetActiveCamera();
01740       camera->SetPosition( pos );
01741       camera->SetFocalPoint( focalPnt );
01742       camera->SetViewUp( viewUp );
01743       camera->SetParallelScale( parScale );
01744       GetRenderer()->SetScale( scale );
01745       //SetScale( scale );
01746       
01747       // apply graduated axes parameters
01748       if ( !baseParamsOnly ) {
01749        SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
01750        if ( gradAxesActor && paramsLst.size() == nAllParams ) {
01751          int i = nNormalParams+1, j = i + nGradAxisParams - 1;
01752          ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
01753          i = j + 1; j += nGradAxisParams;
01754          ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); 
01755          i = j + 1; j += nGradAxisParams;
01756          ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); 
01757         
01758          if ( paramsLst[13].toUShort() )
01759            gradAxesActor->VisibilityOn();
01760          else
01761            gradAxesActor->VisibilityOff();
01762        }
01763        else if ( paramsLst.size() == nAllParams ) {
01764          if ( paramsLst[90].toUShort() )
01765            GetTrihedron()->VisibilityOn();
01766          else
01767            GetTrihedron()->VisibilityOff();
01768         
01769          SetTrihedronSize(paramsLst[91].toDouble());
01770        }
01771       }
01772     }
01773   }
01774   Repaint();
01775 }
01776 
01777 
01781 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
01782 {
01783   if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
01784     SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
01785     if ( anInteractor->isVisible() ) {
01786       doSetVisualParameters( myVisualParams );
01787       anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
01788     }
01789   }
01790   return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
01791 }
01792 
01793 
01797 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
01798 {
01799   if(theIsActivate){
01800     mySetRotationPointDlg->addObserver();
01801     if ( mySetRotationPointDlg->IsFirstShown() )
01802       activateSetRotationGravity();
01803     mySetRotationPointDlg->show();
01804   }else
01805     mySetRotationPointDlg->hide();
01806 }
01807 
01811 void SVTK_ViewWindow::activateSetRotationGravity()
01812 {
01813   myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
01814 }
01815 
01819 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
01820 {
01821   myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
01822 }
01823 
01827 void SVTK_ViewWindow::activateStartPointSelection()
01828 {
01829   myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
01830 }
01831 
01835 void SVTK_ViewWindow::onPerspectiveMode()
01836 {
01837   bool anIsParallelMode = toolMgr()->action( ParallelModeId )->isChecked();
01838 
01839   // advanced zooming is not available in perspective mode
01840   if( QtxAction* anAction = getAction( SwitchZoomingStyleId ) )
01841     anAction->setEnabled( anIsParallelMode );
01842 
01843   vtkCamera* aCamera = getRenderer()->GetActiveCamera();
01844   aCamera->SetParallelProjection(anIsParallelMode);
01845   GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
01846 }
01847 
01848 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
01849 {
01850   myEventDispatcher = theDispatcher;
01851 }
01852 
01856 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
01857 {
01858   QtxAction* anAction;
01859   QtxActionToolMgr* mgr = toolMgr();
01860 
01861   // Dump view
01862   anAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
01863                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
01864                            tr( "MNU_DUMP_VIEW" ), 0, this);
01865   anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
01866   connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
01867   mgr->registerAction( anAction, DumpId );
01868 
01869   // FitAll
01870   anAction = new QtxAction(tr("MNU_FITALL"), 
01871                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
01872                            tr( "MNU_FITALL" ), 0, this);
01873   anAction->setStatusTip(tr("DSC_FITALL"));
01874   connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
01875   mgr->registerAction( anAction, FitAllId );
01876 
01877   // FitRect
01878   anAction = new QtxAction(tr("MNU_FITRECT"), 
01879                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
01880                            tr( "MNU_FITRECT" ), 0, this);
01881   anAction->setStatusTip(tr("DSC_FITRECT"));
01882   connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
01883   mgr->registerAction( anAction, FitRectId );
01884 
01885   // Zoom
01886   anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
01887                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
01888                            tr( "MNU_ZOOM_VIEW" ), 0, this);
01889   anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
01890   connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
01891   mgr->registerAction( anAction, ZoomId );
01892 
01893   // Panning
01894   anAction = new QtxAction(tr("MNU_PAN_VIEW"), 
01895                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
01896                            tr( "MNU_PAN_VIEW" ), 0, this);
01897   anAction->setStatusTip(tr("DSC_PAN_VIEW"));
01898   connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
01899   mgr->registerAction( anAction, PanId );
01900 
01901   // Global Panning
01902   anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), 
01903                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
01904                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
01905   anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
01906   connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
01907   mgr->registerAction( anAction, GlobalPanId );
01908 
01909   // Change rotation point
01910   anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), 
01911                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
01912                            tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
01913   anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
01914   anAction->setCheckable(true);
01915   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
01916   mgr->registerAction( anAction, ChangeRotationPointId );
01917 
01918   // Rotation
01919   anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), 
01920                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
01921                            tr( "MNU_ROTATE_VIEW" ), 0, this);
01922   anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
01923   connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
01924   mgr->registerAction( anAction, RotationId );
01925 
01926   // Projections
01927   anAction = new QtxAction(tr("MNU_FRONT_VIEW"), 
01928                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
01929                            tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
01930   anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
01931   connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
01932   this->addAction(anAction);
01933   mgr->registerAction( anAction, FrontId );
01934 
01935   anAction = new QtxAction(tr("MNU_BACK_VIEW"), 
01936                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
01937                            tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
01938   anAction->setStatusTip(tr("DSC_BACK_VIEW"));
01939   connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
01940   this->addAction(anAction);
01941   mgr->registerAction( anAction, BackId );
01942 
01943   anAction = new QtxAction(tr("MNU_TOP_VIEW"), 
01944                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
01945                            tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
01946   anAction->setStatusTip(tr("DSC_TOP_VIEW"));
01947   connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
01948   this->addAction(anAction);
01949   mgr->registerAction( anAction, TopId );
01950 
01951   anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), 
01952                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
01953                            tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
01954   anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
01955   connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
01956   this->addAction(anAction);
01957   mgr->registerAction( anAction, BottomId );
01958 
01959   anAction = new QtxAction(tr("MNU_LEFT_VIEW"), 
01960                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
01961                            tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
01962   anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
01963   connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
01964   this->addAction(anAction);
01965   mgr->registerAction( anAction, LeftId );
01966 
01967   anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), 
01968                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
01969                            tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
01970   anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
01971   connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
01972   this->addAction(anAction);
01973   mgr->registerAction( anAction, RightId );
01974 
01975   // rotate anticlockwise
01976   anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
01977                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
01978                            tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
01979   anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
01980   connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
01981   this->addAction(anAction);
01982   mgr->registerAction( anAction, AntiClockWiseId );
01983 
01984   // rotate clockwise
01985   anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
01986                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
01987                            tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
01988   anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
01989   connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
01990   this->addAction(anAction);
01991   mgr->registerAction( anAction, ClockWiseId );
01992 
01993   // Reset
01994   anAction = new QtxAction(tr("MNU_RESET_VIEW"), 
01995                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
01996                            tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
01997   anAction->setStatusTip(tr("DSC_RESET_VIEW"));
01998   connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
01999   this->addAction(anAction);
02000   mgr->registerAction( anAction, ResetId );
02001 
02002   // onViewTrihedron: Shows - Hides Trihedron
02003   anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
02004                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
02005                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
02006   anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
02007   connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
02008   mgr->registerAction( anAction, ViewTrihedronId );
02009 
02010   // onNonIsometric: Manage non-isometric params
02011   anAction = new QtxAction(tr("MNU_SVTK_SCALING"), 
02012                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
02013                            tr( "MNU_SVTK_SCALING" ), 0, this);
02014   anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
02015   anAction->setCheckable(true);
02016   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
02017   mgr->registerAction( anAction, NonIsometric );
02018 
02019   // onGraduatedAxes: Manage graduated axes params
02020   anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"), 
02021                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
02022                            tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
02023   anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
02024   anAction->setCheckable(true);
02025   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
02026   mgr->registerAction( anAction, GraduatedAxes );
02027 
02028   // onGraduatedAxes: Manage graduated axes params
02029   anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"), 
02030                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
02031                            tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
02032   anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
02033   anAction->setCheckable(true);
02034   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
02035   mgr->registerAction( anAction, UpdateRate );
02036 
02037   // Set perspective mode group
02038   anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"), 
02039                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
02040                            tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
02041   anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
02042   anAction->setCheckable(true);
02043   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
02044   mgr->registerAction( anAction, ParallelModeId );
02045 
02046   anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"), 
02047                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
02048                            tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
02049   anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
02050   anAction->setCheckable(true);
02051   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
02052   mgr->registerAction( anAction, ProjectionModeId );
02053 
02054   QActionGroup* aPerspectiveGroup = new QActionGroup( this );
02055   aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
02056   aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
02057 
02058   // View Parameters
02059   anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), 
02060                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
02061                            tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
02062   anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
02063   anAction->setCheckable(true);
02064   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
02065   mgr->registerAction( anAction, ViewParametersId );
02066 
02067   // Synchronize View 
02068   anAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"), 
02069                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SYNCHRONIZE" ) ),
02070                            tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this);
02071   anAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
02072   anAction->setMenu( new QMenu( this ) );
02073   anAction->setCheckable(true);
02074   connect(anAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
02075   connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onSynchronizeView(bool)));
02076   mgr->registerAction( anAction, SynchronizeId );
02077 
02078   // Switch between interaction styles
02079   anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"), 
02080                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
02081                            tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
02082   anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
02083   anAction->setCheckable(true);
02084   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
02085   mgr->registerAction( anAction, SwitchInteractionStyleId );
02086 
02087   // Switch between zooming styles
02088   anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"), 
02089                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
02090                            tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
02091   anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
02092   anAction->setCheckable(true);
02093   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
02094   mgr->registerAction( anAction, SwitchZoomingStyleId );
02095 
02096   // Turn on/off dynamic pre-selection
02097   anAction = new QtxAction(tr("MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH"), 
02098                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH" ) ),
02099                            tr( "MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH" ), 0, this);
02100   anAction->setStatusTip(tr("DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH"));
02101   anAction->setCheckable(true);
02102   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchDynamicPreSelection(bool)));
02103   mgr->registerAction( anAction, SwitchDynamicPreselectionId );
02104 
02105   // Start recording
02106   myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), 
02107                                 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
02108                                 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
02109   myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
02110   connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
02111   mgr->registerAction( myStartAction, StartRecordingId );
02112 
02113   // Play recording
02114   myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"), 
02115                                theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
02116                                tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
02117   myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
02118   myPlayAction->setEnabled( false );
02119   connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
02120   mgr->registerAction( myPlayAction, PlayRecordingId );
02121 
02122   // Pause recording
02123   myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"), 
02124                                 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
02125                                 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
02126   myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
02127   myPauseAction->setEnabled( false );
02128   connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
02129   mgr->registerAction( myPauseAction, PauseRecordingId );
02130 
02131   // Stop recording
02132   myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"), 
02133                                theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
02134                                tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
02135   myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
02136   myStopAction->setEnabled( false );
02137   connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
02138   mgr->registerAction( myStopAction, StopRecordingId );
02139 }
02140 
02144 void SVTK_ViewWindow::createToolBar()
02145 {
02146   QtxActionToolMgr* mgr = toolMgr();
02147   
02148   mgr->append( DumpId, myToolBar );
02149   mgr->append( SwitchInteractionStyleId, myToolBar );
02150   mgr->append( SwitchZoomingStyleId, myToolBar );
02151   mgr->append( SwitchDynamicPreselectionId, myToolBar );
02152   mgr->append( ViewTrihedronId, myToolBar );
02153 
02154   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
02155   aScaleAction->insertAction( getAction( FitAllId ) );
02156   aScaleAction->insertAction( getAction( FitRectId ) );
02157   aScaleAction->insertAction( getAction( ZoomId ) );
02158   mgr->append( aScaleAction, myToolBar );
02159 
02160   QtxMultiAction* aPanningAction = new QtxMultiAction( this );
02161   aPanningAction->insertAction( getAction( PanId ) );
02162   aPanningAction->insertAction( getAction( GlobalPanId ) );
02163   mgr->append( aPanningAction, myToolBar );
02164 
02165   mgr->append( ChangeRotationPointId, myToolBar );
02166 
02167   mgr->append( RotationId, myToolBar );
02168 
02169   QtxMultiAction* aViewsAction = new QtxMultiAction( this );
02170   aViewsAction->insertAction( getAction( FrontId ) );
02171   aViewsAction->insertAction( getAction( BackId ) );
02172   aViewsAction->insertAction( getAction( TopId ) );
02173   aViewsAction->insertAction( getAction( BottomId ) );
02174   aViewsAction->insertAction( getAction( LeftId ) );
02175   aViewsAction->insertAction( getAction( RightId ) );
02176   mgr->append( aViewsAction, myToolBar );
02177 
02178   mgr->append( AntiClockWiseId, myToolBar );
02179   mgr->append( ClockWiseId, myToolBar );
02180 
02181   mgr->append( ResetId, myToolBar );
02182 
02183   mgr->append( UpdateRate, myToolBar );
02184   mgr->append( NonIsometric, myToolBar );
02185   mgr->append( GraduatedAxes, myToolBar );
02186 
02187   mgr->append( ViewParametersId, myToolBar );
02188   mgr->append( SynchronizeId, myToolBar );
02189 
02190   mgr->append( toolMgr()->separator(), myToolBar );
02191 
02192   mgr->append( ParallelModeId, myToolBar );
02193   mgr->append( ProjectionModeId, myToolBar );
02194 
02195   mgr->append( StartRecordingId, myRecordingToolBar );
02196   mgr->append( PlayRecordingId, myRecordingToolBar );
02197   mgr->append( PauseRecordingId, myRecordingToolBar );
02198   mgr->append( StopRecordingId, myRecordingToolBar );
02199 }
02200 
02201 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
02202 {
02203   if(theIsActivate){
02204     myUpdateRateDlg->Update();
02205     myUpdateRateDlg->show();
02206   }else
02207     myUpdateRateDlg->hide();
02208 }
02209 
02210 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
02211 {
02212   if(theIsActivate){
02213     myNonIsometricDlg->Update();
02214     myNonIsometricDlg->show();
02215   }else
02216     myNonIsometricDlg->hide();
02217 }
02218 
02219 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
02220 {
02221   if(theIsActivate){
02222     myCubeAxesDlg->Update();
02223     myCubeAxesDlg->show();
02224   }else
02225     myCubeAxesDlg->hide();
02226 }
02227 
02231 void SVTK_ViewWindow::activateRotation()
02232 {
02233   myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
02234 }
02235 
02236 
02240 void SVTK_ViewWindow::activatePanning()
02241 {
02242   myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
02243 }
02244 
02248 void SVTK_ViewWindow::activateZoom()
02249 {
02250   myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
02251 }
02252 
02256 void SVTK_ViewWindow::activateWindowFit()
02257 {
02258   myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
02259 }
02260 
02264 void SVTK_ViewWindow::activateGlobalPanning()
02265 {
02266   myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
02267 }
02268 
02269 void SVTK_ViewWindow::onStartRecording()
02270 {
02271   myRecorder->CheckExistAVIMaker();
02272   if (myRecorder->ErrorStatus()) {
02273     SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
02274   }
02275   else {
02276     SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
02277 
02278     if( !aRecorderDlg->exec() )
02279       return;
02280 
02281     myStartAction->setEnabled( false );
02282     myPlayAction->setEnabled( false );
02283     myPauseAction->setEnabled( true );
02284     myStopAction->setEnabled( true );
02285 
02286     // to prevent resizing the window while recording
02287     myPreRecordingMinSize = minimumSize();
02288     myPreRecordingMaxSize = maximumSize();
02289     setFixedSize( size() );
02290 
02291     myRecorder->Record();
02292   }
02293 }
02294 
02295 void SVTK_ViewWindow::onPlayRecording()
02296 {
02297   myStartAction->setEnabled( false );
02298   myPlayAction->setEnabled( false );
02299   myPauseAction->setEnabled( true );
02300   myStopAction->setEnabled( true );
02301 
02302   myRecorder->Pause();
02303 }
02304 
02305 void SVTK_ViewWindow::onPauseRecording()
02306 {
02307   myStartAction->setEnabled( false );
02308   myPlayAction->setEnabled( true );
02309   myPauseAction->setEnabled( false );
02310   myStopAction->setEnabled( true );
02311 
02312   myRecorder->Pause();
02313 }
02314 
02315 void SVTK_ViewWindow::onStopRecording()
02316 {
02317   myStartAction->setEnabled( true );
02318   myPlayAction->setEnabled( false );
02319   myPauseAction->setEnabled( false );
02320   myStopAction->setEnabled( false );
02321 
02322   myRecorder->Stop();
02323 
02324   setMinimumSize( myPreRecordingMinSize );
02325   setMaximumSize( myPreRecordingMaxSize );
02326 }
02327 
02331 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
02332 {
02333   GetInteractor()->InvokeEvent(theEvent,theCallData);
02334 }
02335 
02339 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
02340 {
02341   if(theIsActivate){
02342     myViewParameterDlg->addObserver();
02343     myViewParameterDlg->show();
02344   }else
02345     myViewParameterDlg->hide();
02346 }
02347 
02351 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent ) 
02352 {
02353   emit Show( theEvent );
02354 }
02355 
02359 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent ) 
02360 {
02361   emit Hide( theEvent );
02362 }
02363 
02364 void SVTK_ViewWindow::synchronizeView( SVTK_ViewWindow* viewWindow, int id )
02365 {
02366   SVTK_ViewWindow* otherViewWindow = 0;
02367   QList<SVTK_ViewWindow*> compatibleViews;
02368 
02369   bool isSync = viewWindow->toolMgr()->action( SynchronizeId )->isChecked();
02370 
02371   int vwid = viewWindow->getId();
02372   
02373   SUIT_Application* app = SUIT_Session::session()->activeApplication();
02374   if ( !app ) return;
02375 
02376   QList<SUIT_ViewManager*> wmlist;
02377   app->viewManagers( viewWindow->getViewManager()->getType(), wmlist );
02378 
02379   foreach( SUIT_ViewManager* wm, wmlist ) {
02380     QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
02381 
02382     foreach( SUIT_ViewWindow* vw, vwlist ) {
02383       SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
02384       if ( !vtkVW ) continue;
02385       if ( vtkVW->getId() == id ) 
02386        otherViewWindow = vtkVW;
02387       else if ( vtkVW != viewWindow )
02388        compatibleViews.append( vtkVW );
02389     }
02390   }
02391 
02392   if ( isSync && id ) {
02393     // remove all possible disconnections
02394     foreach( SVTK_ViewWindow* vw, compatibleViews ) {
02395       // disconnect target view
02396       vw->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), viewWindow, SLOT( synchronize( SVTK_ViewPort* ) ) );
02397       viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), vw, SLOT( synchronize( SVTK_ViewPort* ) ) );
02398       if ( otherViewWindow ) {
02399        // disconnect source view
02400        vw->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewPort* ) ) );
02401        otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), vw, SLOT( synchronize( SVTK_ViewPort* ) ) );
02402       }
02403       QAction* a = vw->toolMgr()->action( SynchronizeId );
02404       if ( a ) {
02405        int anid = a->data().toInt();
02406        if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
02407          bool blocked = a->blockSignals( true );
02408          a->setChecked( false );
02409          a->blockSignals( blocked );
02410        }
02411       }
02412     }
02413     if ( otherViewWindow ) {
02414       // reconnect source and target view
02415       otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), viewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
02416       viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
02417       otherViewWindow->connect( viewWindow, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( synchronize( SVTK_ViewWindow* ) ) );
02418       viewWindow->connect( otherViewWindow, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( synchronize( SVTK_ViewWindow* ) ) );
02419       // synchronize target view with source view
02420       viewWindow->doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
02421       viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
02422       otherViewWindow->toolMgr()->action( SynchronizeId )->setData( viewWindow->getId() );
02423       if ( !otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
02424        bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
02425        otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( true );
02426        otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
02427       }
02428     }
02429   }
02430   else if ( otherViewWindow ) {
02431     // reconnect source and target view
02432     otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), viewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
02433     viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
02434     viewWindow->doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
02435     viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
02436     if ( otherViewWindow->toolMgr()->action( SynchronizeId )->data().toInt() == viewWindow->getId() && otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
02437       bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
02438       otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( false );
02439       otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
02440     }
02441   }
02442 }
02443 
02447 void SVTK_ViewWindow::onSynchronizeView(bool checked)
02448 {
02449   QAction* a = qobject_cast<QAction*>( sender() );
02450   if ( a ) {
02451     synchronizeView( this, a->data().toInt() );
02452   }
02453 }
02454 
02458 void SVTK_ViewWindow::updateSyncViews()
02459 {
02460   QAction* anAction = toolMgr()->action( SynchronizeId );
02461   if ( anAction && anAction->menu() ) {
02462     int currentId = anAction->data().toInt();
02463     anAction->menu()->clear();
02464     SUIT_Application* app = SUIT_Session::session()->activeApplication();
02465     if ( app ) { 
02466       QList<SUIT_ViewManager*> wmlist;
02467       app->viewManagers( getViewManager()->getType(), wmlist );
02468       foreach( SUIT_ViewManager* wm, wmlist ) {
02469        QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
02470        foreach ( SUIT_ViewWindow* vw, vwlist ) {
02471          SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
02472          if ( !vtkVW || vtkVW == this ) continue;
02473          QAction* a = anAction->menu()->addAction( vtkVW->windowTitle() );
02474           if ( vtkVW->getId() == currentId ) {
02475             QFont f = a->font();
02476            f.setBold( true );
02477            a->setFont( f );
02478          }
02479          a->setData( vtkVW->getId() );
02480          connect( a, SIGNAL( triggered(bool) ), this, SLOT( onSynchronizeView(bool) ) );
02481        }
02482       }
02483     }
02484     if ( anAction->menu()->actions().isEmpty() ) {
02485       anAction->setData( 0 );
02486       anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
02487     }
02488   }
02489 }
02490 
02491 
02495 void SVTK_ViewWindow::emitTransformed() {
02496   transformed(this);
02497 }
02498 
02502 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
02503                                 unsigned long theEvent,
02504                                 void* theClientData,
02505                                 void* theCallData)
02506 {
02507   SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
02508   if(self)
02509     self->emitTransformed();
02510 }