1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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"
32 #include "SALOME_Actor.h"
38 #include <QSignalMapper>
39 #include <QXmlStreamWriter>
40 #include <QXmlStreamReader>
41 #include <QXmlStreamAttributes>
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>
63 #include "QtxAction.h"
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"
77 #include "VTKViewer_Utilities.h"
78 #include "VTKViewer_Trihedron.h"
80 #include "SVTK_View.h"
81 #include "SVTK_Selector.h"
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"
96 #include "salomevtkPVAxesWidget.h"
97 #include "salomevtkPVAxesActor.h"
99 #include "SALOME_ListIO.hxx"
101 #include "VTKViewer_Algorithm.h"
102 #include "SVTK_Functor.h"
104 #include <OpenGLUtils_FrameBuffer.h>
110 int convertAction( const int accelAction )
112 switch ( accelAction ) {
113 case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
114 case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
115 case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
116 case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
117 case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
118 case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
119 case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
120 case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
121 case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
122 case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
131 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
132 SUIT_ViewWindow(theDesktop),
134 myDumpImage(QImage()),
135 myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
136 myEventCallbackCommand(vtkCallbackCommand::New())
138 setWindowFlags( windowFlags() & ~Qt::Window );
139 // specific of vtkSmartPointer
140 myKeyFreeInteractorStyle->Delete();
144 To initialize #SVTK_ViewWindow instance
146 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
149 myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
151 SVTK_Selector* aSelector = SVTK_Selector::New();
152 int aPreselectionMode = SUIT_Session::session()->resourceMgr()->
153 integerValue( "VTKViewer", "preselection", Standard_Preselection );
154 aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection );
155 aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled );
156 bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
157 booleanValue( "VTKViewer", "enable_selection", true );
158 aSelector->SetSelectionEnabled( isSelectionEnabled );
160 SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
161 aDevice->SetRenderWidget(myInteractor);
162 aDevice->SetSelector(aSelector);
164 SVTK_Renderer* aRenderer = SVTK_Renderer::New();
165 aRenderer->Initialize(aDevice,aSelector);
167 myInteractor->Initialize(aDevice,aRenderer,aSelector);
173 myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant)
174 QString( "VTKViewerViewOperations" ), // name (language-independant)
175 false ); // disable floatable toolbar
177 myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant)
178 QString( "VTKRecordingOperations" ), // name (language-independant)
179 false ); // disable floatable toolbar
181 createActions( SUIT_Session::session()->resourceMgr() );
184 SetEventDispatcher(myInteractor->GetDevice());
185 myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
186 myInteractor->setFocusPolicy(Qt::StrongFocus);
187 myInteractor->setFocus();
188 bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()->
189 booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
190 myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
191 setFocusProxy(myInteractor);
193 myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
194 myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
195 myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
196 myCubeAxesDlg->initialize();
197 mySetRotationPointDlg = new SVTK_SetRotationPointDlg
198 ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
199 myViewParameterDlg = new SVTK_ViewParameterDlg
200 ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
202 myDefaultInteractorStyle = SVTK_InteractorStyle::New();
203 myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
204 myDefaultInteractorStyle->Delete();
206 myRecorder = SVTK_Recorder::New();
208 myRecorder->SetNbFPS( 17.3 );
209 myRecorder->SetQuality( 100 );
210 myRecorder->SetProgressiveMode( true );
211 myRecorder->SetUseSkippedFrames( true );
212 myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
214 setCentralWidget(myInteractor);
216 myAxesWidget = salomevtk::vtkPVAxesWidget::New();
217 myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
218 myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
219 myAxesWidget->SetInteractor(myInteractor->GetDevice());
220 myAxesWidget->SetEnabled(1);
221 myAxesWidget->SetInteractive(0);
223 salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
224 anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 );
225 anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
226 anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
227 anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 );
228 anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
229 anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
230 anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 );
231 anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
232 anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
234 myView = new SVTK_View(this);
235 Initialize(myView,theModel);
238 myEventCallbackCommand->SetClientData(this);
239 myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
240 myEventCallbackCommand->Delete();
242 GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
243 myEventCallbackCommand.GetPointer(), 0.0);
244 myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
245 myEventCallbackCommand.GetPointer(), 0.0);
249 myInteractor->getRenderWindow()->Render();
250 setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
255 To initialize #SVTK_ViewWindow instance
257 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
258 SVTK_ViewModelBase* theModel)
260 connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
261 this,SLOT(onKeyPressed(QKeyEvent*)) );
262 connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
263 this,SLOT(onKeyReleased(QKeyEvent*)));
264 connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
265 this,SLOT(onMousePressed(QMouseEvent*)));
266 connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
267 this,SLOT(onMouseReleased(QMouseEvent*)));
268 connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
269 this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
270 connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
271 this,SLOT(onMouseMoving(QMouseEvent*)));
272 connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
273 this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
274 connect(theView,SIGNAL(selectionChanged()),
275 theModel,SLOT(onSelectionChanged()));
277 connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
283 SVTK_ViewWindow::~SVTK_ViewWindow()
285 myRecorder->Delete();
286 myAxesWidget->Delete();
291 \return corresponding view
293 SVTK_View* SVTK_ViewWindow::getView()
299 \return corresponding vtk render window
301 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
303 return GetInteractor()->getRenderWindow();
307 \return corresponding vtk render window interactor
309 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
315 \return corresponding vtk render window interactor
317 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
319 return myInteractor->GetDevice();
323 \return corresponding vtk renderer
325 vtkRenderer* SVTK_ViewWindow::getRenderer() const
327 return GetInteractor()->getRenderer();
331 Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
333 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
335 return GetInteractor()->GetRenderer();
339 \return corresponding vtk selector
341 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
343 return GetInteractor()->GetSelector();
347 Processes transformation "front view"
349 void SVTK_ViewWindow::onFrontView()
351 GetRenderer()->OnFrontView();
353 emit transformed( this );
357 Processes transformation "back view"
359 void SVTK_ViewWindow::onBackView()
361 GetRenderer()->OnBackView();
363 emit transformed( this );
367 Processes transformation "top view"
369 void SVTK_ViewWindow::onTopView()
371 GetRenderer()->OnTopView();
373 emit transformed( this );
377 Processes transformation "bottom view"
379 void SVTK_ViewWindow::onBottomView()
381 GetRenderer()->OnBottomView();
383 emit transformed( this );
387 Processes transformation "left view"
389 void SVTK_ViewWindow::onLeftView()
391 GetRenderer()->OnLeftView();
393 emit transformed( this );
397 Processes transformation "right view"
399 void SVTK_ViewWindow::onRightView()
401 GetRenderer()->OnRightView();
403 emit transformed( this );
407 \brief Rotate view 90 degrees clockwise
409 void SVTK_ViewWindow::onClockWiseView()
411 GetRenderer()->onClockWiseView();
413 emit transformed( this );
417 \brief Rotate view 90 degrees conterclockwise
419 void SVTK_ViewWindow::onAntiClockWiseView()
421 GetRenderer()->onAntiClockWiseView();
423 emit transformed( this );
427 Processes transformation "reset view": sets default orientation of viewport camera
429 void SVTK_ViewWindow::onResetView()
431 GetRenderer()->OnResetView();
433 emit transformed( this );
437 Processes transformation "fit all"
439 void SVTK_ViewWindow::onFitAll()
441 GetRenderer()->OnFitAll();
443 emit transformed( this );
447 Processes transformation "fit selection"
449 void SVTK_ViewWindow::onFitSelection()
451 GetRenderer()->onFitSelection();
453 emit transformed( this );
457 SLOT: called if selection is changed
459 void SVTK_ViewWindow::onSelectionChanged()
461 myView->onSelectionChanged();
465 Change selection mode
466 \param theMode - new selection mode
468 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
470 GetSelector()->SetSelectionMode(theMode);
474 \return selection mode
476 Selection_Mode SVTK_ViewWindow::SelectionMode() const
478 return GetSelector()->SelectionMode();
482 Unhilights all objects in viewer
484 void SVTK_ViewWindow::unHighlightAll()
486 myView->unHighlightAll();
490 Hilights/unhilights object in viewer
491 \param theIO - object to be updated
492 \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
493 \param theIsUpdate - update current viewer
495 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO,
499 myView->highlight( theIO, theIsHighlight, theIsUpdate );
503 \return true if object is in viewer or in collector
504 \param theIO - object to be checked
506 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
508 return myView->isInViewer( theIO );
512 \return true if object is displayed in viewer
513 \param theIO - object to be checked
515 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
517 return myView->isVisible( theIO );
522 \param theEntry - entry that corresponds to intractive objects
524 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry)
526 return myView->FindIObject(theEntry);
531 \param theIO - object
532 \param theImmediatly - update viewer
534 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
537 myView->Display(theIO,theImmediatly);
542 \param theIO - object
543 \param theImmediatly - update viewer
545 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
548 myView->Erase(theIO,theImmediatly);
552 Display only passed object
553 \param theIO - object
555 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
557 myView->DisplayOnly(theIO);
561 Display all objects in view
563 void SVTK_ViewWindow::DisplayAll()
565 myView->DisplayAll();
569 Erase all objects in view
571 void SVTK_ViewWindow::EraseAll()
577 Sets background color [obsolete]
578 \param color - new background color
580 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
582 Qtx::BackgroundData bg = background();
588 \return background color of viewer [obsolete]
590 QColor SVTK_ViewWindow::backgroundColor() const
592 return background().color();
597 \param bgData - new background data
599 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
603 if ( bgData.isValid() ) {
604 switch ( bgData.mode() ) {
605 case Qtx::ColorBackground:
607 QColor c = bgData.color();
609 // show solid-colored background
610 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
611 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
612 getRenderer()->SetBackground( c.red()/255.0,
614 c.blue()/255.0 ); // set background color
619 case Qtx::SimpleGradientBackground:
622 int type = bgData.gradient( c1, c2 );
628 // show two-color gradient background
629 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
630 getRenderer()->SetGradientBackground( true ); // switch to gradient mode
632 VTKViewer_OpenGLRenderer* aRenderer =
633 VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
636 aRenderer->SetGradientType( type );
637 aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
638 aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
644 case Qtx::CustomGradientBackground:
646 // NOT IMPLEMENTED YET
647 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
648 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
655 if ( bgData.isTextureShown() ) {
657 int textureMode = bgData.texture( fileName );
658 QFileInfo fi( fileName );
659 if ( !fileName.isEmpty() && fi.exists() ) {
660 // read texture from file
661 QString extension = fi.suffix().toLower();
662 vtkImageReader2* aReader = 0;
663 if ( extension == "jpg" || extension == "jpeg" )
664 aReader = vtkJPEGReader::New();
665 else if ( extension == "bmp" )
666 aReader = vtkBMPReader::New();
667 else if ( extension == "tif" || extension == "tiff" )
668 aReader = vtkTIFFReader::New();
669 else if ( extension == "png" )
670 aReader = vtkPNGReader::New();
671 else if ( extension == "mhd" || extension == "mha" )
672 aReader = vtkMetaImageReader::New();
675 aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
677 VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
678 vtkImageMapToColors* aMap = 0;
679 vtkAlgorithmOutput* anOutput;
681 // special processing for BMP reader
682 vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
684 // Special processing for BMP file
685 aBMPReader->SetAllow8BitBMP(1);
687 aMap = vtkImageMapToColors::New();
688 aMap->SetInputConnection( aBMPReader->GetOutputPort() );
689 aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
690 aMap->SetOutputFormatToRGB();
692 anOutput = aMap->GetOutputPort();
697 anOutput = aReader->GetOutputPort( 0 );
698 aTexture->SetInputConnection( anOutput );
700 // VSR: Currently, VTK only supports Stretch mode, so below code will give
701 // the same results for all modes
702 switch ( textureMode ) {
703 case Qtx::TileTexture:
704 aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
706 case Qtx::StretchTexture:
707 aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
709 case Qtx::CenterTexture:
710 aTexture->SetPosition((int)VTKViewer_Texture::Centered);
714 // show textured background
715 getRenderer()->SetTexturedBackground( true );
716 getRenderer()->SetBackgroundTexture( aTexture );
718 // clean-up resources
729 myBackground = bgData;
733 \return background data of viewer
735 Qtx::BackgroundData SVTK_ViewWindow::background() const
742 Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
744 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
746 return GetInteractor()->GetInteractorStyle();
750 Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
752 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
754 GetInteractor()->PushInteractorStyle(theStyle);
758 Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
760 void SVTK_ViewWindow::PopInteractorStyle()
762 GetInteractor()->PopInteractorStyle();
766 Updates current viewer
768 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
770 if(theUpdateTrihedron)
771 GetRenderer()->OnAdjustTrihedron();
773 GetInteractor()->update();
775 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
781 Redirect the request to #SVTK_Renderer::GetScale
783 void SVTK_ViewWindow::GetScale( double theScale[3] )
785 GetRenderer()->GetScale( theScale );
789 Redirect the request to #SVTK_Renderer::SetScale
791 void SVTK_ViewWindow::SetScale( double theScale[3] )
793 GetRenderer()->SetScale( theScale );
795 emit transformed( this );
799 Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
801 bool SVTK_ViewWindow::isTrihedronDisplayed()
803 return GetRenderer()->IsTrihedronDisplayed();
807 Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
809 bool SVTK_ViewWindow::isCubeAxesDisplayed()
811 return GetRenderer()->IsCubeAxesDisplayed();
815 Redirect the request to #SVTK_Renderer::OnViewTrihedron
817 void SVTK_ViewWindow::onViewTrihedron(bool show)
819 GetRenderer()->SetTrihedronVisibility(show);
824 Redirect the request to #SVTK_Renderer::OnViewCubeAxes
826 void SVTK_ViewWindow::onViewCubeAxes()
828 GetRenderer()->OnViewCubeAxes();
833 Redirect the request to #SVTK_Renderer::GetTrihedron
835 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
837 return GetRenderer()->GetTrihedron();
841 Redirect the request to #SVTK_Renderer::GetCubeAxes
843 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
845 return GetRenderer()->GetCubeAxes();
849 \return trihedron size
851 double SVTK_ViewWindow::GetTrihedronSize() const
853 return GetRenderer()->GetTrihedronSize();
858 \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo )
860 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
862 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
864 if ( theMode != Stereo ) {
865 aViewer->setProjectionMode(theMode);
866 bool anIsParallelMode = (theMode == Parallel);
867 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
868 aCamera->SetParallelProjection(anIsParallelMode);
869 GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
870 getRenderWindow()->SetStereoRender(0);
873 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
874 SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
875 getRenderWindow()->SetStereoRender(1);
879 // update action state if method is called outside
880 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
881 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
882 QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
883 QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
884 if ( theMode == Parallel && !aParallelAction->isChecked() ) {
885 aParallelAction->setChecked( true );
886 aSwitchZoomingStyle->setEnabled(true);
887 aStereoAction->setChecked( false );
889 if ( theMode == Projection && !aProjectionAction->isChecked() ) {
890 aProjectionAction->setChecked( true );
891 aSwitchZoomingStyle->setEnabled(false);
893 if ( theMode == Stereo ) {
894 aStereoAction->setChecked( true );
895 if ( aParallelAction->isEnabled() ) {
896 aParallelAction->setEnabled( false );
897 aParallelAction->setChecked( false );
898 aStereoAction->setChecked( false );
901 aParallelAction->setEnabled( true );
902 aStereoAction->setChecked( false );
903 aParallelAction->setChecked( aViewer->projectionMode() == Parallel );
905 if ( aProjectionAction->isEnabled() ) {
906 aProjectionAction->setEnabled( false );
907 aProjectionAction->setChecked( true );
908 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
909 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 ){
910 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
914 aProjectionAction->setEnabled( true );
915 aStereoAction->setChecked( false );
916 aProjectionAction->setChecked( aViewer->projectionMode() == Projection );
921 if ( !aParallelAction->isEnabled() )
922 aParallelAction->setEnabled( true );
923 if ( !aProjectionAction->isEnabled() )
924 aProjectionAction->setEnabled( true );
930 \param theType - stereo type
932 void SVTK_ViewWindow::SetStereoType(const int theType)
934 vtkRenderWindow* aWindow = getRenderWindow();
937 aWindow->SetStereoTypeToCrystalEyes();
940 aWindow->SetStereoTypeToRedBlue();
943 aWindow->SetStereoTypeToInterlaced();
946 aWindow->SetStereoTypeToLeft();
949 aWindow->SetStereoTypeToRight();
952 aWindow->SetStereoTypeToDresden();
955 aWindow->SetStereoTypeToAnaglyph();
958 aWindow->SetStereoTypeToCheckerboard();
960 case SplitViewPortHorizontal:
961 aWindow->SetStereoTypeToSplitViewportHorizontal();
968 \param theFilter - anaglyph filter
970 void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter)
972 vtkRenderWindow* aWindow = getRenderWindow();
973 switch (theFilter ) {
975 aWindow->SetAnaglyphColorMask(4,3);
978 aWindow->SetAnaglyphColorMask(6,1);
981 aWindow->SetAnaglyphColorMask(2,5);
987 \return OpenGl stereo support
989 bool SVTK_ViewWindow::isOpenGlStereoSupport() const
991 GLboolean support[1];
992 glGetBooleanv (GL_STEREO, support);
999 Set the gravity center as a focal point
1001 void SVTK_ViewWindow::activateSetFocalPointGravity()
1003 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
1007 Set the selected point as a focal point
1009 void SVTK_ViewWindow::activateSetFocalPointSelected()
1011 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
1015 Set the point selected by user as a focal point
1017 void SVTK_ViewWindow::activateStartFocalPointSelection()
1019 myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
1022 void SVTK_ViewWindow::activateProjectionMode(int theMode)
1024 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
1025 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
1027 aParallelAction->setChecked( true );
1029 aProjectionAction->setChecked( true );
1031 if ( !aParallelAction->isEnabled() )
1032 aParallelAction->setEnabled( true );
1033 if ( !aProjectionAction->isEnabled() )
1034 aProjectionAction->setEnabled( true );
1038 Sets actual interaction style
1039 \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
1041 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
1043 onSwitchInteractionStyle( theStyle==1 );
1047 Sets actual zooming style
1048 \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) )
1050 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
1052 onSwitchZoomingStyle( theStyle==1 );
1056 Set preselection mode.
1057 \param theMode the mode to set (standard, dynamic or disabled)
1059 void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
1061 onSwitchPreSelectionMode( theMode );
1065 Enables/disables selection.
1066 \param theEnable if true - selection will be enabled
1068 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
1070 GetSelector()->SetSelectionEnabled( theEnable );
1071 QtxAction* a = getAction( EnableSelectionId );
1072 if ( a->isChecked() != theEnable)
1073 a->setChecked( theEnable );
1074 QtxActionGroup* aPreselectionGroup =
1075 dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
1076 if ( aPreselectionGroup )
1077 aPreselectionGroup->setEnabled( theEnable );
1081 Switches "keyboard free" interaction style on/off
1083 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
1086 // check if style is already set
1087 if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
1089 // keep the same style extensions
1090 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
1092 myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
1093 myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
1096 PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
1100 // pop only key free style
1101 if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
1102 PopInteractorStyle();
1105 // update action state if method is called outside
1106 QtxAction* a = getAction( SwitchInteractionStyleId );
1107 if ( a->isChecked() != theOn ) a->setChecked( theOn );
1111 Toogles advanced zooming style (relatively to the cursor position) on/off
1113 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
1115 if( myDefaultInteractorStyle.GetPointer() )
1116 myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1117 if( myKeyFreeInteractorStyle.GetPointer() )
1118 myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1120 // update action state if method is called outside
1121 QtxAction* a = getAction( SwitchZoomingStyleId );
1122 if ( a->isChecked() != theOn )
1123 a->setChecked( theOn );
1127 Switch preselection mode.
1128 \param theMode the preselection mode
1130 void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
1132 GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection );
1133 GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled );
1135 // update action state if method is called outside
1136 QtxAction* a = getAction( StandardPreselectionId + theMode );
1137 if ( a && !a->isChecked() )
1138 a->setChecked( true );
1142 Enables/disables selection.
1143 \param theOn if true - selection will be enabled
1145 void SVTK_ViewWindow::onEnableSelection( bool on )
1147 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
1149 aViewer->enableSelection(on);
1153 Sets incremental speed
1154 \param theValue - new incremental speed
1155 \param theMode - modification mode
1157 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
1159 if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
1160 ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
1164 Sets spacemouse buttons for the functions
1165 \param theBtn1 - spacemouse button for the "decrease speed increment"
1166 \param theBtn2 - spacemouse button for the "increase speed increment"
1167 \param theBtn3 - spacemouse button for the "dominant combined switch"
1169 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1,
1174 myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
1176 myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
1178 myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
1183 \param theSize - new trihedron size
1184 \param theRelative - trihedron relativeness
1186 void SVTK_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative)
1188 GetRenderer()->SetTrihedronSize(theSize, theRelative);
1192 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
1193 * trihedron and cube axes, even if trihedron and cube axes is invisible.
1195 void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
1197 GetRenderer()->AdjustActors();
1202 Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
1204 void SVTK_ViewWindow::onAdjustTrihedron()
1206 GetRenderer()->OnAdjustTrihedron();
1210 Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
1212 void SVTK_ViewWindow::onAdjustCubeAxes()
1214 GetRenderer()->OnAdjustCubeAxes();
1217 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
1219 if ( otherViewWindow ) {
1220 bool blocked = blockSignals( true );
1221 doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
1222 blockSignals( blocked );
1229 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
1231 emit keyPressed( this, event );
1237 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
1239 emit keyReleased( this, event );
1245 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
1247 emit mousePressed(this, event);
1251 Emits mouse released
1253 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
1255 emit mouseReleased( this, event );
1261 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
1263 emit mouseMoving( this, event );
1267 Emits mouse double clicked
1269 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
1271 emit mouseDoubleClicked( this, event );
1275 Redirect the request to #SVTK_Renderer::AddActor
1277 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor,
1279 bool theIsAdjustActors )
1281 GetRenderer()->AddActor(theActor, theIsAdjustActors);
1284 emit actorAdded(theActor);
1288 Redirect the request to #SVTK_Renderer::RemoveActor
1290 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor,
1292 bool theIsAdjustActors )
1294 GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
1295 if ( myDefaultInteractorStyle )
1296 myDefaultInteractorStyle->FreeActors();
1297 if ( myKeyFreeInteractorStyle )
1298 myKeyFreeInteractorStyle->FreeActors();
1301 emit actorRemoved(theActor);
1304 QImage SVTK_ViewWindow::dumpViewContent()
1306 vtkRenderWindow* aWindow = getRenderWindow();
1307 int* aSize = aWindow->GetSize();
1308 int aWidth = aSize[0];
1309 int aHeight = aSize[1];
1311 #ifndef DISABLE_GLVIEWER
1312 OpenGLUtils_FrameBuffer aFrameBuffer;
1313 if( aFrameBuffer.init( aWidth, aHeight ) )
1315 glPushAttrib( GL_VIEWPORT_BIT );
1316 glViewport( 0, 0, aWidth, aHeight );
1317 aFrameBuffer.bind();
1322 aFrameBuffer.unbind();
1325 QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1327 aFrameBuffer.bind();
1328 glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1329 aFrameBuffer.unbind();
1331 anImage = anImage.rgbSwapped();
1332 anImage = anImage.mirrored();
1337 // if frame buffers are unsupported, use old functionality
1338 unsigned char *aData =
1339 aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
1341 QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
1343 anImage = anImage.rgbSwapped();
1344 anImage = anImage.mirrored();
1349 \return QImage, containing all scene rendering in window
1351 QImage SVTK_ViewWindow::dumpView()
1353 if( myDumpImage.isNull() )
1354 return dumpViewContent();
1360 QString SVTK_ViewWindow::filter() const
1362 return tr( "SVTK_IMAGE_FILES" );
1365 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
1367 if ( format != "PS" && format != "EPS" && format != "PDF" )
1368 return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1370 SUIT_OverrideCursor wc;
1372 vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
1373 anExporter->SetRenderWindow(getRenderWindow());
1375 if ( format == "PS" ) {
1376 anExporter->SetFileFormatToPS();
1377 anExporter->CompressOff();
1380 if ( format == "EPS" ) {
1381 anExporter->SetFileFormatToEPS();
1382 anExporter->CompressOff();
1385 if ( format == "PDF" ) {
1386 anExporter->SetFileFormatToPDF();
1389 QString aFilePrefix(fileName);
1390 QString anExtension(SUIT_Tools::extension(fileName));
1391 aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
1392 anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
1393 anExporter->Write();
1394 anExporter->Delete();
1400 \refresh QImage, containing all scene rendering in window
1402 void SVTK_ViewWindow::RefreshDumpImage()
1404 myDumpImage = dumpViewContent();
1408 Redirect the request to #SVTK_Renderer::SetSelectionProp
1410 void SVTK_ViewWindow::SetSelectionProp(const double& theRed,
1411 const double& theGreen,
1412 const double& theBlue,
1413 const int& theWidth)
1415 myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
1419 Redirect the request to #SVTK_Renderer::SetSelectionProp
1421 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed,
1422 const double& theGreen,
1423 const double& theBlue,
1424 const int& theWidth)
1426 myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
1430 Redirect the request to #SVTK_Renderer::SetSelectionTolerance
1432 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes,
1433 const double& theTolItems,
1434 const double& theTolObjects)
1436 myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
1440 Get visibility status of the static trihedron
1442 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
1444 return (bool)myAxesWidget->GetEnabled();
1448 Set visibility status of the static trihedron
1450 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
1452 myAxesWidget->SetEnabled( (int)theIsVisible );
1457 \param accelAction - action
1459 bool SVTK_ViewWindow::action( const int accelAction )
1461 if ( accelAction == SUIT_Accel::ZoomFit )
1464 int anEvent = SVTK::convertAction( accelAction );
1465 GetInteractor()->InvokeEvent(anEvent, 0);
1471 \return action by it's id
1473 QtxAction* SVTK_ViewWindow::getAction( int id ) const
1475 return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
1479 // old visual parameters had 13 values. New format added additional
1480 // 76 values for graduated axes, so both numbers are processed.
1481 const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
1482 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
1483 const int nTrihedronParams = 3; // number of parameters for Trihedron
1484 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
1486 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
1488 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
1495 bool isVisible = actor->GetTitleVisibility();
1496 QString title ( actor->GetTitle() );
1498 int font = VTK_ARIAL;
1503 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1506 txtProp->GetColor( color );
1507 font = txtProp->GetFontFamily();
1508 bold = txtProp->GetBold();
1509 italic = txtProp->GetItalic();
1510 shadow = txtProp->GetShadow();
1512 writer.writeStartElement("GraduatedAxis");
1513 writer.writeAttribute("Axis", theAxis);
1515 writer.writeStartElement("Title");
1516 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1517 writer.writeAttribute("Text", title);
1518 writer.writeAttribute("Font", QString("%1").arg(font));
1519 writer.writeAttribute("Bold", QString("%1").arg(bold));
1520 writer.writeAttribute("Italic", QString("%1").arg(italic));
1521 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1523 writer.writeStartElement("Color");
1524 writer.writeAttribute("R", QString("%1").arg(color[0]));
1525 writer.writeAttribute("G", QString("%1").arg(color[1]));
1526 writer.writeAttribute("B", QString("%1").arg(color[2]));
1527 writer.writeEndElement();
1528 writer.writeEndElement();
1530 //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
1531 // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1534 isVisible = actor->GetLabelVisibility();
1535 int labels = actor->GetNumberOfLabels();
1536 int offset = actor->GetTickOffset();
1542 txtProp = actor->GetLabelTextProperty();
1545 txtProp->GetColor( color );
1546 font = txtProp->GetFontFamily();
1547 bold = txtProp->GetBold();
1548 italic = txtProp->GetItalic();
1549 shadow = txtProp->GetShadow();
1552 writer.writeStartElement("Labels");
1553 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1554 writer.writeAttribute("Number", QString("%1").arg(labels));
1555 writer.writeAttribute("Offset", QString("%1").arg(offset));
1556 writer.writeAttribute("Font", QString("%1").arg(font));
1557 writer.writeAttribute("Bold", QString("%1").arg(bold));
1558 writer.writeAttribute("Italic", QString("%1").arg(italic));
1559 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1561 writer.writeStartElement("Color");
1562 writer.writeAttribute("R", QString("%1").arg(color[0]));
1563 writer.writeAttribute("G", QString("%1").arg(color[1]));
1564 writer.writeAttribute("B", QString("%1").arg(color[2]));
1565 writer.writeEndElement();
1566 writer.writeEndElement();
1567 // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
1568 // color[0], color[1], color[2], font, bold, italic, shadow );
1571 isVisible = actor->GetTickVisibility();
1572 int length = actor->GetTickLength();
1573 writer.writeStartElement("TickMarks");
1574 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1575 writer.writeAttribute("Length", QString("%1").arg(length));
1576 writer.writeEndElement();
1578 //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1580 writer.writeEndElement();
1584 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1591 } while (!reader.isStartElement());
1593 // Read title params
1594 QXmlStreamAttributes aAttr = reader.attributes();
1595 bool isVisible = aAttr.value("isVisible").toString().toUShort();
1596 QString title = aAttr.value("Text").toString();
1597 int font = aAttr.value("Font").toString().toInt();
1598 int bold = aAttr.value("Bold").toString().toInt();
1599 int italic = aAttr.value("Italic").toString().toInt();
1600 int shadow = aAttr.value("Shadow").toString().toInt();
1602 //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1606 } while (!reader.isStartElement());
1609 aAttr = reader.attributes();
1612 color[0] = aAttr.value("R").toString().toDouble();
1613 color[1] = aAttr.value("G").toString().toDouble();
1614 color[2] = aAttr.value("B").toString().toDouble();
1615 //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1617 actor->SetTitleVisibility( isVisible );
1618 actor->SetTitle( title.toLatin1() );
1619 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1621 txtProp->SetColor( color );
1622 txtProp->SetFontFamily( font );
1623 txtProp->SetBold( bold );
1624 txtProp->SetItalic( italic );
1625 txtProp->SetShadow( shadow );
1632 } while (!reader.isStartElement());
1634 aAttr = reader.attributes();
1635 isVisible = aAttr.value("isVisible").toString().toUShort();
1636 int labels = aAttr.value("Number").toString().toInt();
1637 int offset = aAttr.value("Offset").toString().toInt();
1638 font = aAttr.value("Font").toString().toInt();
1639 bold = aAttr.value("Bold").toString().toInt();
1640 italic = aAttr.value("Italic").toString().toInt();
1641 shadow = aAttr.value("Shadow").toString().toInt();
1645 } while (!reader.isStartElement());
1647 aAttr = reader.attributes();
1649 color[0] = aAttr.value("R").toString().toDouble();
1650 color[1] = aAttr.value("G").toString().toDouble();
1651 color[2] = aAttr.value("B").toString().toDouble();
1653 actor->SetLabelVisibility( isVisible );
1654 actor->SetNumberOfLabels( labels );
1655 actor->SetTickOffset( offset );
1656 txtProp = actor->GetLabelTextProperty();
1658 txtProp->SetColor( color );
1659 txtProp->SetFontFamily( font );
1660 txtProp->SetBold( bold );
1661 txtProp->SetItalic( italic );
1662 txtProp->SetShadow( shadow );
1668 } while (!reader.isStartElement());
1669 aAttr = reader.attributes();
1671 // retrieve and set tick marks properties
1672 isVisible = aAttr.value("isVisible").toString().toUShort();
1673 int length = aAttr.value("Length").toString().toInt();
1675 actor->SetTickVisibility( isVisible );
1676 actor->SetTickLength( length );
1679 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1681 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1686 QStringList paramsLst = params.split( '*' );
1688 if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1690 // retrieve and set name parameters
1691 bool isVisible = paramsLst[2].toUShort();
1692 QString title = paramsLst[3];
1694 color[0] = paramsLst[4].toDouble();
1695 color[1] = paramsLst[5].toDouble();
1696 color[2] = paramsLst[6].toDouble();
1697 int font = paramsLst[7].toInt();
1698 int bold = paramsLst[8].toInt();
1699 int italic = paramsLst[9].toInt();
1700 int shadow = paramsLst[10].toInt();
1702 actor->SetTitleVisibility( isVisible );
1703 actor->SetTitle( title.toLatin1() );
1704 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1706 txtProp->SetColor( color );
1707 txtProp->SetFontFamily( font );
1708 txtProp->SetBold( bold );
1709 txtProp->SetItalic( italic );
1710 txtProp->SetShadow( shadow );
1713 // retrieve and set lable parameters
1714 isVisible = paramsLst[12].toUShort();
1715 int labels = paramsLst[13].toInt();
1716 int offset = paramsLst[14].toInt();
1717 color[0] = paramsLst[15].toDouble();
1718 color[1] = paramsLst[16].toDouble();
1719 color[2] = paramsLst[17].toDouble();
1720 font = paramsLst[18].toInt();
1721 bold = paramsLst[19].toInt();
1722 italic = paramsLst[20].toInt();
1723 shadow = paramsLst[21].toInt();
1725 actor->SetLabelVisibility( isVisible );
1726 actor->SetNumberOfLabels( labels );
1727 actor->SetTickOffset( offset );
1728 txtProp = actor->GetLabelTextProperty();
1730 txtProp->SetColor( color );
1731 txtProp->SetFontFamily( font );
1732 txtProp->SetBold( bold );
1733 txtProp->SetItalic( italic );
1734 txtProp->SetShadow( shadow );
1737 // retrieve and set tick marks properties
1738 isVisible = paramsLst[23].toUShort();
1739 int length = paramsLst[24].toInt();
1741 actor->SetTickVisibility( isVisible );
1742 actor->SetTickLength( length );
1746 /*! The method returns the visual parameters of this view as a formated string
1748 QString SVTK_ViewWindow::getVisualParameters()
1750 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1752 // save position, focal point, viewUp, scale
1753 vtkCamera* camera = getRenderer()->GetActiveCamera();
1754 camera->GetPosition( pos );
1755 camera->GetFocalPoint( focalPnt );
1756 camera->GetViewUp( viewUp );
1757 parScale = camera->GetParallelScale();
1760 // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1761 // view up values (3 digits), parallel scale (1 digit), scale (3 digits,
1762 // Graduated axes parameters (X, Y, Z axes parameters)
1764 QXmlStreamWriter aWriter(&retStr);
1765 aWriter.setAutoFormatting(true);
1767 aWriter.writeStartDocument();
1768 aWriter.writeStartElement("ViewState");
1770 aWriter.writeStartElement("Position");
1771 aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1772 aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1773 aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1774 aWriter.writeEndElement();
1776 aWriter.writeStartElement("FocalPoint");
1777 aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1778 aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1779 aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1780 aWriter.writeEndElement();
1782 aWriter.writeStartElement("ViewUp");
1783 aWriter.writeAttribute("X", QString::number(viewUp[0]));
1784 aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1785 aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1786 aWriter.writeEndElement();
1788 aWriter.writeStartElement("ViewScale");
1789 aWriter.writeAttribute("Parallel", QString::number(parScale));
1790 aWriter.writeAttribute("X", QString::number(scale[0]));
1791 aWriter.writeAttribute("Y", QString::number(scale[1]));
1792 aWriter.writeAttribute("Z", QString::number(scale[2]));
1793 aWriter.writeEndElement();
1795 if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1796 aWriter.writeStartElement("DisplayCubeAxis");
1797 aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1798 aWriter.writeEndElement();
1800 getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1801 getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1802 getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1805 aWriter.writeStartElement("Trihedron");
1806 aWriter.writeAttribute("isShown", QString( "%1" ).arg( isTrihedronDisplayed()));
1807 aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1808 aWriter.writeEndElement();
1810 aWriter.writeStartElement("Background");
1811 aWriter.writeAttribute("Value", QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
1812 aWriter.writeEndElement();
1814 aWriter.writeEndElement();
1815 aWriter.writeEndDocument();
1821 The method restores visual parameters of this view or postpones it untill the view is shown
1823 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1825 //printf("#### %s\n", qPrintable(parameters));
1826 SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1827 if ( anInteractor->isVisible() ) {
1828 doSetVisualParameters( parameters );
1831 myVisualParams = parameters;
1832 anInteractor->installEventFilter(this);
1837 The method restores visual parameters of this view from a formated string
1839 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
1842 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1844 QXmlStreamReader aReader(parameters);
1845 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1847 while(!aReader.atEnd()) {
1849 if (aReader.isStartElement()) {
1850 QXmlStreamAttributes aAttr = aReader.attributes();
1851 //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1852 if (aReader.name() == "Position") {
1853 pos[0] = aAttr.value("X").toString().toDouble();
1854 pos[1] = aAttr.value("Y").toString().toDouble();
1855 pos[2] = aAttr.value("Z").toString().toDouble();
1856 //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1858 else if (aReader.name() == "FocalPoint") {
1859 focalPnt[0] = aAttr.value("X").toString().toDouble();
1860 focalPnt[1] = aAttr.value("Y").toString().toDouble();
1861 focalPnt[2] = aAttr.value("Z").toString().toDouble();
1862 //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1864 else if (aReader.name() == "ViewUp") {
1865 viewUp[0] = aAttr.value("X").toString().toDouble();
1866 viewUp[1] = aAttr.value("Y").toString().toDouble();
1867 viewUp[2] = aAttr.value("Z").toString().toDouble();
1868 //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1870 else if (aReader.name() == "ViewScale") {
1871 parScale = aAttr.value("Parallel").toString().toDouble();
1872 scale[0] = aAttr.value("X").toString().toDouble();
1873 scale[1] = aAttr.value("Y").toString().toDouble();
1874 scale[2] = aAttr.value("Z").toString().toDouble();
1875 //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1877 else if (aReader.name() == "DisplayCubeAxis") {
1878 if ( !baseParamsOnly ) {
1879 if (aAttr.value("Show") == "0")
1880 gradAxesActor->VisibilityOff();
1882 gradAxesActor->VisibilityOn();
1885 else if (aReader.name() == "GraduatedAxis") {
1886 if ( !baseParamsOnly ) {
1887 if(aAttr.value("Axis") == "X")
1888 setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1889 else if(aAttr.value("Axis") == "Y")
1890 setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1891 else if(aAttr.value("Axis") == "Z")
1892 setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1895 else if (aReader.name() == "Trihedron") {
1896 if ( !baseParamsOnly ) {
1897 if (aAttr.value("isShown") == "0")
1898 GetTrihedron()->VisibilityOff();
1900 GetTrihedron()->VisibilityOn();
1901 SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1904 else if (aReader.name() == "Background") {
1905 if ( !baseParamsOnly ) {
1906 setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
1911 if (!aReader.hasError()) {
1912 vtkCamera* camera = getRenderer()->GetActiveCamera();
1913 camera->SetPosition( pos );
1914 camera->SetFocalPoint( focalPnt );
1915 camera->SetViewUp( viewUp );
1916 camera->SetParallelScale( parScale );
1917 GetRenderer()->SetScale( scale );
1918 //SetScale( scale );
1921 QStringList paramsLst = parameters.split( '*' );
1922 if ( paramsLst.size() >= nNormalParams ) {
1923 // 'reading' list of parameters
1924 pos[0] = paramsLst[0].toDouble();
1925 pos[1] = paramsLst[1].toDouble();
1926 pos[2] = paramsLst[2].toDouble();
1927 focalPnt[0] = paramsLst[3].toDouble();
1928 focalPnt[1] = paramsLst[4].toDouble();
1929 focalPnt[2] = paramsLst[5].toDouble();
1930 viewUp[0] = paramsLst[6].toDouble();
1931 viewUp[1] = paramsLst[7].toDouble();
1932 viewUp[2] = paramsLst[8].toDouble();
1933 parScale = paramsLst[9].toDouble();
1934 scale[0] = paramsLst[10].toDouble();
1935 scale[1] = paramsLst[11].toDouble();
1936 scale[2] = paramsLst[12].toDouble();
1938 // applying parameters
1939 vtkCamera* camera = getRenderer()->GetActiveCamera();
1940 camera->SetPosition( pos );
1941 camera->SetFocalPoint( focalPnt );
1942 camera->SetViewUp( viewUp );
1943 camera->SetParallelScale( parScale );
1944 GetRenderer()->SetScale( scale );
1945 //SetScale( scale );
1947 // apply graduated axes parameters
1948 if ( !baseParamsOnly ) {
1949 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1950 if ( gradAxesActor && paramsLst.size() == nAllParams ) {
1951 int i = nNormalParams+1, j = i + nGradAxisParams - 1;
1952 ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
1953 i = j + 1; j += nGradAxisParams;
1954 ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
1955 i = j + 1; j += nGradAxisParams;
1956 ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
1958 if ( paramsLst[13].toUShort() )
1959 gradAxesActor->VisibilityOn();
1961 gradAxesActor->VisibilityOff();
1963 else if ( paramsLst.size() == nAllParams ) {
1964 if ( paramsLst[90].toUShort() )
1965 GetTrihedron()->VisibilityOn();
1967 GetTrihedron()->VisibilityOff();
1969 SetTrihedronSize(paramsLst[91].toDouble());
1979 Delayed setVisualParameters
1981 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
1983 if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
1984 SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
1985 if ( anInteractor->isVisible() ) {
1986 doSetVisualParameters( myVisualParams );
1987 anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
1990 return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
1995 Change rotation point
1997 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
2000 mySetRotationPointDlg->addObserver();
2001 if ( mySetRotationPointDlg->IsFirstShown() )
2002 activateSetRotationGravity();
2003 mySetRotationPointDlg->show();
2005 mySetRotationPointDlg->hide();
2009 Set the gravity center as a rotation point
2011 void SVTK_ViewWindow::activateSetRotationGravity()
2013 myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
2017 Set the selected point as a rotation point
2019 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
2021 myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
2025 Set the gravity center of element selected by user as a rotation point
2027 void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
2029 SetSelectionMode( theSelectionMode );
2030 myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
2034 Set the view projection mode: orthogonal or perspective
2036 void SVTK_ViewWindow::onPerspectiveMode()
2038 if (toolMgr()->action( ParallelModeId )->isChecked())
2039 SetProjectionMode( Parallel);
2040 if (toolMgr()->action( ProjectionModeId )->isChecked())
2041 SetProjectionMode( Projection);
2042 if (toolMgr()->action( StereoModeId )->isChecked())
2043 SetProjectionMode( Stereo);
2044 emit transformed( this );
2047 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
2049 myEventDispatcher = theDispatcher;
2053 Creates all actions of svtk main window
2055 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
2057 QtxAction* anAction;
2058 QtxActionToolMgr* mgr = toolMgr();
2061 anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
2062 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
2063 tr( "MNU_DUMP_VIEW" ), 0, this);
2064 anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
2065 connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
2066 mgr->registerAction( anAction, DumpId );
2069 anAction = new QtxAction(tr("MNU_FITALL"),
2070 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
2071 tr( "MNU_FITALL" ), 0, this);
2072 anAction->setStatusTip(tr("DSC_FITALL"));
2073 connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
2074 mgr->registerAction( anAction, FitAllId );
2077 anAction = new QtxAction(tr("MNU_FITRECT"),
2078 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
2079 tr( "MNU_FITRECT" ), 0, this);
2080 anAction->setStatusTip(tr("DSC_FITRECT"));
2081 connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
2082 mgr->registerAction( anAction, FitRectId );
2085 anAction = new QtxAction(tr("MNU_FITSELECTION"),
2086 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
2087 tr( "MNU_FITSELECTION" ), 0, this);
2088 anAction->setStatusTip(tr("DSC_FITSELECTION"));
2089 connect(anAction, SIGNAL(activated()), this, SLOT(onFitSelection()));
2090 mgr->registerAction( anAction, FitSelectionId );
2093 anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
2094 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
2095 tr( "MNU_ZOOM_VIEW" ), 0, this);
2096 anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
2097 connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
2098 mgr->registerAction( anAction, ZoomId );
2101 anAction = new QtxAction(tr("MNU_PAN_VIEW"),
2102 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
2103 tr( "MNU_PAN_VIEW" ), 0, this);
2104 anAction->setStatusTip(tr("DSC_PAN_VIEW"));
2105 connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
2106 mgr->registerAction( anAction, PanId );
2109 anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
2110 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
2111 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
2112 anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
2113 connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
2114 mgr->registerAction( anAction, GlobalPanId );
2116 // Change rotation point
2117 anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
2118 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
2119 tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
2120 anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
2121 anAction->setCheckable(true);
2122 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
2123 mgr->registerAction( anAction, ChangeRotationPointId );
2126 anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
2127 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
2128 tr( "MNU_ROTATE_VIEW" ), 0, this);
2129 anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
2130 connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
2131 mgr->registerAction( anAction, RotationId );
2134 anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
2135 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
2136 tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
2137 anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
2138 connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
2139 this->addAction(anAction);
2140 mgr->registerAction( anAction, FrontId );
2142 anAction = new QtxAction(tr("MNU_BACK_VIEW"),
2143 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
2144 tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
2145 anAction->setStatusTip(tr("DSC_BACK_VIEW"));
2146 connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
2147 this->addAction(anAction);
2148 mgr->registerAction( anAction, BackId );
2150 anAction = new QtxAction(tr("MNU_TOP_VIEW"),
2151 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
2152 tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
2153 anAction->setStatusTip(tr("DSC_TOP_VIEW"));
2154 connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
2155 this->addAction(anAction);
2156 mgr->registerAction( anAction, TopId );
2158 anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
2159 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
2160 tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
2161 anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
2162 connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
2163 this->addAction(anAction);
2164 mgr->registerAction( anAction, BottomId );
2166 anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
2167 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
2168 tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
2169 anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
2170 connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
2171 this->addAction(anAction);
2172 mgr->registerAction( anAction, LeftId );
2174 anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
2175 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
2176 tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
2177 anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
2178 connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
2179 this->addAction(anAction);
2180 mgr->registerAction( anAction, RightId );
2182 // rotate anticlockwise
2183 anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
2184 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
2185 tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
2186 anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
2187 connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
2188 this->addAction(anAction);
2189 mgr->registerAction( anAction, AntiClockWiseId );
2192 anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
2193 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
2194 tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
2195 anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
2196 connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
2197 this->addAction(anAction);
2198 mgr->registerAction( anAction, ClockWiseId );
2201 anAction = new QtxAction(tr("MNU_RESET_VIEW"),
2202 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
2203 tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
2204 anAction->setStatusTip(tr("DSC_RESET_VIEW"));
2205 connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
2206 this->addAction(anAction);
2207 mgr->registerAction( anAction, ResetId );
2209 // onViewTrihedron: Shows - Hides Trihedron
2210 anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
2211 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
2212 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
2213 anAction->setCheckable( true );
2214 anAction->setChecked( true );
2216 anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
2217 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
2218 mgr->registerAction( anAction, ViewTrihedronId );
2220 // onNonIsometric: Manage non-isometric params
2221 anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
2222 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
2223 tr( "MNU_SVTK_SCALING" ), 0, this);
2224 anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
2225 anAction->setCheckable(true);
2226 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
2227 mgr->registerAction( anAction, NonIsometric );
2229 // onGraduatedAxes: Manage graduated axes params
2230 anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
2231 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
2232 tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
2233 anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
2234 anAction->setCheckable(true);
2235 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
2236 mgr->registerAction( anAction, GraduatedAxes );
2238 // onGraduatedAxes: Manage graduated axes params
2239 anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"),
2240 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
2241 tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
2242 anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
2243 anAction->setCheckable(true);
2244 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
2245 mgr->registerAction( anAction, UpdateRate );
2247 // Set perspective mode group
2248 anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"),
2249 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
2250 tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
2251 anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
2252 anAction->setCheckable(true);
2253 //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
2254 mgr->registerAction( anAction, ParallelModeId );
2256 anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"),
2257 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
2258 tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
2259 anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
2260 anAction->setCheckable(true);
2261 //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
2262 mgr->registerAction( anAction, ProjectionModeId );
2264 anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
2265 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ),
2266 tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
2267 anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
2268 anAction->setCheckable(true);
2269 //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
2270 mgr->registerAction( anAction, StereoModeId );
2272 QActionGroup* aPerspectiveGroup = new QActionGroup( this );
2273 aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
2274 aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
2275 aPerspectiveGroup->addAction( mgr->action( StereoModeId ) );
2276 connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onPerspectiveMode()));
2279 anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
2280 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
2281 tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
2282 anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
2283 anAction->setCheckable(true);
2284 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
2285 mgr->registerAction( anAction, ViewParametersId );
2288 mgr->registerAction( synchronizeAction(), SynchronizeId );
2290 // Switch between interaction styles
2291 anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
2292 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
2293 tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
2294 anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
2295 anAction->setCheckable(true);
2296 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
2297 mgr->registerAction( anAction, SwitchInteractionStyleId );
2299 // Switch between zooming styles
2300 anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"),
2301 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
2302 tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
2303 anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
2304 anAction->setCheckable(true);
2305 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
2306 mgr->registerAction( anAction, SwitchZoomingStyleId );
2309 QSignalMapper* aSignalMapper = new QSignalMapper( this );
2310 connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int)));
2312 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_STANDARD"),
2313 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ),
2314 tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
2315 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
2316 anAction->setCheckable(true);
2317 connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
2318 aSignalMapper->setMapping( anAction, Standard_Preselection );
2319 mgr->registerAction( anAction, StandardPreselectionId );
2321 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DYNAMIC"),
2322 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DYNAMIC" ) ),
2323 tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
2324 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
2325 anAction->setCheckable(true);
2326 connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
2327 aSignalMapper->setMapping( anAction, Dynamic_Preselection );
2328 mgr->registerAction( anAction, DynamicPreselectionId );
2330 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DISABLED"),
2331 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DISABLED" ) ),
2332 tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
2333 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
2334 anAction->setCheckable(true);
2335 connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
2336 aSignalMapper->setMapping( anAction, Preselection_Disabled );
2337 mgr->registerAction( anAction, DisablePreselectionId );
2339 QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true );
2340 aPreselectionAction->add( getAction( StandardPreselectionId ) );
2341 aPreselectionAction->add( getAction( DynamicPreselectionId ) );
2342 aPreselectionAction->add( getAction( DisablePreselectionId ) );
2343 mgr->registerAction( aPreselectionAction, PreselectionId );
2346 anAction = new QtxAction(tr("MNU_SVTK_ENABLE_SELECTION"),
2347 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SELECTION" ) ),
2348 tr( "MNU_SVTK_ENABLE_SELECTION" ), 0, this);
2349 anAction->setStatusTip(tr("DSC_SVTK_ENABLE_SELECTION"));
2350 anAction->setCheckable(true);
2351 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool)));
2352 mgr->registerAction( anAction, EnableSelectionId );
2355 myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
2356 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
2357 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
2358 myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
2359 connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
2360 mgr->registerAction( myStartAction, StartRecordingId );
2363 myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
2364 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
2365 tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
2366 myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
2367 myPlayAction->setEnabled( false );
2368 connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
2369 mgr->registerAction( myPlayAction, PlayRecordingId );
2372 myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
2373 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
2374 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
2375 myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
2376 myPauseAction->setEnabled( false );
2377 connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
2378 mgr->registerAction( myPauseAction, PauseRecordingId );
2381 myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
2382 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
2383 tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
2384 myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
2385 myStopAction->setEnabled( false );
2386 connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
2387 mgr->registerAction( myStopAction, StopRecordingId );
2391 Creates toolbar of svtk main window
2393 void SVTK_ViewWindow::createToolBar()
2395 QtxActionToolMgr* mgr = toolMgr();
2397 mgr->append( DumpId, myToolBar );
2398 mgr->append( SwitchInteractionStyleId, myToolBar );
2399 mgr->append( SwitchZoomingStyleId, myToolBar );
2401 mgr->append( mgr->separator(), myToolBar );
2403 mgr->append( PreselectionId, myToolBar );
2404 mgr->append( EnableSelectionId, myToolBar );
2406 mgr->append( mgr->separator(), myToolBar );
2408 mgr->append( ViewTrihedronId, myToolBar );
2410 QtxMultiAction* aScaleAction = new QtxMultiAction( this );
2411 aScaleAction->insertAction( getAction( FitAllId ) );
2412 aScaleAction->insertAction( getAction( FitRectId ) );
2413 aScaleAction->insertAction( getAction( FitSelectionId ) );
2414 aScaleAction->insertAction( getAction( ZoomId ) );
2415 mgr->append( aScaleAction, myToolBar );
2417 QtxMultiAction* aPanningAction = new QtxMultiAction( this );
2418 aPanningAction->insertAction( getAction( PanId ) );
2419 aPanningAction->insertAction( getAction( GlobalPanId ) );
2420 mgr->append( aPanningAction, myToolBar );
2422 mgr->append( ChangeRotationPointId, myToolBar );
2424 mgr->append( RotationId, myToolBar );
2426 QtxMultiAction* aViewsAction = new QtxMultiAction( this );
2427 aViewsAction->insertAction( getAction( FrontId ) );
2428 aViewsAction->insertAction( getAction( BackId ) );
2429 aViewsAction->insertAction( getAction( TopId ) );
2430 aViewsAction->insertAction( getAction( BottomId ) );
2431 aViewsAction->insertAction( getAction( LeftId ) );
2432 aViewsAction->insertAction( getAction( RightId ) );
2433 mgr->append( aViewsAction, myToolBar );
2435 mgr->append( AntiClockWiseId, myToolBar );
2436 mgr->append( ClockWiseId, myToolBar );
2438 mgr->append( ResetId, myToolBar );
2440 mgr->append( UpdateRate, myToolBar );
2441 mgr->append( NonIsometric, myToolBar );
2442 mgr->append( GraduatedAxes, myToolBar );
2444 mgr->append( ViewParametersId, myToolBar );
2445 mgr->append( SynchronizeId, myToolBar );
2447 mgr->append( toolMgr()->separator(), myToolBar );
2449 mgr->append( ParallelModeId, myToolBar );
2450 mgr->append( ProjectionModeId, myToolBar );
2451 mgr->append( StereoModeId, myToolBar );
2453 mgr->append( StartRecordingId, myRecordingToolBar );
2454 mgr->append( PlayRecordingId, myRecordingToolBar );
2455 mgr->append( PauseRecordingId, myRecordingToolBar );
2456 mgr->append( StopRecordingId, myRecordingToolBar );
2459 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
2462 myUpdateRateDlg->Update();
2463 myUpdateRateDlg->show();
2465 myUpdateRateDlg->hide();
2468 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
2471 myNonIsometricDlg->Update();
2472 myNonIsometricDlg->show();
2474 myNonIsometricDlg->hide();
2477 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
2480 myCubeAxesDlg->Update();
2481 myCubeAxesDlg->show();
2483 myCubeAxesDlg->hide();
2487 Starts rotation transformation
2489 void SVTK_ViewWindow::activateRotation()
2491 myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
2496 Starts panning transformation
2498 void SVTK_ViewWindow::activatePanning()
2500 myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
2504 Starts zoom transformation
2506 void SVTK_ViewWindow::activateZoom()
2508 myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
2512 Starts window fit transformation
2514 void SVTK_ViewWindow::activateWindowFit()
2516 myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
2520 Starts global panning transformation
2522 void SVTK_ViewWindow::activateGlobalPanning()
2524 myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
2527 void SVTK_ViewWindow::onStartRecording()
2529 myRecorder->CheckExistAVIMaker();
2530 if (myRecorder->ErrorStatus()) {
2531 SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
2534 SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
2536 if( !aRecorderDlg->exec() )
2539 myStartAction->setEnabled( false );
2540 myPlayAction->setEnabled( false );
2541 myPauseAction->setEnabled( true );
2542 myStopAction->setEnabled( true );
2544 // to prevent resizing the window while recording
2545 myPreRecordingMinSize = minimumSize();
2546 myPreRecordingMaxSize = maximumSize();
2547 setFixedSize( size() );
2549 myRecorder->Record();
2553 void SVTK_ViewWindow::onPlayRecording()
2555 myStartAction->setEnabled( false );
2556 myPlayAction->setEnabled( false );
2557 myPauseAction->setEnabled( true );
2558 myStopAction->setEnabled( true );
2560 myRecorder->Pause();
2563 void SVTK_ViewWindow::onPauseRecording()
2565 myStartAction->setEnabled( false );
2566 myPlayAction->setEnabled( true );
2567 myPauseAction->setEnabled( false );
2568 myStopAction->setEnabled( true );
2570 myRecorder->Pause();
2573 void SVTK_ViewWindow::onStopRecording()
2575 myStartAction->setEnabled( true );
2576 myPlayAction->setEnabled( false );
2577 myPauseAction->setEnabled( false );
2578 myStopAction->setEnabled( false );
2582 setMinimumSize( myPreRecordingMinSize );
2583 setMaximumSize( myPreRecordingMaxSize );
2587 To invoke a VTK event on SVTK_RenderWindowInteractor instance
2589 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
2591 GetInteractor()->InvokeEvent(theEvent,theCallData);
2595 Modify view parameters
2597 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
2600 myViewParameterDlg->addObserver();
2601 myViewParameterDlg->show();
2603 myViewParameterDlg->hide();
2607 Custom show event handler
2609 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent )
2611 emit Show( theEvent );
2615 Custom hide event handler
2617 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
2619 emit Hide( theEvent );
2623 Emit transformed signal.
2625 void SVTK_ViewWindow::emitTransformed() {
2632 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
2633 unsigned long theEvent,
2634 void* theClientData,
2637 SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
2639 self->emitTransformed();
2643 Get camera properties for the SVTK view window.
2644 \return shared pointer on camera properties.
2646 SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
2648 SUIT_CameraProperties aProps;
2651 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2655 aProps.setDimension( SUIT_CameraProperties::Dim3D );
2656 if ( toolMgr()->action( ParallelModeId ) ) {
2657 if ( toolMgr()->action( ParallelModeId )->isChecked() )
2658 aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
2660 aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
2663 double aFocalPoint[3];
2664 double aPosition[3];
2666 double anAxialScale[3];
2668 aCamera->OrthogonalizeViewUp();
2669 aCamera->GetFocalPoint( aFocalPoint );
2670 aCamera->GetPosition( aPosition );
2671 aCamera->GetViewUp( aViewUp );
2673 aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2674 aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
2675 aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2676 aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
2678 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2680 aProps.setViewAngle( aCamera->GetViewAngle() );
2683 GetRenderer()->GetScale( anAxialScale );
2684 aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2691 This implementation synchronizes camera propreties.
2693 void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2695 bool blocked = blockSignals( true );
2697 SUIT_CameraProperties aProps = theView->cameraProperties();
2698 if ( !cameraProperties().isCompatible( aProps ) ) {
2699 // other view, this one is being currently synchronized to, seems has become incompatible
2700 // we have to break synchronization
2706 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2708 double aFocalPoint[3];
2709 double aPosition[3];
2711 double anAxialScale[3];
2713 // get common properties
2714 aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2715 aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
2716 aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2717 aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2719 // restore properties to the camera
2720 aCamera->SetViewUp( aViewUp );
2721 aCamera->SetPosition( aPosition );
2722 aCamera->SetFocalPoint( aFocalPoint );
2723 aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
2725 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2727 aCamera->SetViewAngle( aProps.getViewAngle() );
2730 GetRenderer()->SetScale( anAxialScale );
2732 getRenderer()->ResetCameraClippingRange();
2735 blockSignals( blocked );