1 // Copyright (C) 2007-2016 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_PsOptionsDlg.h"
27 #include "SVTK_SetRotationPointDlg.h"
28 #include "SVTK_ViewParameterDlg.h"
29 #include "SVTK_ViewModel.h"
30 #include "VTKViewer_Texture.h"
31 #include "VTKViewer_OpenGLRenderer.h"
33 #include "SALOME_Actor.h"
39 #include <QSignalMapper>
40 #include <QXmlStreamWriter>
41 #include <QXmlStreamReader>
42 #include <QXmlStreamAttributes>
44 #include <vtkTextProperty.h>
45 #include <vtkActorCollection.h>
46 #include <vtkRenderWindow.h>
47 #include <vtkRenderer.h>
48 #include <vtkCamera.h>
49 #include <vtkPointPicker.h>
50 #include <vtkCellPicker.h>
51 #include <vtkAxisActor2D.h>
52 #include <vtkGL2PSExporter.h>
53 #include <vtkInteractorStyle.h>
54 #include <vtkProperty.h>
55 #include <vtkCallbackCommand.h>
56 #include <vtkJPEGReader.h>
57 #include <vtkBMPReader.h>
58 #include <vtkTIFFReader.h>
59 #include <vtkPNGReader.h>
60 #include <vtkMetaImageReader.h>
61 #include <vtkImageMapToColors.h>
62 #include <vtkTexture.h>
64 #include "QtxAction.h"
66 #include "SUIT_Session.h"
67 #include "SUIT_MessageBox.h"
68 #include "SUIT_Accel.h"
69 #include "SUIT_Tools.h"
70 #include "SUIT_ResourceMgr.h"
71 #include "SUIT_Accel.h"
72 #include "SUIT_OverrideCursor.h"
73 #include "SUIT_ViewManager.h"
74 #include "QtxActionToolMgr.h"
75 #include "QtxMultiAction.h"
76 #include "QtxActionGroup.h"
78 #include "VTKViewer_Utilities.h"
79 #include "VTKViewer_Trihedron.h"
80 #include "VTKViewer_Actor.h"
82 #include "SVTK_View.h"
83 #include "SVTK_Selector.h"
85 #include "SVTK_Event.h"
86 #include "SVTK_Renderer.h"
87 #include "SVTK_ViewWindow.h"
88 #include "SVTK_InteractorStyle.h"
89 #include "SVTK_RenderWindowInteractor.h"
90 #include "SVTK_GenericRenderWindowInteractor.h"
91 #include "SVTK_CubeAxesActor2D.h"
92 #include "SVTK_ComboAction.h"
93 #include "SVTK_KeyFreeInteractorStyle.h"
94 #include "SVTK_Selector.h"
95 #include "SVTK_Recorder.h"
96 #include "SVTK_RecorderDlg.h"
98 #include "salomevtkPVAxesWidget.h"
99 #include "salomevtkPVAxesActor.h"
101 #include "SALOME_ListIO.hxx"
103 #include "VTKViewer_Algorithm.h"
104 #include "SVTK_Functor.h"
106 #include <OpenGLUtils_FrameBuffer.h>
112 int convertAction( const int accelAction )
114 switch ( accelAction ) {
115 case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
116 case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
117 case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
118 case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
119 case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
120 case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
121 case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
122 case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
123 case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
124 case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
133 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
134 SUIT_ViewWindow(theDesktop),
136 myDumpImage(QImage()),
137 myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
138 myEventCallbackCommand(vtkCallbackCommand::New())
140 setWindowFlags( windowFlags() & ~Qt::Window );
141 // specific of vtkSmartPointer
142 myKeyFreeInteractorStyle->Delete();
146 To initialize #SVTK_ViewWindow instance
148 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
151 myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
153 SVTK_Selector* aSelector = SVTK_Selector::New();
154 int aPreselectionMode = SUIT_Session::session()->resourceMgr()->
155 integerValue( "VTKViewer", "preselection", Standard_Preselection );
156 aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection );
157 aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled );
158 bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
159 booleanValue( "VTKViewer", "enable_selection", true );
160 aSelector->SetSelectionEnabled( isSelectionEnabled );
162 SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
163 aDevice->SetRenderWidget(myInteractor);
164 aDevice->SetSelector(aSelector);
166 SVTK_Renderer* aRenderer = SVTK_Renderer::New();
167 aRenderer->Initialize(aDevice,aSelector);
169 myInteractor->Initialize(aDevice,aRenderer,aSelector);
175 myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant)
176 QString( "VTKViewerViewOperations" ), // name (language-independant)
177 false ); // disable floatable toolbar
179 myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant)
180 QString( "VTKRecordingOperations" ), // name (language-independant)
181 false ); // disable floatable toolbar
183 createActions( SUIT_Session::session()->resourceMgr() );
186 SetEventDispatcher(myInteractor->GetDevice());
187 myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
188 myInteractor->setFocusPolicy(Qt::StrongFocus);
189 myInteractor->setFocus();
190 bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()->
191 booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
192 myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
193 setFocusProxy(myInteractor);
195 myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
196 myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
197 myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
198 myCubeAxesDlg->initialize();
199 mySetRotationPointDlg = new SVTK_SetRotationPointDlg
200 ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
201 myViewParameterDlg = new SVTK_ViewParameterDlg
202 ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
204 myDefaultInteractorStyle = SVTK_InteractorStyle::New();
205 myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
206 myDefaultInteractorStyle->Delete();
208 myRecorder = SVTK_Recorder::New();
210 myRecorder->SetNbFPS( 17.3 );
211 myRecorder->SetQuality( 100 );
212 myRecorder->SetProgressiveMode( true );
213 myRecorder->SetUseSkippedFrames( true );
214 myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
216 setCentralWidget(myInteractor);
218 myAxesWidget = salomevtk::vtkPVAxesWidget::New();
219 myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
220 myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
221 myAxesWidget->SetInteractor(myInteractor->GetDevice());
222 myAxesWidget->SetEnabled(1);
223 myAxesWidget->SetInteractive(0);
225 salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
226 anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 );
227 anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
228 anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
229 anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 );
230 anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
231 anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
232 anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 );
233 anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
234 anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
236 myView = new SVTK_View(this);
237 Initialize(myView,theModel);
240 myEventCallbackCommand->SetClientData(this);
241 myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
242 myEventCallbackCommand->Delete();
244 GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
245 myEventCallbackCommand.GetPointer(), 0.0);
246 myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
247 myEventCallbackCommand.GetPointer(), 0.0);
251 myInteractor->getRenderWindow()->Render();
252 setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
257 To initialize #SVTK_ViewWindow instance
259 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
260 SVTK_ViewModelBase* theModel)
262 connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
263 this,SLOT(onKeyPressed(QKeyEvent*)) );
264 connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
265 this,SLOT(onKeyReleased(QKeyEvent*)));
266 connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
267 this,SLOT(onMousePressed(QMouseEvent*)));
268 connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
269 this,SLOT(onMouseReleased(QMouseEvent*)));
270 connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
271 this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
272 connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
273 this,SLOT(onMouseMoving(QMouseEvent*)));
274 connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
275 this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
276 connect(theView,SIGNAL(selectionChanged()),
277 theModel,SLOT(onSelectionChanged()));
279 connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
285 SVTK_ViewWindow::~SVTK_ViewWindow()
287 myRecorder->Delete();
288 myAxesWidget->Delete();
293 \return corresponding view
295 SVTK_View* SVTK_ViewWindow::getView()
301 \return corresponding vtk render window
303 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
305 return GetInteractor()->getRenderWindow();
309 \return corresponding vtk render window interactor
311 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
317 \return corresponding vtk render window interactor
319 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
321 return myInteractor->GetDevice();
325 \return corresponding vtk renderer
327 vtkRenderer* SVTK_ViewWindow::getRenderer() const
329 return GetInteractor()->getRenderer();
333 Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
335 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
337 return GetInteractor()->GetRenderer();
341 \return corresponding vtk selector
343 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
345 return GetInteractor()->GetSelector();
349 Processes transformation "front view"
351 void SVTK_ViewWindow::onFrontView()
353 GetRenderer()->OnFrontView();
355 emit transformed( this );
359 Processes transformation "back view"
361 void SVTK_ViewWindow::onBackView()
363 GetRenderer()->OnBackView();
365 emit transformed( this );
369 Processes transformation "top view"
371 void SVTK_ViewWindow::onTopView()
373 GetRenderer()->OnTopView();
375 emit transformed( this );
379 Processes transformation "bottom view"
381 void SVTK_ViewWindow::onBottomView()
383 GetRenderer()->OnBottomView();
385 emit transformed( this );
389 Processes transformation "left view"
391 void SVTK_ViewWindow::onLeftView()
393 GetRenderer()->OnLeftView();
395 emit transformed( this );
399 Processes transformation "right view"
401 void SVTK_ViewWindow::onRightView()
403 GetRenderer()->OnRightView();
405 emit transformed( this );
409 \brief Rotate view 90 degrees clockwise
411 void SVTK_ViewWindow::onClockWiseView()
413 GetRenderer()->onClockWiseView();
415 emit transformed( this );
419 \brief Rotate view 90 degrees conterclockwise
421 void SVTK_ViewWindow::onAntiClockWiseView()
423 GetRenderer()->onAntiClockWiseView();
425 emit transformed( this );
429 Processes transformation "reset view": sets default orientation of viewport camera
431 void SVTK_ViewWindow::onResetView()
433 GetRenderer()->OnResetView();
435 emit transformed( this );
439 Processes transformation "fit all"
441 void SVTK_ViewWindow::onFitAll()
443 GetRenderer()->OnFitAll();
445 emit transformed( this );
449 Processes transformation "fit selection"
451 void SVTK_ViewWindow::onFitSelection()
453 GetRenderer()->onFitSelection();
455 emit transformed( this );
459 SLOT: called if selection is changed
461 void SVTK_ViewWindow::onSelectionChanged()
463 myView->onSelectionChanged();
467 Change selection mode
468 \param theMode - new selection mode
470 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
472 GetSelector()->SetSelectionMode(theMode);
476 \return selection mode
478 Selection_Mode SVTK_ViewWindow::SelectionMode() const
480 return GetSelector()->SelectionMode();
484 Unhilights all objects in viewer
486 void SVTK_ViewWindow::unHighlightAll()
488 myView->unHighlightAll();
492 Hilights/unhilights object in viewer
493 \param theIO - object to be updated
494 \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
495 \param theIsUpdate - update current viewer
497 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO,
501 myView->highlight( theIO, theIsHighlight, theIsUpdate );
505 \return true if object is in viewer or in collector
506 \param theIO - object to be checked
508 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
510 return myView->isInViewer( theIO );
514 \return true if object is displayed in viewer
515 \param theIO - object to be checked
517 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
519 return myView->isVisible( theIO );
524 \param theEntry - entry that corresponds to intractive objects
526 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry)
528 return myView->FindIObject(theEntry);
533 \param theIO - object
534 \param theImmediatly - update viewer
536 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
539 myView->Display(theIO,theImmediatly);
544 \param theIO - object
545 \param theImmediatly - update viewer
547 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
550 myView->Erase(theIO,theImmediatly);
554 Display only passed object
555 \param theIO - object
557 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
559 myView->DisplayOnly(theIO);
563 Display all objects in view
565 void SVTK_ViewWindow::DisplayAll()
567 myView->DisplayAll();
571 Erase all objects in view
573 void SVTK_ViewWindow::EraseAll()
579 Sets background color [obsolete]
580 \param color - new background color
582 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
584 Qtx::BackgroundData bg = background();
590 \return background color of viewer [obsolete]
592 QColor SVTK_ViewWindow::backgroundColor() const
594 return background().color();
599 \param bgData - new background data
601 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
605 if ( bgData.isValid() ) {
606 switch ( bgData.mode() ) {
607 case Qtx::ColorBackground:
609 QColor c = bgData.color();
611 // show solid-colored background
612 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
613 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
614 getRenderer()->SetBackground( c.red()/255.0,
616 c.blue()/255.0 ); // set background color
621 case Qtx::SimpleGradientBackground:
624 int type = bgData.gradient( c1, c2 );
630 // show two-color gradient background
631 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
632 getRenderer()->SetGradientBackground( true ); // switch to gradient mode
634 VTKViewer_OpenGLRenderer* aRenderer =
635 VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
638 aRenderer->SetGradientType( type );
639 aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
640 aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
646 case Qtx::CustomGradientBackground:
648 // NOT IMPLEMENTED YET
649 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
650 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
657 if ( bgData.isTextureShown() ) {
659 int textureMode = bgData.texture( fileName );
660 QFileInfo fi( fileName );
661 if ( !fileName.isEmpty() && fi.exists() ) {
662 // read texture from file
663 QString extension = fi.suffix().toLower();
664 vtkImageReader2* aReader = 0;
665 if ( extension == "jpg" || extension == "jpeg" )
666 aReader = vtkJPEGReader::New();
667 else if ( extension == "bmp" )
668 aReader = vtkBMPReader::New();
669 else if ( extension == "tif" || extension == "tiff" )
670 aReader = vtkTIFFReader::New();
671 else if ( extension == "png" )
672 aReader = vtkPNGReader::New();
673 else if ( extension == "mhd" || extension == "mha" )
674 aReader = vtkMetaImageReader::New();
677 aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
679 VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
680 vtkImageMapToColors* aMap = 0;
681 vtkAlgorithmOutput* anOutput;
683 // special processing for BMP reader
684 vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
686 // Special processing for BMP file
687 aBMPReader->SetAllow8BitBMP(1);
689 aMap = vtkImageMapToColors::New();
690 aMap->SetInputConnection( aBMPReader->GetOutputPort() );
691 aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
692 aMap->SetOutputFormatToRGB();
694 anOutput = aMap->GetOutputPort();
699 anOutput = aReader->GetOutputPort( 0 );
700 aTexture->SetInputConnection( anOutput );
702 // VSR: Currently, VTK only supports Stretch mode, so below code will give
703 // the same results for all modes
704 switch ( textureMode ) {
705 case Qtx::TileTexture:
706 aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
708 case Qtx::StretchTexture:
709 aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
711 case Qtx::CenterTexture:
712 aTexture->SetPosition((int)VTKViewer_Texture::Centered);
716 // show textured background
717 getRenderer()->SetTexturedBackground( true );
718 getRenderer()->SetBackgroundTexture( aTexture );
720 // clean-up resources
731 myBackground = bgData;
735 \return background data of viewer
737 Qtx::BackgroundData SVTK_ViewWindow::background() const
744 Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
746 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
748 return GetInteractor()->GetInteractorStyle();
752 Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
754 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
756 GetInteractor()->PushInteractorStyle(theStyle);
760 Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
762 void SVTK_ViewWindow::PopInteractorStyle()
764 GetInteractor()->PopInteractorStyle();
768 Updates current viewer
770 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
772 if(theUpdateTrihedron)
773 GetRenderer()->OnAdjustTrihedron();
775 GetInteractor()->update();
777 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
783 Redirect the request to #SVTK_Renderer::GetScale
785 void SVTK_ViewWindow::GetScale( double theScale[3] )
787 GetRenderer()->GetScale( theScale );
791 Redirect the request to #SVTK_Renderer::SetScale
793 void SVTK_ViewWindow::SetScale( double theScale[3] )
795 GetRenderer()->SetScale( theScale );
797 emit transformed( this );
801 Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
803 bool SVTK_ViewWindow::isTrihedronDisplayed()
805 return GetRenderer()->IsTrihedronDisplayed();
809 Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
811 bool SVTK_ViewWindow::isCubeAxesDisplayed()
813 return GetRenderer()->IsCubeAxesDisplayed();
817 Redirect the request to #SVTK_Renderer::OnViewTrihedron
819 void SVTK_ViewWindow::onViewTrihedron(bool show)
821 GetRenderer()->SetTrihedronVisibility(show);
826 Redirect the request to #SVTK_Renderer::OnViewCubeAxes
828 void SVTK_ViewWindow::onViewCubeAxes()
830 GetRenderer()->OnViewCubeAxes();
835 Redirect the request to #SVTK_Renderer::GetTrihedron
837 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
839 return GetRenderer()->GetTrihedron();
843 Redirect the request to #SVTK_Renderer::GetCubeAxes
845 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
847 return GetRenderer()->GetCubeAxes();
851 \return trihedron size
853 double SVTK_ViewWindow::GetTrihedronSize() const
855 return GetRenderer()->GetTrihedronSize();
860 \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo )
862 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
864 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
865 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
866 QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
870 onProjectionMode( aParallelAction );
873 onProjectionMode( aProjectionAction );
876 onStereoMode( true );
880 // update action state if method is called outside
881 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
882 QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
883 if ( theMode == Parallel && !aParallelAction->isChecked() ) {
884 aParallelAction->setChecked( true );
885 aSwitchZoomingStyle->setEnabled(true);
886 aStereoAction->setChecked( false );
888 if ( theMode == Projection && !aProjectionAction->isChecked() ) {
889 aProjectionAction->setChecked( true );
890 aSwitchZoomingStyle->setEnabled(false);
892 if ( theMode == Stereo ) {
893 aStereoAction->setChecked( true );
894 if ( aParallelAction->isEnabled() ) {
895 aParallelAction->setEnabled( false );
896 aParallelAction->setChecked( false );
897 aStereoAction->setChecked( false );
900 aParallelAction->setEnabled( true );
901 aStereoAction->setChecked( false );
902 aParallelAction->setChecked( aViewer->projectionMode() == Parallel );
904 if ( aProjectionAction->isEnabled() ) {
905 aProjectionAction->setEnabled( false );
906 aProjectionAction->setChecked( true );
907 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
908 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
909 toolMgr()->action( StereoModeId )->isChecked() ) {
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 Set support quad-buffered stereo
988 \param theEnable - enable/disable support quad-buffered stereo
990 void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable)
992 vtkRenderWindow* aWindow = getRenderWindow();
993 aWindow->SetStereoCapableWindow((int)theEnable);
997 \return OpenGl stereo support
999 bool SVTK_ViewWindow::isOpenGlStereoSupport() const
1001 GLboolean support[1];
1002 glGetBooleanv (GL_STEREO, support);
1009 Set the gravity center as a focal point
1011 void SVTK_ViewWindow::activateSetFocalPointGravity()
1013 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
1017 Set the selected point as a focal point
1019 void SVTK_ViewWindow::activateSetFocalPointSelected()
1021 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
1025 Set the point selected by user as a focal point
1027 void SVTK_ViewWindow::activateStartFocalPointSelection()
1029 myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
1032 void SVTK_ViewWindow::activateProjectionMode(int theMode)
1034 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
1035 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
1037 aParallelAction->setChecked( true );
1039 aProjectionAction->setChecked( true );
1041 if ( !aParallelAction->isEnabled() )
1042 aParallelAction->setEnabled( true );
1043 if ( !aProjectionAction->isEnabled() )
1044 aProjectionAction->setEnabled( true );
1048 Sets actual interaction style
1049 \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
1051 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
1053 onSwitchInteractionStyle( theStyle==1 );
1057 Sets actual zooming style
1058 \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) )
1060 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
1062 onSwitchZoomingStyle( theStyle==1 );
1066 Set preselection mode.
1067 \param theMode the mode to set (standard, dynamic or disabled)
1069 void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
1071 onSwitchPreSelectionMode( theMode );
1075 Enables/disables selection.
1076 \param theEnable if true - selection will be enabled
1078 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
1080 GetSelector()->SetSelectionEnabled( theEnable );
1081 QtxAction* a = getAction( EnableSelectionId );
1082 if ( a->isChecked() != theEnable)
1083 a->setChecked( theEnable );
1084 QtxActionGroup* aPreselectionGroup =
1085 dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
1086 if ( aPreselectionGroup )
1087 aPreselectionGroup->setEnabled( theEnable );
1090 vtkActorCollection *actors = getRenderer()->GetActors();
1091 for (int i = 0; i < actors->GetNumberOfItems(); ++i )
1092 if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
1094 cout << "actor " << actor << endl;
1095 actor->EnableSelection( theEnable );
1100 Switches "keyboard free" interaction style on/off
1102 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
1105 // check if style is already set
1106 if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
1108 // keep the same style extensions
1109 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
1111 myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
1112 myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
1115 PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
1119 // pop only key free style
1120 if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
1121 PopInteractorStyle();
1124 // update action state if method is called outside
1125 QtxAction* a = getAction( SwitchInteractionStyleId );
1126 if ( a->isChecked() != theOn ) a->setChecked( theOn );
1130 Toogles advanced zooming style (relatively to the cursor position) on/off
1132 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
1134 if( myDefaultInteractorStyle.GetPointer() )
1135 myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1136 if( myKeyFreeInteractorStyle.GetPointer() )
1137 myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1139 // update action state if method is called outside
1140 QtxAction* a = getAction( SwitchZoomingStyleId );
1141 if ( a->isChecked() != theOn )
1142 a->setChecked( theOn );
1146 Switch preselection mode.
1147 \param theMode the preselection mode
1149 void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
1151 GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection );
1152 GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled );
1154 // update action state if method is called outside
1155 QtxAction* a = getAction( StandardPreselectionId + theMode );
1156 if ( a && !a->isChecked() )
1157 a->setChecked( true );
1161 Enables/disables selection.
1162 \param theOn if true - selection will be enabled
1164 void SVTK_ViewWindow::onEnableSelection( bool on )
1166 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
1168 aViewer->enableSelection(on);
1172 Sets incremental speed
1173 \param theValue - new incremental speed
1174 \param theMode - modification mode
1176 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
1178 if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
1179 ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
1183 Sets spacemouse buttons for the functions
1184 \param theBtn1 - spacemouse button for the "decrease speed increment"
1185 \param theBtn2 - spacemouse button for the "increase speed increment"
1186 \param theBtn3 - spacemouse button for the "dominant combined switch"
1188 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1,
1193 myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
1195 myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
1197 myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
1202 \param theSize - new trihedron size
1203 \param theRelative - trihedron relativeness
1205 void SVTK_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative)
1207 GetRenderer()->SetTrihedronSize(theSize, theRelative);
1211 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
1212 * trihedron and cube axes, even if trihedron and cube axes is invisible.
1214 void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
1216 GetRenderer()->AdjustActors();
1221 Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
1223 void SVTK_ViewWindow::onAdjustTrihedron()
1225 GetRenderer()->OnAdjustTrihedron();
1229 Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
1231 void SVTK_ViewWindow::onAdjustCubeAxes()
1233 GetRenderer()->OnAdjustCubeAxes();
1236 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
1238 if ( otherViewWindow ) {
1239 bool blocked = blockSignals( true );
1240 doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
1241 blockSignals( blocked );
1248 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
1250 emit keyPressed( this, event );
1256 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
1258 emit keyReleased( this, event );
1264 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
1266 emit mousePressed(this, event);
1270 Emits mouse released
1272 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
1274 emit mouseReleased( this, event );
1280 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
1282 emit mouseMoving( this, event );
1286 Emits mouse double clicked
1288 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
1290 emit mouseDoubleClicked( this, event );
1294 Redirect the request to #SVTK_Renderer::AddActor
1296 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor,
1298 bool theIsAdjustActors )
1300 GetRenderer()->AddActor(theActor, theIsAdjustActors);
1303 emit actorAdded(theActor);
1307 Redirect the request to #SVTK_Renderer::RemoveActor
1309 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor,
1311 bool theIsAdjustActors )
1313 GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
1314 if ( myDefaultInteractorStyle )
1315 myDefaultInteractorStyle->FreeActors();
1316 if ( myKeyFreeInteractorStyle )
1317 myKeyFreeInteractorStyle->FreeActors();
1320 emit actorRemoved(theActor);
1323 QImage SVTK_ViewWindow::dumpViewContent()
1325 vtkRenderWindow* aWindow = getRenderWindow();
1326 int* aSize = aWindow->GetSize();
1327 int aWidth = aSize[0];
1328 int aHeight = aSize[1];
1330 #ifndef DISABLE_GLVIEWER
1331 OpenGLUtils_FrameBuffer aFrameBuffer;
1332 if( aFrameBuffer.init( aWidth, aHeight ) )
1334 glPushAttrib( GL_VIEWPORT_BIT );
1335 glViewport( 0, 0, aWidth, aHeight );
1336 aFrameBuffer.bind();
1341 aFrameBuffer.unbind();
1344 QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1346 aFrameBuffer.bind();
1347 glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1348 aFrameBuffer.unbind();
1350 anImage = anImage.rgbSwapped();
1351 anImage = anImage.mirrored();
1356 // if frame buffers are unsupported, use old functionality
1357 unsigned char *aData =
1358 aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
1360 QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
1362 anImage = anImage.rgbSwapped();
1363 anImage = anImage.mirrored();
1368 \return QImage, containing all scene rendering in window
1370 QImage SVTK_ViewWindow::dumpView()
1372 if( myDumpImage.isNull() )
1373 return dumpViewContent();
1379 QString SVTK_ViewWindow::filter() const
1381 return tr( "SVTK_IMAGE_FILES" );
1384 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
1386 if ( format != "PS" && format != "EPS" && format != "PDF" )
1387 return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1389 SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
1390 if ( optionsDlg->exec() == QDialog::Accepted ) {
1391 SUIT_OverrideCursor wc;
1393 vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
1394 anExporter->SetRenderWindow(getRenderWindow());
1397 anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
1398 anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
1399 anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
1400 anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
1401 anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
1403 if ( format == "PS" ) {
1404 anExporter->SetFileFormatToPS();
1405 anExporter->CompressOff();
1408 if ( format == "EPS" ) {
1409 anExporter->SetFileFormatToEPS();
1410 anExporter->CompressOff();
1413 if ( format == "PDF" ) {
1414 anExporter->SetFileFormatToPDF();
1417 QString aFilePrefix(fileName);
1418 QString anExtension(SUIT_Tools::extension(fileName));
1419 aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
1420 anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
1421 anExporter->Write();
1422 anExporter->Delete();
1429 \refresh QImage, containing all scene rendering in window
1431 void SVTK_ViewWindow::RefreshDumpImage()
1433 myDumpImage = dumpViewContent();
1437 Redirect the request to #SVTK_Renderer::SetSelectionProp
1439 void SVTK_ViewWindow::SetSelectionProp(const double& theRed,
1440 const double& theGreen,
1441 const double& theBlue,
1442 const int& theWidth)
1444 myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
1448 Redirect the request to #SVTK_Renderer::SetSelectionProp
1450 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed,
1451 const double& theGreen,
1452 const double& theBlue,
1453 const int& theWidth)
1455 myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
1459 Redirect the request to #SVTK_Renderer::SetSelectionTolerance
1461 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes,
1462 const double& theTolItems,
1463 const double& theTolObjects)
1465 myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
1469 Get visibility status of the static trihedron
1471 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
1473 return (bool)myAxesWidget->GetEnabled();
1477 Set visibility status of the static trihedron
1479 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
1481 myAxesWidget->SetEnabled( (int)theIsVisible );
1486 \param accelAction - action
1488 bool SVTK_ViewWindow::action( const int accelAction )
1490 if ( accelAction == SUIT_Accel::ZoomFit )
1493 int anEvent = SVTK::convertAction( accelAction );
1494 GetInteractor()->InvokeEvent(anEvent, 0);
1500 \return action by it's id
1502 QtxAction* SVTK_ViewWindow::getAction( int id ) const
1504 return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
1508 // old visual parameters had 13 values. New format added additional
1509 // 76 values for graduated axes, so both numbers are processed.
1510 const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
1511 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
1512 const int nTrihedronParams = 3; // number of parameters for Trihedron
1513 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
1515 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
1517 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
1524 bool isVisible = actor->GetTitleVisibility();
1525 QString title ( actor->GetTitle() );
1527 int font = VTK_ARIAL;
1532 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1535 txtProp->GetColor( color );
1536 font = txtProp->GetFontFamily();
1537 bold = txtProp->GetBold();
1538 italic = txtProp->GetItalic();
1539 shadow = txtProp->GetShadow();
1541 writer.writeStartElement("GraduatedAxis");
1542 writer.writeAttribute("Axis", theAxis);
1544 writer.writeStartElement("Title");
1545 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1546 writer.writeAttribute("Text", title);
1547 writer.writeAttribute("Font", QString("%1").arg(font));
1548 writer.writeAttribute("Bold", QString("%1").arg(bold));
1549 writer.writeAttribute("Italic", QString("%1").arg(italic));
1550 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1552 writer.writeStartElement("Color");
1553 writer.writeAttribute("R", QString("%1").arg(color[0]));
1554 writer.writeAttribute("G", QString("%1").arg(color[1]));
1555 writer.writeAttribute("B", QString("%1").arg(color[2]));
1556 writer.writeEndElement();
1557 writer.writeEndElement();
1559 //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
1560 // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1563 isVisible = actor->GetLabelVisibility();
1564 int labels = actor->GetNumberOfLabels();
1565 int offset = actor->GetTickOffset();
1571 txtProp = actor->GetLabelTextProperty();
1574 txtProp->GetColor( color );
1575 font = txtProp->GetFontFamily();
1576 bold = txtProp->GetBold();
1577 italic = txtProp->GetItalic();
1578 shadow = txtProp->GetShadow();
1581 writer.writeStartElement("Labels");
1582 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1583 writer.writeAttribute("Number", QString("%1").arg(labels));
1584 writer.writeAttribute("Offset", QString("%1").arg(offset));
1585 writer.writeAttribute("Font", QString("%1").arg(font));
1586 writer.writeAttribute("Bold", QString("%1").arg(bold));
1587 writer.writeAttribute("Italic", QString("%1").arg(italic));
1588 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1590 writer.writeStartElement("Color");
1591 writer.writeAttribute("R", QString("%1").arg(color[0]));
1592 writer.writeAttribute("G", QString("%1").arg(color[1]));
1593 writer.writeAttribute("B", QString("%1").arg(color[2]));
1594 writer.writeEndElement();
1595 writer.writeEndElement();
1596 // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
1597 // color[0], color[1], color[2], font, bold, italic, shadow );
1600 isVisible = actor->GetTickVisibility();
1601 int length = actor->GetTickLength();
1602 writer.writeStartElement("TickMarks");
1603 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1604 writer.writeAttribute("Length", QString("%1").arg(length));
1605 writer.writeEndElement();
1607 //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1609 writer.writeEndElement();
1613 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1620 } while (!reader.isStartElement());
1622 // Read title params
1623 QXmlStreamAttributes aAttr = reader.attributes();
1624 bool isVisible = aAttr.value("isVisible").toString().toUShort();
1625 QString title = aAttr.value("Text").toString();
1626 int font = aAttr.value("Font").toString().toInt();
1627 int bold = aAttr.value("Bold").toString().toInt();
1628 int italic = aAttr.value("Italic").toString().toInt();
1629 int shadow = aAttr.value("Shadow").toString().toInt();
1631 //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1635 } while (!reader.isStartElement());
1638 aAttr = reader.attributes();
1641 color[0] = aAttr.value("R").toString().toDouble();
1642 color[1] = aAttr.value("G").toString().toDouble();
1643 color[2] = aAttr.value("B").toString().toDouble();
1644 //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1646 actor->SetTitleVisibility( isVisible );
1647 actor->SetTitle( title.toLatin1() );
1648 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1650 txtProp->SetColor( color );
1651 txtProp->SetFontFamily( font );
1652 txtProp->SetBold( bold );
1653 txtProp->SetItalic( italic );
1654 txtProp->SetShadow( shadow );
1661 } while (!reader.isStartElement());
1663 aAttr = reader.attributes();
1664 isVisible = aAttr.value("isVisible").toString().toUShort();
1665 int labels = aAttr.value("Number").toString().toInt();
1666 int offset = aAttr.value("Offset").toString().toInt();
1667 font = aAttr.value("Font").toString().toInt();
1668 bold = aAttr.value("Bold").toString().toInt();
1669 italic = aAttr.value("Italic").toString().toInt();
1670 shadow = aAttr.value("Shadow").toString().toInt();
1674 } while (!reader.isStartElement());
1676 aAttr = reader.attributes();
1678 color[0] = aAttr.value("R").toString().toDouble();
1679 color[1] = aAttr.value("G").toString().toDouble();
1680 color[2] = aAttr.value("B").toString().toDouble();
1682 actor->SetLabelVisibility( isVisible );
1683 actor->SetNumberOfLabels( labels );
1684 actor->SetTickOffset( offset );
1685 txtProp = actor->GetLabelTextProperty();
1687 txtProp->SetColor( color );
1688 txtProp->SetFontFamily( font );
1689 txtProp->SetBold( bold );
1690 txtProp->SetItalic( italic );
1691 txtProp->SetShadow( shadow );
1697 } while (!reader.isStartElement());
1698 aAttr = reader.attributes();
1700 // retrieve and set tick marks properties
1701 isVisible = aAttr.value("isVisible").toString().toUShort();
1702 int length = aAttr.value("Length").toString().toInt();
1704 actor->SetTickVisibility( isVisible );
1705 actor->SetTickLength( length );
1708 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1710 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1715 QStringList paramsLst = params.split( '*' );
1717 if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1719 // retrieve and set name parameters
1720 bool isVisible = paramsLst[2].toUShort();
1721 QString title = paramsLst[3];
1723 color[0] = paramsLst[4].toDouble();
1724 color[1] = paramsLst[5].toDouble();
1725 color[2] = paramsLst[6].toDouble();
1726 int font = paramsLst[7].toInt();
1727 int bold = paramsLst[8].toInt();
1728 int italic = paramsLst[9].toInt();
1729 int shadow = paramsLst[10].toInt();
1731 actor->SetTitleVisibility( isVisible );
1732 actor->SetTitle( title.toLatin1() );
1733 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1735 txtProp->SetColor( color );
1736 txtProp->SetFontFamily( font );
1737 txtProp->SetBold( bold );
1738 txtProp->SetItalic( italic );
1739 txtProp->SetShadow( shadow );
1742 // retrieve and set lable parameters
1743 isVisible = paramsLst[12].toUShort();
1744 int labels = paramsLst[13].toInt();
1745 int offset = paramsLst[14].toInt();
1746 color[0] = paramsLst[15].toDouble();
1747 color[1] = paramsLst[16].toDouble();
1748 color[2] = paramsLst[17].toDouble();
1749 font = paramsLst[18].toInt();
1750 bold = paramsLst[19].toInt();
1751 italic = paramsLst[20].toInt();
1752 shadow = paramsLst[21].toInt();
1754 actor->SetLabelVisibility( isVisible );
1755 actor->SetNumberOfLabels( labels );
1756 actor->SetTickOffset( offset );
1757 txtProp = actor->GetLabelTextProperty();
1759 txtProp->SetColor( color );
1760 txtProp->SetFontFamily( font );
1761 txtProp->SetBold( bold );
1762 txtProp->SetItalic( italic );
1763 txtProp->SetShadow( shadow );
1766 // retrieve and set tick marks properties
1767 isVisible = paramsLst[23].toUShort();
1768 int length = paramsLst[24].toInt();
1770 actor->SetTickVisibility( isVisible );
1771 actor->SetTickLength( length );
1775 /*! The method returns the visual parameters of this view as a formated string
1777 QString SVTK_ViewWindow::getVisualParameters()
1779 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1781 // save position, focal point, viewUp, scale
1782 vtkCamera* camera = getRenderer()->GetActiveCamera();
1783 camera->GetPosition( pos );
1784 camera->GetFocalPoint( focalPnt );
1785 camera->GetViewUp( viewUp );
1786 parScale = camera->GetParallelScale();
1789 // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1790 // view up values (3 digits), parallel scale (1 digit), scale (3 digits,
1791 // Graduated axes parameters (X, Y, Z axes parameters)
1793 QXmlStreamWriter aWriter(&retStr);
1794 aWriter.setAutoFormatting(true);
1796 aWriter.writeStartDocument();
1797 aWriter.writeStartElement("ViewState");
1799 aWriter.writeStartElement("Position");
1800 aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1801 aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1802 aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1803 aWriter.writeEndElement();
1805 aWriter.writeStartElement("FocalPoint");
1806 aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1807 aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1808 aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1809 aWriter.writeEndElement();
1811 aWriter.writeStartElement("ViewUp");
1812 aWriter.writeAttribute("X", QString::number(viewUp[0]));
1813 aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1814 aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1815 aWriter.writeEndElement();
1817 aWriter.writeStartElement("ViewScale");
1818 aWriter.writeAttribute("Parallel", QString::number(parScale));
1819 aWriter.writeAttribute("X", QString::number(scale[0]));
1820 aWriter.writeAttribute("Y", QString::number(scale[1]));
1821 aWriter.writeAttribute("Z", QString::number(scale[2]));
1822 aWriter.writeEndElement();
1824 if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1825 aWriter.writeStartElement("DisplayCubeAxis");
1826 aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1827 aWriter.writeEndElement();
1829 getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1830 getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1831 getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1834 aWriter.writeStartElement("Trihedron");
1835 aWriter.writeAttribute("isShown", QString( "%1" ).arg( isTrihedronDisplayed()));
1836 aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1837 aWriter.writeEndElement();
1839 aWriter.writeStartElement("Background");
1840 aWriter.writeAttribute("Value", QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
1841 aWriter.writeEndElement();
1843 aWriter.writeEndElement();
1844 aWriter.writeEndDocument();
1850 The method restores visual parameters of this view or postpones it untill the view is shown
1852 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1854 //printf("#### %s\n", qPrintable(parameters));
1855 SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1856 if ( anInteractor->isVisible() ) {
1857 doSetVisualParameters( parameters );
1860 myVisualParams = parameters;
1861 anInteractor->installEventFilter(this);
1866 The method restores visual parameters of this view from a formated string
1868 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
1871 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1873 QXmlStreamReader aReader(parameters);
1874 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1876 while(!aReader.atEnd()) {
1878 if (aReader.isStartElement()) {
1879 QXmlStreamAttributes aAttr = aReader.attributes();
1880 //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1881 if (aReader.name() == "Position") {
1882 pos[0] = aAttr.value("X").toString().toDouble();
1883 pos[1] = aAttr.value("Y").toString().toDouble();
1884 pos[2] = aAttr.value("Z").toString().toDouble();
1885 //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1887 else if (aReader.name() == "FocalPoint") {
1888 focalPnt[0] = aAttr.value("X").toString().toDouble();
1889 focalPnt[1] = aAttr.value("Y").toString().toDouble();
1890 focalPnt[2] = aAttr.value("Z").toString().toDouble();
1891 //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1893 else if (aReader.name() == "ViewUp") {
1894 viewUp[0] = aAttr.value("X").toString().toDouble();
1895 viewUp[1] = aAttr.value("Y").toString().toDouble();
1896 viewUp[2] = aAttr.value("Z").toString().toDouble();
1897 //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1899 else if (aReader.name() == "ViewScale") {
1900 parScale = aAttr.value("Parallel").toString().toDouble();
1901 scale[0] = aAttr.value("X").toString().toDouble();
1902 scale[1] = aAttr.value("Y").toString().toDouble();
1903 scale[2] = aAttr.value("Z").toString().toDouble();
1904 //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1906 else if (aReader.name() == "DisplayCubeAxis") {
1907 if ( !baseParamsOnly ) {
1908 if (aAttr.value("Show") == "0")
1909 gradAxesActor->VisibilityOff();
1911 gradAxesActor->VisibilityOn();
1914 else if (aReader.name() == "GraduatedAxis") {
1915 if ( !baseParamsOnly ) {
1916 if(aAttr.value("Axis") == "X")
1917 setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1918 else if(aAttr.value("Axis") == "Y")
1919 setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1920 else if(aAttr.value("Axis") == "Z")
1921 setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1924 else if (aReader.name() == "Trihedron") {
1925 if ( !baseParamsOnly ) {
1926 if (aAttr.value("isShown") == "0")
1927 GetTrihedron()->VisibilityOff();
1929 GetTrihedron()->VisibilityOn();
1930 SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1933 else if (aReader.name() == "Background") {
1934 if ( !baseParamsOnly ) {
1935 setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
1940 if (!aReader.hasError()) {
1941 vtkCamera* camera = getRenderer()->GetActiveCamera();
1942 camera->SetPosition( pos );
1943 camera->SetFocalPoint( focalPnt );
1944 camera->SetViewUp( viewUp );
1945 camera->SetParallelScale( parScale );
1946 GetRenderer()->SetScale( scale );
1947 //SetScale( scale );
1950 QStringList paramsLst = parameters.split( '*' );
1951 if ( paramsLst.size() >= nNormalParams ) {
1952 // 'reading' list of parameters
1953 pos[0] = paramsLst[0].toDouble();
1954 pos[1] = paramsLst[1].toDouble();
1955 pos[2] = paramsLst[2].toDouble();
1956 focalPnt[0] = paramsLst[3].toDouble();
1957 focalPnt[1] = paramsLst[4].toDouble();
1958 focalPnt[2] = paramsLst[5].toDouble();
1959 viewUp[0] = paramsLst[6].toDouble();
1960 viewUp[1] = paramsLst[7].toDouble();
1961 viewUp[2] = paramsLst[8].toDouble();
1962 parScale = paramsLst[9].toDouble();
1963 scale[0] = paramsLst[10].toDouble();
1964 scale[1] = paramsLst[11].toDouble();
1965 scale[2] = paramsLst[12].toDouble();
1967 // applying parameters
1968 vtkCamera* camera = getRenderer()->GetActiveCamera();
1969 camera->SetPosition( pos );
1970 camera->SetFocalPoint( focalPnt );
1971 camera->SetViewUp( viewUp );
1972 camera->SetParallelScale( parScale );
1973 GetRenderer()->SetScale( scale );
1974 //SetScale( scale );
1976 // apply graduated axes parameters
1977 if ( !baseParamsOnly ) {
1978 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1979 if ( gradAxesActor && paramsLst.size() == nAllParams ) {
1980 int i = nNormalParams+1, j = i + nGradAxisParams - 1;
1981 ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
1982 i = j + 1; j += nGradAxisParams;
1983 ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
1984 i = j + 1; j += nGradAxisParams;
1985 ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
1987 if ( paramsLst[13].toUShort() )
1988 gradAxesActor->VisibilityOn();
1990 gradAxesActor->VisibilityOff();
1992 else if ( paramsLst.size() == nAllParams ) {
1993 if ( paramsLst[90].toUShort() )
1994 GetTrihedron()->VisibilityOn();
1996 GetTrihedron()->VisibilityOff();
1998 SetTrihedronSize(paramsLst[91].toDouble());
2008 Delayed setVisualParameters
2010 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
2012 if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
2013 SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
2014 if ( anInteractor->isVisible() ) {
2015 doSetVisualParameters( myVisualParams );
2016 anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
2019 return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
2024 Change rotation point
2026 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
2029 mySetRotationPointDlg->addObserver();
2030 if ( mySetRotationPointDlg->IsFirstShown() )
2031 activateSetRotationGravity();
2032 mySetRotationPointDlg->show();
2034 mySetRotationPointDlg->hide();
2038 Set the gravity center as a rotation point
2040 void SVTK_ViewWindow::activateSetRotationGravity()
2042 myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
2046 Set the selected point as a rotation point
2048 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
2050 myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
2054 Set the gravity center of element selected by user as a rotation point
2056 void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
2058 SetSelectionMode( theSelectionMode );
2059 myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
2063 \brief Set the given projection mode.
2065 Set the given projection mode: Orthographic or Perspective.
2067 void SVTK_ViewWindow::onProjectionMode( QAction* theAction )
2069 int aMode = Parallel;
2070 if (theAction == toolMgr()->action( ProjectionModeId ))
2072 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2073 aViewer->setProjectionMode(aMode);
2074 bool anIsParallelMode = (aMode == Parallel);
2075 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2076 aCamera->SetParallelProjection(anIsParallelMode);
2077 GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
2078 getRenderWindow()->SetStereoRender(0);
2083 \brief Sets Stereo projection mode.
2085 Sets Stereo projection mode.
2087 void SVTK_ViewWindow::onStereoMode( bool activate )
2090 toolMgr()->action( ProjectionModeId )->setChecked(true);
2091 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2092 aCamera->SetParallelProjection(false);
2093 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false);
2094 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2095 SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
2096 getRenderWindow()->SetStereoRender(1);
2100 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true);
2101 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2102 if (aViewer->projectionMode() == Parallel) {
2103 toolMgr()->action( ParallelModeId )->setChecked(true);
2104 onProjectionMode(toolMgr()->action( ParallelModeId ));
2106 else if (aViewer->projectionMode() == Projection) {
2107 toolMgr()->action( ProjectionModeId )->setChecked(true);
2108 onProjectionMode(toolMgr()->action( ProjectionModeId ));
2111 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
2112 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
2113 toolMgr()->action( StereoModeId )->isChecked() )
2114 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
2118 Set the view projection mode: orthogonal or perspective
2120 void SVTK_ViewWindow::onProjectionMode()
2122 if (toolMgr()->action( ParallelModeId )->isChecked())
2123 SetProjectionMode( Parallel);
2124 if (toolMgr()->action( ProjectionModeId )->isChecked())
2125 SetProjectionMode( Projection);
2126 if (toolMgr()->action( StereoModeId )->isChecked())
2127 SetProjectionMode( Stereo);
2128 emit transformed( this );
2131 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
2133 myEventDispatcher = theDispatcher;
2137 Creates all actions of svtk main window
2139 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
2141 QtxAction* anAction;
2142 QtxActionToolMgr* mgr = toolMgr();
2145 anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
2146 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
2147 tr( "MNU_DUMP_VIEW" ), 0, this);
2148 anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
2149 connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
2150 mgr->registerAction( anAction, DumpId );
2153 anAction = new QtxAction(tr("MNU_FITALL"),
2154 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
2155 tr( "MNU_FITALL" ), 0, this);
2156 anAction->setStatusTip(tr("DSC_FITALL"));
2157 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
2158 mgr->registerAction( anAction, FitAllId );
2161 anAction = new QtxAction(tr("MNU_FITRECT"),
2162 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
2163 tr( "MNU_FITRECT" ), 0, this);
2164 anAction->setStatusTip(tr("DSC_FITRECT"));
2165 connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
2166 mgr->registerAction( anAction, FitRectId );
2169 anAction = new QtxAction(tr("MNU_FITSELECTION"),
2170 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
2171 tr( "MNU_FITSELECTION" ), 0, this);
2172 anAction->setStatusTip(tr("DSC_FITSELECTION"));
2173 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
2174 mgr->registerAction( anAction, FitSelectionId );
2177 anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
2178 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
2179 tr( "MNU_ZOOM_VIEW" ), 0, this);
2180 anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
2181 connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
2182 mgr->registerAction( anAction, ZoomId );
2185 anAction = new QtxAction(tr("MNU_PAN_VIEW"),
2186 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
2187 tr( "MNU_PAN_VIEW" ), 0, this);
2188 anAction->setStatusTip(tr("DSC_PAN_VIEW"));
2189 connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
2190 mgr->registerAction( anAction, PanId );
2193 anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
2194 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
2195 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
2196 anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
2197 connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
2198 mgr->registerAction( anAction, GlobalPanId );
2200 // Change rotation point
2201 anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
2202 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
2203 tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
2204 anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
2205 anAction->setCheckable(true);
2206 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
2207 mgr->registerAction( anAction, ChangeRotationPointId );
2210 anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
2211 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
2212 tr( "MNU_ROTATE_VIEW" ), 0, this);
2213 anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
2214 connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
2215 mgr->registerAction( anAction, RotationId );
2218 anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
2219 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
2220 tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
2221 anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
2222 connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
2223 this->addAction(anAction);
2224 mgr->registerAction( anAction, FrontId );
2226 anAction = new QtxAction(tr("MNU_BACK_VIEW"),
2227 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
2228 tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
2229 anAction->setStatusTip(tr("DSC_BACK_VIEW"));
2230 connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView()));
2231 this->addAction(anAction);
2232 mgr->registerAction( anAction, BackId );
2234 anAction = new QtxAction(tr("MNU_TOP_VIEW"),
2235 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
2236 tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
2237 anAction->setStatusTip(tr("DSC_TOP_VIEW"));
2238 connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView()));
2239 this->addAction(anAction);
2240 mgr->registerAction( anAction, TopId );
2242 anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
2243 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
2244 tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
2245 anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
2246 connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
2247 this->addAction(anAction);
2248 mgr->registerAction( anAction, BottomId );
2250 anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
2251 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
2252 tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
2253 anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
2254 connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
2255 this->addAction(anAction);
2256 mgr->registerAction( anAction, LeftId );
2258 anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
2259 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
2260 tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
2261 anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
2262 connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView()));
2263 this->addAction(anAction);
2264 mgr->registerAction( anAction, RightId );
2266 // rotate anticlockwise
2267 anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
2268 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
2269 tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
2270 anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
2271 connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
2272 this->addAction(anAction);
2273 mgr->registerAction( anAction, AntiClockWiseId );
2276 anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
2277 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
2278 tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
2279 anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
2280 connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
2281 this->addAction(anAction);
2282 mgr->registerAction( anAction, ClockWiseId );
2285 anAction = new QtxAction(tr("MNU_RESET_VIEW"),
2286 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
2287 tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
2288 anAction->setStatusTip(tr("DSC_RESET_VIEW"));
2289 connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView()));
2290 this->addAction(anAction);
2291 mgr->registerAction( anAction, ResetId );
2293 // onViewTrihedron: Shows - Hides Trihedron
2294 anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
2295 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
2296 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
2297 anAction->setCheckable( true );
2298 anAction->setChecked( true );
2300 anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
2301 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
2302 mgr->registerAction( anAction, ViewTrihedronId );
2304 // onNonIsometric: Manage non-isometric params
2305 anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
2306 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
2307 tr( "MNU_SVTK_SCALING" ), 0, this);
2308 anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
2309 anAction->setCheckable(true);
2310 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
2311 mgr->registerAction( anAction, NonIsometric );
2313 // onGraduatedAxes: Manage graduated axes params
2314 anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
2315 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
2316 tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
2317 anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
2318 anAction->setCheckable(true);
2319 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
2320 mgr->registerAction( anAction, GraduatedAxes );
2322 // onGraduatedAxes: Manage graduated axes params
2323 anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"),
2324 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
2325 tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
2326 anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
2327 anAction->setCheckable(true);
2328 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
2329 mgr->registerAction( anAction, UpdateRate );
2331 // Set perspective mode group
2332 anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"),
2333 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
2334 tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
2335 anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
2336 anAction->setCheckable(true);
2337 mgr->registerAction( anAction, ParallelModeId );
2339 anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"),
2340 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
2341 tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
2342 anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
2343 anAction->setCheckable(true);
2344 mgr->registerAction( anAction, ProjectionModeId );
2346 anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
2347 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ),
2348 tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
2349 anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
2350 anAction->setCheckable(true);
2351 connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool)));
2352 mgr->registerAction( anAction, StereoModeId );
2354 QActionGroup* aPerspectiveGroup = new QActionGroup( this );
2355 aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
2356 aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
2357 connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*)));
2360 anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
2361 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
2362 tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
2363 anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
2364 anAction->setCheckable(true);
2365 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
2366 mgr->registerAction( anAction, ViewParametersId );
2369 mgr->registerAction( synchronizeAction(), SynchronizeId );
2371 // Switch between interaction styles
2372 anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
2373 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
2374 tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
2375 anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
2376 anAction->setCheckable(true);
2377 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
2378 mgr->registerAction( anAction, SwitchInteractionStyleId );
2380 // Switch between zooming styles
2381 anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"),
2382 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
2383 tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
2384 anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
2385 anAction->setCheckable(true);
2386 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
2387 mgr->registerAction( anAction, SwitchZoomingStyleId );
2390 QSignalMapper* aSignalMapper = new QSignalMapper( this );
2391 connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int)));
2393 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_STANDARD"),
2394 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ),
2395 tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
2396 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
2397 anAction->setCheckable(true);
2398 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2399 aSignalMapper->setMapping( anAction, Standard_Preselection );
2400 mgr->registerAction( anAction, StandardPreselectionId );
2402 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DYNAMIC"),
2403 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DYNAMIC" ) ),
2404 tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
2405 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
2406 anAction->setCheckable(true);
2407 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2408 aSignalMapper->setMapping( anAction, Dynamic_Preselection );
2409 mgr->registerAction( anAction, DynamicPreselectionId );
2411 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DISABLED"),
2412 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DISABLED" ) ),
2413 tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
2414 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
2415 anAction->setCheckable(true);
2416 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2417 aSignalMapper->setMapping( anAction, Preselection_Disabled );
2418 mgr->registerAction( anAction, DisablePreselectionId );
2420 QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true );
2421 aPreselectionAction->add( getAction( StandardPreselectionId ) );
2422 aPreselectionAction->add( getAction( DynamicPreselectionId ) );
2423 aPreselectionAction->add( getAction( DisablePreselectionId ) );
2424 mgr->registerAction( aPreselectionAction, PreselectionId );
2427 anAction = new QtxAction(tr("MNU_SVTK_ENABLE_SELECTION"),
2428 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SELECTION" ) ),
2429 tr( "MNU_SVTK_ENABLE_SELECTION" ), 0, this);
2430 anAction->setStatusTip(tr("DSC_SVTK_ENABLE_SELECTION"));
2431 anAction->setCheckable(true);
2432 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool)));
2433 mgr->registerAction( anAction, EnableSelectionId );
2436 myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
2437 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
2438 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
2439 myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
2440 connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
2441 mgr->registerAction( myStartAction, StartRecordingId );
2444 myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
2445 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
2446 tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
2447 myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
2448 myPlayAction->setEnabled( false );
2449 connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
2450 mgr->registerAction( myPlayAction, PlayRecordingId );
2453 myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
2454 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
2455 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
2456 myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
2457 myPauseAction->setEnabled( false );
2458 connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
2459 mgr->registerAction( myPauseAction, PauseRecordingId );
2462 myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
2463 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
2464 tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
2465 myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
2466 myStopAction->setEnabled( false );
2467 connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
2468 mgr->registerAction( myStopAction, StopRecordingId );
2472 Creates toolbar of svtk main window
2474 void SVTK_ViewWindow::createToolBar()
2476 QtxActionToolMgr* mgr = toolMgr();
2478 mgr->append( DumpId, myToolBar );
2479 mgr->append( SwitchInteractionStyleId, myToolBar );
2480 mgr->append( SwitchZoomingStyleId, myToolBar );
2482 mgr->append( mgr->separator(), myToolBar );
2484 mgr->append( PreselectionId, myToolBar );
2485 mgr->append( EnableSelectionId, myToolBar );
2487 mgr->append( mgr->separator(), myToolBar );
2489 mgr->append( ViewTrihedronId, myToolBar );
2491 QtxMultiAction* aScaleAction = new QtxMultiAction( this );
2492 aScaleAction->insertAction( getAction( FitAllId ) );
2493 aScaleAction->insertAction( getAction( FitRectId ) );
2494 aScaleAction->insertAction( getAction( FitSelectionId ) );
2495 aScaleAction->insertAction( getAction( ZoomId ) );
2496 mgr->append( aScaleAction, myToolBar );
2498 QtxMultiAction* aPanningAction = new QtxMultiAction( this );
2499 aPanningAction->insertAction( getAction( PanId ) );
2500 aPanningAction->insertAction( getAction( GlobalPanId ) );
2501 mgr->append( aPanningAction, myToolBar );
2503 mgr->append( ChangeRotationPointId, myToolBar );
2505 mgr->append( RotationId, myToolBar );
2507 QtxMultiAction* aViewsAction = new QtxMultiAction( this );
2508 aViewsAction->insertAction( getAction( FrontId ) );
2509 aViewsAction->insertAction( getAction( BackId ) );
2510 aViewsAction->insertAction( getAction( TopId ) );
2511 aViewsAction->insertAction( getAction( BottomId ) );
2512 aViewsAction->insertAction( getAction( LeftId ) );
2513 aViewsAction->insertAction( getAction( RightId ) );
2514 mgr->append( aViewsAction, myToolBar );
2516 mgr->append( AntiClockWiseId, myToolBar );
2517 mgr->append( ClockWiseId, myToolBar );
2519 mgr->append( ResetId, myToolBar );
2521 mgr->append( UpdateRate, myToolBar );
2522 mgr->append( NonIsometric, myToolBar );
2523 mgr->append( GraduatedAxes, myToolBar );
2525 mgr->append( ViewParametersId, myToolBar );
2526 mgr->append( SynchronizeId, myToolBar );
2528 mgr->append( toolMgr()->separator(), myToolBar );
2530 mgr->append( ParallelModeId, myToolBar );
2531 mgr->append( ProjectionModeId, myToolBar );
2532 mgr->append( StereoModeId, myToolBar );
2534 mgr->append( StartRecordingId, myRecordingToolBar );
2535 mgr->append( PlayRecordingId, myRecordingToolBar );
2536 mgr->append( PauseRecordingId, myRecordingToolBar );
2537 mgr->append( StopRecordingId, myRecordingToolBar );
2540 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
2543 myUpdateRateDlg->Update();
2544 myUpdateRateDlg->show();
2546 myUpdateRateDlg->hide();
2549 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
2552 myNonIsometricDlg->Update();
2553 myNonIsometricDlg->show();
2555 myNonIsometricDlg->hide();
2558 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
2561 myCubeAxesDlg->Update();
2562 myCubeAxesDlg->show();
2564 myCubeAxesDlg->hide();
2568 Starts rotation transformation
2570 void SVTK_ViewWindow::activateRotation()
2572 myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
2577 Starts panning transformation
2579 void SVTK_ViewWindow::activatePanning()
2581 myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
2585 Starts zoom transformation
2587 void SVTK_ViewWindow::activateZoom()
2589 myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
2593 Starts window fit transformation
2595 void SVTK_ViewWindow::activateWindowFit()
2597 myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
2601 Starts global panning transformation
2603 void SVTK_ViewWindow::activateGlobalPanning()
2605 myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
2608 void SVTK_ViewWindow::onStartRecording()
2610 myRecorder->CheckExistAVIMaker();
2611 if (myRecorder->ErrorStatus()) {
2612 SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
2615 SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
2617 if( !aRecorderDlg->exec() )
2620 myStartAction->setEnabled( false );
2621 myPlayAction->setEnabled( false );
2622 myPauseAction->setEnabled( true );
2623 myStopAction->setEnabled( true );
2625 // to prevent resizing the window while recording
2626 myPreRecordingMinSize = minimumSize();
2627 myPreRecordingMaxSize = maximumSize();
2628 setFixedSize( size() );
2630 myRecorder->Record();
2634 void SVTK_ViewWindow::onPlayRecording()
2636 myStartAction->setEnabled( false );
2637 myPlayAction->setEnabled( false );
2638 myPauseAction->setEnabled( true );
2639 myStopAction->setEnabled( true );
2641 myRecorder->Pause();
2644 void SVTK_ViewWindow::onPauseRecording()
2646 myStartAction->setEnabled( false );
2647 myPlayAction->setEnabled( true );
2648 myPauseAction->setEnabled( false );
2649 myStopAction->setEnabled( true );
2651 myRecorder->Pause();
2654 void SVTK_ViewWindow::onStopRecording()
2656 myStartAction->setEnabled( true );
2657 myPlayAction->setEnabled( false );
2658 myPauseAction->setEnabled( false );
2659 myStopAction->setEnabled( false );
2663 setMinimumSize( myPreRecordingMinSize );
2664 setMaximumSize( myPreRecordingMaxSize );
2668 To invoke a VTK event on SVTK_RenderWindowInteractor instance
2670 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
2672 GetInteractor()->InvokeEvent(theEvent,theCallData);
2676 Modify view parameters
2678 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
2681 myViewParameterDlg->addObserver();
2682 myViewParameterDlg->show();
2684 myViewParameterDlg->hide();
2688 Custom show event handler
2690 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent )
2692 emit Show( theEvent );
2696 Custom hide event handler
2698 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
2700 emit Hide( theEvent );
2704 Emit transformed signal.
2706 void SVTK_ViewWindow::emitTransformed() {
2713 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
2714 unsigned long theEvent,
2715 void* theClientData,
2718 SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
2720 self->emitTransformed();
2724 Get camera properties for the SVTK view window.
2725 \return shared pointer on camera properties.
2727 SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
2729 SUIT_CameraProperties aProps;
2732 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2736 aProps.setDimension( SUIT_CameraProperties::Dim3D );
2737 if ( toolMgr()->action( ParallelModeId ) ) {
2738 if ( toolMgr()->action( ParallelModeId )->isChecked() )
2739 aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
2741 aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
2744 double aFocalPoint[3];
2745 double aPosition[3];
2747 double anAxialScale[3];
2749 aCamera->OrthogonalizeViewUp();
2750 aCamera->GetFocalPoint( aFocalPoint );
2751 aCamera->GetPosition( aPosition );
2752 aCamera->GetViewUp( aViewUp );
2754 aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2755 aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
2756 aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2757 aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
2759 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2761 aProps.setViewAngle( aCamera->GetViewAngle() );
2764 GetRenderer()->GetScale( anAxialScale );
2765 aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2772 This implementation synchronizes camera propreties.
2774 void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2776 bool blocked = blockSignals( true );
2778 SUIT_CameraProperties aProps = theView->cameraProperties();
2779 if ( !cameraProperties().isCompatible( aProps ) ) {
2780 // other view, this one is being currently synchronized to, seems has become incompatible
2781 // we have to break synchronization
2787 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2789 double aFocalPoint[3];
2790 double aPosition[3];
2792 double anAxialScale[3];
2794 // get common properties
2795 aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2796 aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
2797 aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2798 aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2800 // restore properties to the camera
2801 aCamera->SetViewUp( aViewUp );
2802 aCamera->SetPosition( aPosition );
2803 aCamera->SetFocalPoint( aFocalPoint );
2804 aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
2806 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2808 aCamera->SetViewAngle( aProps.getViewAngle() );
2811 GetRenderer()->SetScale( anAxialScale );
2813 getRenderer()->ResetCameraClippingRange();
2816 blockSignals( blocked );