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>
109 #include <OpenGL/gl.h>
116 int convertAction( const int accelAction )
118 switch ( accelAction ) {
119 case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
120 case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
121 case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
122 case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
123 case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
124 case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
125 case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
126 case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
127 case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
128 case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
137 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
138 SUIT_ViewWindow(theDesktop),
140 myDumpImage(QImage()),
141 myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
142 myEventCallbackCommand(vtkCallbackCommand::New())
144 setWindowFlags( windowFlags() & ~Qt::Window );
145 // specific of vtkSmartPointer
146 myKeyFreeInteractorStyle->Delete();
150 To initialize #SVTK_ViewWindow instance
152 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
155 myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
157 SVTK_Selector* aSelector = SVTK_Selector::New();
158 int aPreselectionMode = SUIT_Session::session()->resourceMgr()->
159 integerValue( "VTKViewer", "preselection", Standard_Preselection );
160 aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection );
161 aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled );
162 bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
163 booleanValue( "VTKViewer", "enable_selection", true );
164 aSelector->SetSelectionEnabled( isSelectionEnabled );
166 SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
167 aDevice->SetRenderWidget(myInteractor);
168 aDevice->SetSelector(aSelector);
170 SVTK_Renderer* aRenderer = SVTK_Renderer::New();
171 aRenderer->Initialize(aDevice,aSelector);
173 myInteractor->Initialize(aDevice,aRenderer,aSelector);
179 myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant)
180 QString( "VTKViewerViewOperations" ), // name (language-independant)
181 false ); // disable floatable toolbar
183 myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant)
184 QString( "VTKRecordingOperations" ), // name (language-independant)
185 false ); // disable floatable toolbar
187 createActions( SUIT_Session::session()->resourceMgr() );
190 SetEventDispatcher(myInteractor->GetDevice());
191 myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
192 myInteractor->setFocusPolicy(Qt::StrongFocus);
193 myInteractor->setFocus();
194 bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()->
195 booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
196 myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
197 setFocusProxy(myInteractor);
199 myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
200 myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
201 myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
202 myCubeAxesDlg->initialize();
203 mySetRotationPointDlg = new SVTK_SetRotationPointDlg
204 ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
205 myViewParameterDlg = new SVTK_ViewParameterDlg
206 ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
208 myDefaultInteractorStyle = SVTK_InteractorStyle::New();
209 myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
210 myDefaultInteractorStyle->Delete();
212 myRecorder = SVTK_Recorder::New();
214 myRecorder->SetNbFPS( 17.3 );
215 myRecorder->SetQuality( 100 );
216 myRecorder->SetProgressiveMode( true );
217 myRecorder->SetUseSkippedFrames( true );
218 myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
220 setCentralWidget(myInteractor);
222 myAxesWidget = salomevtk::vtkPVAxesWidget::New();
223 myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
224 myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
225 myAxesWidget->SetInteractor(myInteractor->GetDevice());
226 myAxesWidget->SetEnabled(1);
227 myAxesWidget->SetInteractive(0);
229 salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
230 anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 );
231 anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
232 anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
233 anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 );
234 anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
235 anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
236 anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 );
237 anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
238 anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
240 myView = new SVTK_View(this);
241 Initialize(myView,theModel);
244 myEventCallbackCommand->SetClientData(this);
245 myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
246 myEventCallbackCommand->Delete();
248 GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
249 myEventCallbackCommand.GetPointer(), 0.0);
250 myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
251 myEventCallbackCommand.GetPointer(), 0.0);
255 myInteractor->getRenderWindow()->Render();
256 setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
261 To initialize #SVTK_ViewWindow instance
263 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
264 SVTK_ViewModelBase* theModel)
266 connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
267 this,SLOT(onKeyPressed(QKeyEvent*)) );
268 connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
269 this,SLOT(onKeyReleased(QKeyEvent*)));
270 connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
271 this,SLOT(onMousePressed(QMouseEvent*)));
272 connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
273 this,SLOT(onMouseReleased(QMouseEvent*)));
274 connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
275 this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
276 connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
277 this,SLOT(onMouseMoving(QMouseEvent*)));
278 connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
279 this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
280 connect(theView,SIGNAL(selectionChanged()),
281 theModel,SLOT(onSelectionChanged()));
283 connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
289 SVTK_ViewWindow::~SVTK_ViewWindow()
291 myRecorder->Delete();
292 myAxesWidget->Delete();
297 \return corresponding view
299 SVTK_View* SVTK_ViewWindow::getView()
305 \return corresponding vtk render window
307 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
309 return GetInteractor()->getRenderWindow();
313 \return corresponding vtk render window interactor
315 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
321 \return corresponding vtk render window interactor
323 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
325 return myInteractor->GetDevice();
329 \return corresponding vtk renderer
331 vtkRenderer* SVTK_ViewWindow::getRenderer() const
333 return GetInteractor()->getRenderer();
337 Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
339 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
341 return GetInteractor()->GetRenderer();
345 \return corresponding vtk selector
347 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
349 return GetInteractor()->GetSelector();
353 Processes transformation "front view"
355 void SVTK_ViewWindow::onFrontView()
357 GetRenderer()->OnFrontView();
359 emit transformed( this );
363 Processes transformation "back view"
365 void SVTK_ViewWindow::onBackView()
367 GetRenderer()->OnBackView();
369 emit transformed( this );
373 Processes transformation "top view"
375 void SVTK_ViewWindow::onTopView()
377 GetRenderer()->OnTopView();
379 emit transformed( this );
383 Processes transformation "bottom view"
385 void SVTK_ViewWindow::onBottomView()
387 GetRenderer()->OnBottomView();
389 emit transformed( this );
393 Processes transformation "left view"
395 void SVTK_ViewWindow::onLeftView()
397 GetRenderer()->OnLeftView();
399 emit transformed( this );
403 Processes transformation "right view"
405 void SVTK_ViewWindow::onRightView()
407 GetRenderer()->OnRightView();
409 emit transformed( this );
413 \brief Rotate view 90 degrees clockwise
415 void SVTK_ViewWindow::onClockWiseView()
417 GetRenderer()->onClockWiseView();
419 emit transformed( this );
423 \brief Rotate view 90 degrees conterclockwise
425 void SVTK_ViewWindow::onAntiClockWiseView()
427 GetRenderer()->onAntiClockWiseView();
429 emit transformed( this );
433 Processes transformation "reset view": sets default orientation of viewport camera
435 void SVTK_ViewWindow::onResetView()
437 GetRenderer()->OnResetView();
439 emit transformed( this );
443 Processes transformation "fit all"
445 void SVTK_ViewWindow::onFitAll()
447 GetRenderer()->OnFitAll();
449 emit transformed( this );
453 Processes transformation "fit selection"
455 void SVTK_ViewWindow::onFitSelection()
457 GetRenderer()->onFitSelection();
459 emit transformed( this );
463 SLOT: called if selection is changed
465 void SVTK_ViewWindow::onSelectionChanged()
467 myView->onSelectionChanged();
471 Change selection mode
472 \param theMode - new selection mode
474 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
476 GetSelector()->SetSelectionMode(theMode);
480 \return selection mode
482 Selection_Mode SVTK_ViewWindow::SelectionMode() const
484 return GetSelector()->SelectionMode();
488 Unhilights all objects in viewer
490 void SVTK_ViewWindow::unHighlightAll()
492 myView->unHighlightAll();
496 Hilights/unhilights object in viewer
497 \param theIO - object to be updated
498 \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
499 \param theIsUpdate - update current viewer
501 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO,
505 myView->highlight( theIO, theIsHighlight, theIsUpdate );
509 \return true if object is in viewer or in collector
510 \param theIO - object to be checked
512 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
514 return myView->isInViewer( theIO );
518 \return true if object is displayed in viewer
519 \param theIO - object to be checked
521 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
523 return myView->isVisible( theIO );
528 \param theEntry - entry that corresponds to intractive objects
530 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry)
532 return myView->FindIObject(theEntry);
537 \param theIO - object
538 \param theImmediatly - update viewer
540 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
543 myView->Display(theIO,theImmediatly);
548 \param theIO - object
549 \param theImmediatly - update viewer
551 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
554 myView->Erase(theIO,theImmediatly);
558 Display only passed object
559 \param theIO - object
561 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
563 myView->DisplayOnly(theIO);
567 Display all objects in view
569 void SVTK_ViewWindow::DisplayAll()
571 myView->DisplayAll();
575 Erase all objects in view
577 void SVTK_ViewWindow::EraseAll()
583 Sets background color [obsolete]
584 \param color - new background color
586 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
588 Qtx::BackgroundData bg = background();
594 \return background color of viewer [obsolete]
596 QColor SVTK_ViewWindow::backgroundColor() const
598 return background().color();
603 \param bgData - new background data
605 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
609 if ( bgData.isValid() ) {
610 switch ( bgData.mode() ) {
611 case Qtx::ColorBackground:
613 QColor c = bgData.color();
615 // show solid-colored background
616 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
617 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
618 getRenderer()->SetBackground( c.red()/255.0,
620 c.blue()/255.0 ); // set background color
625 case Qtx::SimpleGradientBackground:
628 int type = bgData.gradient( c1, c2 );
634 // show two-color gradient background
635 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
636 getRenderer()->SetGradientBackground( true ); // switch to gradient mode
638 VTKViewer_OpenGLRenderer* aRenderer =
639 VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
642 aRenderer->SetGradientType( type );
643 aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
644 aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
650 case Qtx::CustomGradientBackground:
652 // NOT IMPLEMENTED YET
653 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
654 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
661 if ( bgData.isTextureShown() ) {
663 int textureMode = bgData.texture( fileName );
664 QFileInfo fi( fileName );
665 if ( !fileName.isEmpty() && fi.exists() ) {
666 // read texture from file
667 QString extension = fi.suffix().toLower();
668 vtkImageReader2* aReader = 0;
669 if ( extension == "jpg" || extension == "jpeg" )
670 aReader = vtkJPEGReader::New();
671 else if ( extension == "bmp" )
672 aReader = vtkBMPReader::New();
673 else if ( extension == "tif" || extension == "tiff" )
674 aReader = vtkTIFFReader::New();
675 else if ( extension == "png" )
676 aReader = vtkPNGReader::New();
677 else if ( extension == "mhd" || extension == "mha" )
678 aReader = vtkMetaImageReader::New();
681 aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
683 VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
684 vtkImageMapToColors* aMap = 0;
685 vtkAlgorithmOutput* anOutput;
687 // special processing for BMP reader
688 vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
690 // Special processing for BMP file
691 aBMPReader->SetAllow8BitBMP(1);
693 aMap = vtkImageMapToColors::New();
694 aMap->SetInputConnection( aBMPReader->GetOutputPort() );
695 aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
696 aMap->SetOutputFormatToRGB();
698 anOutput = aMap->GetOutputPort();
703 anOutput = aReader->GetOutputPort( 0 );
704 aTexture->SetInputConnection( anOutput );
706 // VSR: Currently, VTK only supports Stretch mode, so below code will give
707 // the same results for all modes
708 switch ( textureMode ) {
709 case Qtx::TileTexture:
710 aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
712 case Qtx::StretchTexture:
713 aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
715 case Qtx::CenterTexture:
716 aTexture->SetPosition((int)VTKViewer_Texture::Centered);
720 // show textured background
721 getRenderer()->SetTexturedBackground( true );
722 getRenderer()->SetBackgroundTexture( aTexture );
724 // clean-up resources
735 myBackground = bgData;
739 \return background data of viewer
741 Qtx::BackgroundData SVTK_ViewWindow::background() const
748 Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
750 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
752 return GetInteractor()->GetInteractorStyle();
756 Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
758 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
760 GetInteractor()->PushInteractorStyle(theStyle);
764 Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
766 void SVTK_ViewWindow::PopInteractorStyle()
768 GetInteractor()->PopInteractorStyle();
772 Updates current viewer
774 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
776 if(theUpdateTrihedron)
777 GetRenderer()->OnAdjustTrihedron();
779 GetInteractor()->update();
781 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
787 Redirect the request to #SVTK_Renderer::GetScale
789 void SVTK_ViewWindow::GetScale( double theScale[3] )
791 GetRenderer()->GetScale( theScale );
795 Redirect the request to #SVTK_Renderer::SetScale
797 void SVTK_ViewWindow::SetScale( double theScale[3] )
799 GetRenderer()->SetScale( theScale );
801 emit transformed( this );
805 Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
807 bool SVTK_ViewWindow::isTrihedronDisplayed()
809 return GetRenderer()->IsTrihedronDisplayed();
813 Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
815 bool SVTK_ViewWindow::isCubeAxesDisplayed()
817 return GetRenderer()->IsCubeAxesDisplayed();
821 Redirect the request to #SVTK_Renderer::OnViewTrihedron
823 void SVTK_ViewWindow::onViewTrihedron(bool show)
825 GetRenderer()->SetTrihedronVisibility(show);
830 Redirect the request to #SVTK_Renderer::OnViewCubeAxes
832 void SVTK_ViewWindow::onViewCubeAxes()
834 GetRenderer()->OnViewCubeAxes();
839 Redirect the request to #SVTK_Renderer::GetTrihedron
841 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
843 return GetRenderer()->GetTrihedron();
847 Redirect the request to #SVTK_Renderer::GetCubeAxes
849 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
851 return GetRenderer()->GetCubeAxes();
855 \return trihedron size
857 double SVTK_ViewWindow::GetTrihedronSize() const
859 return GetRenderer()->GetTrihedronSize();
864 \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo )
866 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
868 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
869 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
870 QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
874 onProjectionMode( aParallelAction );
877 onProjectionMode( aProjectionAction );
880 onStereoMode( true );
884 // update action state if method is called outside
885 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
886 QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
887 if ( theMode == Parallel && !aParallelAction->isChecked() ) {
888 aParallelAction->setChecked( true );
889 aSwitchZoomingStyle->setEnabled(true);
890 aStereoAction->setChecked( false );
892 if ( theMode == Projection && !aProjectionAction->isChecked() ) {
893 aProjectionAction->setChecked( true );
894 aSwitchZoomingStyle->setEnabled(false);
896 if ( theMode == Stereo ) {
897 aStereoAction->setChecked( true );
898 if ( aParallelAction->isEnabled() ) {
899 aParallelAction->setEnabled( false );
900 aParallelAction->setChecked( false );
901 aStereoAction->setChecked( false );
904 aParallelAction->setEnabled( true );
905 aStereoAction->setChecked( false );
906 aParallelAction->setChecked( aViewer->projectionMode() == Parallel );
908 if ( aProjectionAction->isEnabled() ) {
909 aProjectionAction->setEnabled( false );
910 aProjectionAction->setChecked( true );
911 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
912 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
913 toolMgr()->action( StereoModeId )->isChecked() ) {
914 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
918 aProjectionAction->setEnabled( true );
919 aStereoAction->setChecked( false );
920 aProjectionAction->setChecked( aViewer->projectionMode() == Projection );
925 if ( !aParallelAction->isEnabled() )
926 aParallelAction->setEnabled( true );
927 if ( !aProjectionAction->isEnabled() )
928 aProjectionAction->setEnabled( true );
934 \param theType - stereo type
936 void SVTK_ViewWindow::SetStereoType(const int theType)
938 vtkRenderWindow* aWindow = getRenderWindow();
941 aWindow->SetStereoTypeToCrystalEyes();
944 aWindow->SetStereoTypeToRedBlue();
947 aWindow->SetStereoTypeToInterlaced();
950 aWindow->SetStereoTypeToLeft();
953 aWindow->SetStereoTypeToRight();
956 aWindow->SetStereoTypeToDresden();
959 aWindow->SetStereoTypeToAnaglyph();
962 aWindow->SetStereoTypeToCheckerboard();
964 case SplitViewPortHorizontal:
965 aWindow->SetStereoTypeToSplitViewportHorizontal();
972 \param theFilter - anaglyph filter
974 void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter)
976 vtkRenderWindow* aWindow = getRenderWindow();
977 switch (theFilter ) {
979 aWindow->SetAnaglyphColorMask(4,3);
982 aWindow->SetAnaglyphColorMask(6,1);
985 aWindow->SetAnaglyphColorMask(2,5);
991 Set support quad-buffered stereo
992 \param theEnable - enable/disable support quad-buffered stereo
994 void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable)
996 vtkRenderWindow* aWindow = getRenderWindow();
997 aWindow->SetStereoCapableWindow((int)theEnable);
1001 \return OpenGl stereo support
1003 bool SVTK_ViewWindow::isOpenGlStereoSupport() const
1005 GLboolean support[1];
1006 glGetBooleanv (GL_STEREO, support);
1013 Set the gravity center as a focal point
1015 void SVTK_ViewWindow::activateSetFocalPointGravity()
1017 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
1021 Set the selected point as a focal point
1023 void SVTK_ViewWindow::activateSetFocalPointSelected()
1025 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
1029 Set the point selected by user as a focal point
1031 void SVTK_ViewWindow::activateStartFocalPointSelection()
1033 myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
1036 void SVTK_ViewWindow::activateProjectionMode(int theMode)
1038 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
1039 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
1041 aParallelAction->setChecked( true );
1043 aProjectionAction->setChecked( true );
1045 if ( !aParallelAction->isEnabled() )
1046 aParallelAction->setEnabled( true );
1047 if ( !aProjectionAction->isEnabled() )
1048 aProjectionAction->setEnabled( true );
1052 Sets actual interaction style
1053 \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
1055 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
1057 onSwitchInteractionStyle( theStyle==1 );
1061 Sets actual zooming style
1062 \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) )
1064 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
1066 onSwitchZoomingStyle( theStyle==1 );
1070 Set preselection mode.
1071 \param theMode the mode to set (standard, dynamic or disabled)
1073 void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
1075 onSwitchPreSelectionMode( theMode );
1079 Enables/disables selection.
1080 \param theEnable if true - selection will be enabled
1082 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
1084 GetSelector()->SetSelectionEnabled( theEnable );
1085 QtxAction* a = getAction( EnableSelectionId );
1086 if ( a->isChecked() != theEnable)
1087 a->setChecked( theEnable );
1088 QtxActionGroup* aPreselectionGroup =
1089 dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
1090 if ( aPreselectionGroup )
1091 aPreselectionGroup->setEnabled( theEnable );
1094 vtkActorCollection *actors = getRenderer()->GetActors();
1095 for (int i = 0; i < actors->GetNumberOfItems(); ++i )
1096 if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
1098 actor->EnableSelection( theEnable );
1103 Switches "keyboard free" interaction style on/off
1105 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
1108 // check if style is already set
1109 if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
1111 // keep the same style extensions
1112 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
1114 myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
1115 myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
1118 PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
1122 // pop only key free style
1123 if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
1124 PopInteractorStyle();
1127 // update action state if method is called outside
1128 QtxAction* a = getAction( SwitchInteractionStyleId );
1129 if ( a->isChecked() != theOn ) a->setChecked( theOn );
1133 Toogles advanced zooming style (relatively to the cursor position) on/off
1135 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
1137 if( myDefaultInteractorStyle.GetPointer() )
1138 myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1139 if( myKeyFreeInteractorStyle.GetPointer() )
1140 myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1142 // update action state if method is called outside
1143 QtxAction* a = getAction( SwitchZoomingStyleId );
1144 if ( a->isChecked() != theOn )
1145 a->setChecked( theOn );
1149 Switch preselection mode.
1150 \param theMode the preselection mode
1152 void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
1154 GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection );
1155 GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled );
1157 // update action state if method is called outside
1158 QtxAction* a = getAction( StandardPreselectionId + theMode );
1159 if ( a && !a->isChecked() )
1160 a->setChecked( true );
1164 Enables/disables selection.
1165 \param theOn if true - selection will be enabled
1167 void SVTK_ViewWindow::onEnableSelection( bool on )
1169 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
1171 aViewer->enableSelection(on);
1175 Sets incremental speed
1176 \param theValue - new incremental speed
1177 \param theMode - modification mode
1179 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
1181 if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
1182 ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
1186 Sets spacemouse buttons for the functions
1187 \param theBtn1 - spacemouse button for the "decrease speed increment"
1188 \param theBtn2 - spacemouse button for the "increase speed increment"
1189 \param theBtn3 - spacemouse button for the "dominant combined switch"
1191 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1,
1196 myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
1198 myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
1200 myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
1205 \param theSize - new trihedron size
1206 \param theRelative - trihedron relativeness
1208 void SVTK_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative)
1210 GetRenderer()->SetTrihedronSize(theSize, theRelative);
1214 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
1215 * trihedron and cube axes, even if trihedron and cube axes is invisible.
1217 void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
1219 GetRenderer()->AdjustActors();
1224 Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
1226 void SVTK_ViewWindow::onAdjustTrihedron()
1228 GetRenderer()->OnAdjustTrihedron();
1232 Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
1234 void SVTK_ViewWindow::onAdjustCubeAxes()
1236 GetRenderer()->OnAdjustCubeAxes();
1239 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
1241 if ( otherViewWindow ) {
1242 bool blocked = blockSignals( true );
1243 doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
1244 blockSignals( blocked );
1251 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
1253 emit keyPressed( this, event );
1259 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
1261 emit keyReleased( this, event );
1267 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
1269 emit mousePressed(this, event);
1273 Emits mouse released
1275 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
1277 emit mouseReleased( this, event );
1283 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
1285 emit mouseMoving( this, event );
1289 Emits mouse double clicked
1291 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
1293 emit mouseDoubleClicked( this, event );
1297 Redirect the request to #SVTK_Renderer::AddActor
1299 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor,
1301 bool theIsAdjustActors )
1303 GetRenderer()->AddActor(theActor, theIsAdjustActors);
1306 emit actorAdded(theActor);
1310 Redirect the request to #SVTK_Renderer::RemoveActor
1312 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor,
1314 bool theIsAdjustActors )
1316 GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
1317 if ( myDefaultInteractorStyle )
1318 myDefaultInteractorStyle->FreeActors();
1319 if ( myKeyFreeInteractorStyle )
1320 myKeyFreeInteractorStyle->FreeActors();
1323 emit actorRemoved(theActor);
1326 QImage SVTK_ViewWindow::dumpViewContent()
1328 vtkRenderWindow* aWindow = getRenderWindow();
1329 int* aSize = aWindow->GetSize();
1330 int aWidth = aSize[0];
1331 int aHeight = aSize[1];
1333 #ifndef DISABLE_GLVIEWER
1334 OpenGLUtils_FrameBuffer aFrameBuffer;
1335 if( aFrameBuffer.init( aWidth, aHeight ) )
1337 glPushAttrib( GL_VIEWPORT_BIT );
1338 glViewport( 0, 0, aWidth, aHeight );
1339 aFrameBuffer.bind();
1344 aFrameBuffer.unbind();
1347 QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1349 aFrameBuffer.bind();
1350 glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1351 aFrameBuffer.unbind();
1353 anImage = anImage.rgbSwapped();
1354 anImage = anImage.mirrored();
1359 // if frame buffers are unsupported, use old functionality
1360 unsigned char *aData =
1361 aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
1363 QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
1365 anImage = anImage.rgbSwapped();
1366 anImage = anImage.mirrored();
1371 \return QImage, containing all scene rendering in window
1373 QImage SVTK_ViewWindow::dumpView()
1375 if( myDumpImage.isNull() )
1376 return dumpViewContent();
1382 QString SVTK_ViewWindow::filter() const
1384 return tr( "SVTK_IMAGE_FILES" );
1387 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
1389 if ( format != "PS" && format != "EPS" && format != "PDF" )
1390 return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1392 SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
1393 if ( optionsDlg->exec() == QDialog::Accepted ) {
1394 SUIT_OverrideCursor wc;
1396 vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
1397 anExporter->SetRenderWindow(getRenderWindow());
1400 anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
1401 anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
1402 anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
1403 anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
1404 anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
1406 if ( format == "PS" ) {
1407 anExporter->SetFileFormatToPS();
1408 anExporter->CompressOff();
1411 if ( format == "EPS" ) {
1412 anExporter->SetFileFormatToEPS();
1413 anExporter->CompressOff();
1416 if ( format == "PDF" ) {
1417 anExporter->SetFileFormatToPDF();
1420 QString aFilePrefix(fileName);
1421 QString anExtension(SUIT_Tools::extension(fileName));
1422 aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
1423 anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
1424 anExporter->Write();
1425 anExporter->Delete();
1432 \refresh QImage, containing all scene rendering in window
1434 void SVTK_ViewWindow::RefreshDumpImage()
1436 myDumpImage = dumpViewContent();
1440 Redirect the request to #SVTK_Renderer::SetSelectionProp
1442 void SVTK_ViewWindow::SetSelectionProp(const double& theRed,
1443 const double& theGreen,
1444 const double& theBlue,
1445 const int& theWidth)
1447 myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
1451 Redirect the request to #SVTK_Renderer::SetSelectionProp
1453 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed,
1454 const double& theGreen,
1455 const double& theBlue,
1456 const int& theWidth)
1458 myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
1462 Redirect the request to #SVTK_Renderer::SetSelectionTolerance
1464 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes,
1465 const double& theTolItems,
1466 const double& theTolObjects)
1468 myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
1472 Get visibility status of the static trihedron
1474 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
1476 return (bool)myAxesWidget->GetEnabled();
1480 Set visibility status of the static trihedron
1482 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
1484 myAxesWidget->SetEnabled( (int)theIsVisible );
1489 \param accelAction - action
1491 bool SVTK_ViewWindow::action( const int accelAction )
1493 if ( accelAction == SUIT_Accel::ZoomFit )
1496 int anEvent = SVTK::convertAction( accelAction );
1497 GetInteractor()->InvokeEvent(anEvent, 0);
1503 \return action by it's id
1505 QtxAction* SVTK_ViewWindow::getAction( int id ) const
1507 return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
1511 // old visual parameters had 13 values. New format added additional
1512 // 76 values for graduated axes, so both numbers are processed.
1513 const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
1514 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
1515 const int nTrihedronParams = 3; // number of parameters for Trihedron
1516 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
1518 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
1520 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
1527 bool isVisible = actor->GetTitleVisibility();
1528 QString title ( actor->GetTitle() );
1530 int font = VTK_ARIAL;
1535 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1538 txtProp->GetColor( color );
1539 font = txtProp->GetFontFamily();
1540 bold = txtProp->GetBold();
1541 italic = txtProp->GetItalic();
1542 shadow = txtProp->GetShadow();
1544 writer.writeStartElement("GraduatedAxis");
1545 writer.writeAttribute("Axis", theAxis);
1547 writer.writeStartElement("Title");
1548 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1549 writer.writeAttribute("Text", title);
1550 writer.writeAttribute("Font", QString("%1").arg(font));
1551 writer.writeAttribute("Bold", QString("%1").arg(bold));
1552 writer.writeAttribute("Italic", QString("%1").arg(italic));
1553 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1555 writer.writeStartElement("Color");
1556 writer.writeAttribute("R", QString("%1").arg(color[0]));
1557 writer.writeAttribute("G", QString("%1").arg(color[1]));
1558 writer.writeAttribute("B", QString("%1").arg(color[2]));
1559 writer.writeEndElement();
1560 writer.writeEndElement();
1562 //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
1563 // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1566 isVisible = actor->GetLabelVisibility();
1567 int labels = actor->GetNumberOfLabels();
1568 int offset = actor->GetTickOffset();
1574 txtProp = actor->GetLabelTextProperty();
1577 txtProp->GetColor( color );
1578 font = txtProp->GetFontFamily();
1579 bold = txtProp->GetBold();
1580 italic = txtProp->GetItalic();
1581 shadow = txtProp->GetShadow();
1584 writer.writeStartElement("Labels");
1585 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1586 writer.writeAttribute("Number", QString("%1").arg(labels));
1587 writer.writeAttribute("Offset", QString("%1").arg(offset));
1588 writer.writeAttribute("Font", QString("%1").arg(font));
1589 writer.writeAttribute("Bold", QString("%1").arg(bold));
1590 writer.writeAttribute("Italic", QString("%1").arg(italic));
1591 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1593 writer.writeStartElement("Color");
1594 writer.writeAttribute("R", QString("%1").arg(color[0]));
1595 writer.writeAttribute("G", QString("%1").arg(color[1]));
1596 writer.writeAttribute("B", QString("%1").arg(color[2]));
1597 writer.writeEndElement();
1598 writer.writeEndElement();
1599 // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
1600 // color[0], color[1], color[2], font, bold, italic, shadow );
1603 isVisible = actor->GetTickVisibility();
1604 int length = actor->GetTickLength();
1605 writer.writeStartElement("TickMarks");
1606 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1607 writer.writeAttribute("Length", QString("%1").arg(length));
1608 writer.writeEndElement();
1610 //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1612 writer.writeEndElement();
1616 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1623 } while (!reader.isStartElement());
1625 // Read title params
1626 QXmlStreamAttributes aAttr = reader.attributes();
1627 bool isVisible = aAttr.value("isVisible").toString().toUShort();
1628 QString title = aAttr.value("Text").toString();
1629 int font = aAttr.value("Font").toString().toInt();
1630 int bold = aAttr.value("Bold").toString().toInt();
1631 int italic = aAttr.value("Italic").toString().toInt();
1632 int shadow = aAttr.value("Shadow").toString().toInt();
1634 //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1638 } while (!reader.isStartElement());
1641 aAttr = reader.attributes();
1644 color[0] = aAttr.value("R").toString().toDouble();
1645 color[1] = aAttr.value("G").toString().toDouble();
1646 color[2] = aAttr.value("B").toString().toDouble();
1647 //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1649 actor->SetTitleVisibility( isVisible );
1650 actor->SetTitle( title.toLatin1() );
1651 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1653 txtProp->SetColor( color );
1654 txtProp->SetFontFamily( font );
1655 txtProp->SetBold( bold );
1656 txtProp->SetItalic( italic );
1657 txtProp->SetShadow( shadow );
1664 } while (!reader.isStartElement());
1666 aAttr = reader.attributes();
1667 isVisible = aAttr.value("isVisible").toString().toUShort();
1668 int labels = aAttr.value("Number").toString().toInt();
1669 int offset = aAttr.value("Offset").toString().toInt();
1670 font = aAttr.value("Font").toString().toInt();
1671 bold = aAttr.value("Bold").toString().toInt();
1672 italic = aAttr.value("Italic").toString().toInt();
1673 shadow = aAttr.value("Shadow").toString().toInt();
1677 } while (!reader.isStartElement());
1679 aAttr = reader.attributes();
1681 color[0] = aAttr.value("R").toString().toDouble();
1682 color[1] = aAttr.value("G").toString().toDouble();
1683 color[2] = aAttr.value("B").toString().toDouble();
1685 actor->SetLabelVisibility( isVisible );
1686 actor->SetNumberOfLabels( labels );
1687 actor->SetTickOffset( offset );
1688 txtProp = actor->GetLabelTextProperty();
1690 txtProp->SetColor( color );
1691 txtProp->SetFontFamily( font );
1692 txtProp->SetBold( bold );
1693 txtProp->SetItalic( italic );
1694 txtProp->SetShadow( shadow );
1700 } while (!reader.isStartElement());
1701 aAttr = reader.attributes();
1703 // retrieve and set tick marks properties
1704 isVisible = aAttr.value("isVisible").toString().toUShort();
1705 int length = aAttr.value("Length").toString().toInt();
1707 actor->SetTickVisibility( isVisible );
1708 actor->SetTickLength( length );
1711 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1713 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1718 QStringList paramsLst = params.split( '*' );
1720 if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1722 // retrieve and set name parameters
1723 bool isVisible = paramsLst[2].toUShort();
1724 QString title = paramsLst[3];
1726 color[0] = paramsLst[4].toDouble();
1727 color[1] = paramsLst[5].toDouble();
1728 color[2] = paramsLst[6].toDouble();
1729 int font = paramsLst[7].toInt();
1730 int bold = paramsLst[8].toInt();
1731 int italic = paramsLst[9].toInt();
1732 int shadow = paramsLst[10].toInt();
1734 actor->SetTitleVisibility( isVisible );
1735 actor->SetTitle( title.toLatin1() );
1736 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1738 txtProp->SetColor( color );
1739 txtProp->SetFontFamily( font );
1740 txtProp->SetBold( bold );
1741 txtProp->SetItalic( italic );
1742 txtProp->SetShadow( shadow );
1745 // retrieve and set lable parameters
1746 isVisible = paramsLst[12].toUShort();
1747 int labels = paramsLst[13].toInt();
1748 int offset = paramsLst[14].toInt();
1749 color[0] = paramsLst[15].toDouble();
1750 color[1] = paramsLst[16].toDouble();
1751 color[2] = paramsLst[17].toDouble();
1752 font = paramsLst[18].toInt();
1753 bold = paramsLst[19].toInt();
1754 italic = paramsLst[20].toInt();
1755 shadow = paramsLst[21].toInt();
1757 actor->SetLabelVisibility( isVisible );
1758 actor->SetNumberOfLabels( labels );
1759 actor->SetTickOffset( offset );
1760 txtProp = actor->GetLabelTextProperty();
1762 txtProp->SetColor( color );
1763 txtProp->SetFontFamily( font );
1764 txtProp->SetBold( bold );
1765 txtProp->SetItalic( italic );
1766 txtProp->SetShadow( shadow );
1769 // retrieve and set tick marks properties
1770 isVisible = paramsLst[23].toUShort();
1771 int length = paramsLst[24].toInt();
1773 actor->SetTickVisibility( isVisible );
1774 actor->SetTickLength( length );
1778 /*! The method returns the visual parameters of this view as a formated string
1780 QString SVTK_ViewWindow::getVisualParameters()
1782 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1784 // save position, focal point, viewUp, scale
1785 vtkCamera* camera = getRenderer()->GetActiveCamera();
1786 camera->GetPosition( pos );
1787 camera->GetFocalPoint( focalPnt );
1788 camera->GetViewUp( viewUp );
1789 parScale = camera->GetParallelScale();
1792 // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1793 // view up values (3 digits), parallel scale (1 digit), scale (3 digits,
1794 // Graduated axes parameters (X, Y, Z axes parameters)
1796 QXmlStreamWriter aWriter(&retStr);
1797 aWriter.setAutoFormatting(true);
1799 aWriter.writeStartDocument();
1800 aWriter.writeStartElement("ViewState");
1802 aWriter.writeStartElement("Position");
1803 aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1804 aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1805 aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1806 aWriter.writeEndElement();
1808 aWriter.writeStartElement("FocalPoint");
1809 aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1810 aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1811 aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1812 aWriter.writeEndElement();
1814 aWriter.writeStartElement("ViewUp");
1815 aWriter.writeAttribute("X", QString::number(viewUp[0]));
1816 aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1817 aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1818 aWriter.writeEndElement();
1820 aWriter.writeStartElement("ViewScale");
1821 aWriter.writeAttribute("Parallel", QString::number(parScale));
1822 aWriter.writeAttribute("X", QString::number(scale[0]));
1823 aWriter.writeAttribute("Y", QString::number(scale[1]));
1824 aWriter.writeAttribute("Z", QString::number(scale[2]));
1825 aWriter.writeEndElement();
1827 if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1828 aWriter.writeStartElement("DisplayCubeAxis");
1829 aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1830 aWriter.writeEndElement();
1832 getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1833 getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1834 getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1837 aWriter.writeStartElement("Trihedron");
1838 aWriter.writeAttribute("isShown", QString( "%1" ).arg( isTrihedronDisplayed()));
1839 aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1840 aWriter.writeEndElement();
1842 aWriter.writeStartElement("Background");
1843 aWriter.writeAttribute("Value", QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
1844 aWriter.writeEndElement();
1846 aWriter.writeEndElement();
1847 aWriter.writeEndDocument();
1853 The method restores visual parameters of this view or postpones it untill the view is shown
1855 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1857 //printf("#### %s\n", qPrintable(parameters));
1858 SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1859 if ( anInteractor->isVisible() ) {
1860 doSetVisualParameters( parameters );
1863 myVisualParams = parameters;
1864 anInteractor->installEventFilter(this);
1869 The method restores visual parameters of this view from a formated string
1871 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
1874 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1876 QXmlStreamReader aReader(parameters);
1877 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1879 while(!aReader.atEnd()) {
1881 if (aReader.isStartElement()) {
1882 QXmlStreamAttributes aAttr = aReader.attributes();
1883 //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1884 if (aReader.name() == "Position") {
1885 pos[0] = aAttr.value("X").toString().toDouble();
1886 pos[1] = aAttr.value("Y").toString().toDouble();
1887 pos[2] = aAttr.value("Z").toString().toDouble();
1888 //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1890 else if (aReader.name() == "FocalPoint") {
1891 focalPnt[0] = aAttr.value("X").toString().toDouble();
1892 focalPnt[1] = aAttr.value("Y").toString().toDouble();
1893 focalPnt[2] = aAttr.value("Z").toString().toDouble();
1894 //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1896 else if (aReader.name() == "ViewUp") {
1897 viewUp[0] = aAttr.value("X").toString().toDouble();
1898 viewUp[1] = aAttr.value("Y").toString().toDouble();
1899 viewUp[2] = aAttr.value("Z").toString().toDouble();
1900 //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1902 else if (aReader.name() == "ViewScale") {
1903 parScale = aAttr.value("Parallel").toString().toDouble();
1904 scale[0] = aAttr.value("X").toString().toDouble();
1905 scale[1] = aAttr.value("Y").toString().toDouble();
1906 scale[2] = aAttr.value("Z").toString().toDouble();
1907 //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1909 else if (aReader.name() == "DisplayCubeAxis") {
1910 if ( !baseParamsOnly ) {
1911 if (aAttr.value("Show") == "0")
1912 gradAxesActor->VisibilityOff();
1914 gradAxesActor->VisibilityOn();
1917 else if (aReader.name() == "GraduatedAxis") {
1918 if ( !baseParamsOnly ) {
1919 if(aAttr.value("Axis") == "X")
1920 setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1921 else if(aAttr.value("Axis") == "Y")
1922 setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1923 else if(aAttr.value("Axis") == "Z")
1924 setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1927 else if (aReader.name() == "Trihedron") {
1928 if ( !baseParamsOnly ) {
1929 if (aAttr.value("isShown") == "0")
1930 GetTrihedron()->VisibilityOff();
1932 GetTrihedron()->VisibilityOn();
1933 SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1936 else if (aReader.name() == "Background") {
1937 if ( !baseParamsOnly ) {
1938 setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
1943 if (!aReader.hasError()) {
1944 vtkCamera* camera = getRenderer()->GetActiveCamera();
1945 camera->SetPosition( pos );
1946 camera->SetFocalPoint( focalPnt );
1947 camera->SetViewUp( viewUp );
1948 camera->SetParallelScale( parScale );
1949 GetRenderer()->SetScale( scale );
1950 //SetScale( scale );
1953 QStringList paramsLst = parameters.split( '*' );
1954 if ( paramsLst.size() >= nNormalParams ) {
1955 // 'reading' list of parameters
1956 pos[0] = paramsLst[0].toDouble();
1957 pos[1] = paramsLst[1].toDouble();
1958 pos[2] = paramsLst[2].toDouble();
1959 focalPnt[0] = paramsLst[3].toDouble();
1960 focalPnt[1] = paramsLst[4].toDouble();
1961 focalPnt[2] = paramsLst[5].toDouble();
1962 viewUp[0] = paramsLst[6].toDouble();
1963 viewUp[1] = paramsLst[7].toDouble();
1964 viewUp[2] = paramsLst[8].toDouble();
1965 parScale = paramsLst[9].toDouble();
1966 scale[0] = paramsLst[10].toDouble();
1967 scale[1] = paramsLst[11].toDouble();
1968 scale[2] = paramsLst[12].toDouble();
1970 // applying parameters
1971 vtkCamera* camera = getRenderer()->GetActiveCamera();
1972 camera->SetPosition( pos );
1973 camera->SetFocalPoint( focalPnt );
1974 camera->SetViewUp( viewUp );
1975 camera->SetParallelScale( parScale );
1976 GetRenderer()->SetScale( scale );
1977 //SetScale( scale );
1979 // apply graduated axes parameters
1980 if ( !baseParamsOnly ) {
1981 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1982 if ( gradAxesActor && paramsLst.size() == nAllParams ) {
1983 int i = nNormalParams+1, j = i + nGradAxisParams - 1;
1984 ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
1985 i = j + 1; j += nGradAxisParams;
1986 ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
1987 i = j + 1; j += nGradAxisParams;
1988 ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
1990 if ( paramsLst[13].toUShort() )
1991 gradAxesActor->VisibilityOn();
1993 gradAxesActor->VisibilityOff();
1995 else if ( paramsLst.size() == nAllParams ) {
1996 if ( paramsLst[90].toUShort() )
1997 GetTrihedron()->VisibilityOn();
1999 GetTrihedron()->VisibilityOff();
2001 SetTrihedronSize(paramsLst[91].toDouble());
2011 Delayed setVisualParameters
2013 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
2015 if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
2016 SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
2017 if ( anInteractor->isVisible() ) {
2018 doSetVisualParameters( myVisualParams );
2019 anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
2022 return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
2027 Change rotation point
2029 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
2032 mySetRotationPointDlg->addObserver();
2033 if ( mySetRotationPointDlg->IsFirstShown() )
2034 activateSetRotationGravity();
2035 mySetRotationPointDlg->show();
2037 mySetRotationPointDlg->hide();
2041 Set the gravity center as a rotation point
2043 void SVTK_ViewWindow::activateSetRotationGravity()
2045 myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
2049 Set the selected point as a rotation point
2051 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
2053 myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
2057 Set the gravity center of element selected by user as a rotation point
2059 void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
2061 SetSelectionMode( theSelectionMode );
2062 myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
2066 \brief Set the given projection mode.
2068 Set the given projection mode: Orthographic or Perspective.
2070 void SVTK_ViewWindow::onProjectionMode( QAction* theAction )
2072 int aMode = Parallel;
2073 if (theAction == toolMgr()->action( ProjectionModeId ))
2075 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2076 aViewer->setProjectionMode(aMode);
2077 bool anIsParallelMode = (aMode == Parallel);
2078 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2079 aCamera->SetParallelProjection(anIsParallelMode);
2080 GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
2081 getRenderWindow()->SetStereoRender(0);
2086 \brief Sets Stereo projection mode.
2088 Sets Stereo projection mode.
2090 void SVTK_ViewWindow::onStereoMode( bool activate )
2093 toolMgr()->action( ProjectionModeId )->setChecked(true);
2094 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2095 aCamera->SetParallelProjection(false);
2096 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false);
2097 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2098 SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
2099 getRenderWindow()->SetStereoRender(1);
2103 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true);
2104 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2105 if (aViewer->projectionMode() == Parallel) {
2106 toolMgr()->action( ParallelModeId )->setChecked(true);
2107 onProjectionMode(toolMgr()->action( ParallelModeId ));
2109 else if (aViewer->projectionMode() == Projection) {
2110 toolMgr()->action( ProjectionModeId )->setChecked(true);
2111 onProjectionMode(toolMgr()->action( ProjectionModeId ));
2114 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
2115 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
2116 toolMgr()->action( StereoModeId )->isChecked() )
2117 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
2121 Set the view projection mode: orthogonal or perspective
2123 void SVTK_ViewWindow::onProjectionMode()
2125 if (toolMgr()->action( ParallelModeId )->isChecked())
2126 SetProjectionMode( Parallel);
2127 if (toolMgr()->action( ProjectionModeId )->isChecked())
2128 SetProjectionMode( Projection);
2129 if (toolMgr()->action( StereoModeId )->isChecked())
2130 SetProjectionMode( Stereo);
2131 emit transformed( this );
2134 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
2136 myEventDispatcher = theDispatcher;
2140 Creates all actions of svtk main window
2142 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
2144 QtxAction* anAction;
2145 QtxActionToolMgr* mgr = toolMgr();
2148 anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
2149 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
2150 tr( "MNU_DUMP_VIEW" ), 0, this);
2151 anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
2152 connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
2153 mgr->registerAction( anAction, DumpId );
2156 anAction = new QtxAction(tr("MNU_FITALL"),
2157 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
2158 tr( "MNU_FITALL" ), 0, this);
2159 anAction->setStatusTip(tr("DSC_FITALL"));
2160 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
2161 mgr->registerAction( anAction, FitAllId );
2164 anAction = new QtxAction(tr("MNU_FITRECT"),
2165 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
2166 tr( "MNU_FITRECT" ), 0, this);
2167 anAction->setStatusTip(tr("DSC_FITRECT"));
2168 connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
2169 mgr->registerAction( anAction, FitRectId );
2172 anAction = new QtxAction(tr("MNU_FITSELECTION"),
2173 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
2174 tr( "MNU_FITSELECTION" ), 0, this);
2175 anAction->setStatusTip(tr("DSC_FITSELECTION"));
2176 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
2177 mgr->registerAction( anAction, FitSelectionId );
2180 anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
2181 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
2182 tr( "MNU_ZOOM_VIEW" ), 0, this);
2183 anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
2184 connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
2185 mgr->registerAction( anAction, ZoomId );
2188 anAction = new QtxAction(tr("MNU_PAN_VIEW"),
2189 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
2190 tr( "MNU_PAN_VIEW" ), 0, this);
2191 anAction->setStatusTip(tr("DSC_PAN_VIEW"));
2192 connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
2193 mgr->registerAction( anAction, PanId );
2196 anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
2197 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
2198 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
2199 anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
2200 connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
2201 mgr->registerAction( anAction, GlobalPanId );
2203 // Change rotation point
2204 anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
2205 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
2206 tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
2207 anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
2208 anAction->setCheckable(true);
2209 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
2210 mgr->registerAction( anAction, ChangeRotationPointId );
2213 anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
2214 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
2215 tr( "MNU_ROTATE_VIEW" ), 0, this);
2216 anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
2217 connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
2218 mgr->registerAction( anAction, RotationId );
2221 anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
2222 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
2223 tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
2224 anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
2225 connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
2226 this->addAction(anAction);
2227 mgr->registerAction( anAction, FrontId );
2229 anAction = new QtxAction(tr("MNU_BACK_VIEW"),
2230 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
2231 tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
2232 anAction->setStatusTip(tr("DSC_BACK_VIEW"));
2233 connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView()));
2234 this->addAction(anAction);
2235 mgr->registerAction( anAction, BackId );
2237 anAction = new QtxAction(tr("MNU_TOP_VIEW"),
2238 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
2239 tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
2240 anAction->setStatusTip(tr("DSC_TOP_VIEW"));
2241 connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView()));
2242 this->addAction(anAction);
2243 mgr->registerAction( anAction, TopId );
2245 anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
2246 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
2247 tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
2248 anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
2249 connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
2250 this->addAction(anAction);
2251 mgr->registerAction( anAction, BottomId );
2253 anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
2254 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
2255 tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
2256 anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
2257 connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
2258 this->addAction(anAction);
2259 mgr->registerAction( anAction, LeftId );
2261 anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
2262 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
2263 tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
2264 anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
2265 connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView()));
2266 this->addAction(anAction);
2267 mgr->registerAction( anAction, RightId );
2269 // rotate anticlockwise
2270 anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
2271 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
2272 tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
2273 anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
2274 connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
2275 this->addAction(anAction);
2276 mgr->registerAction( anAction, AntiClockWiseId );
2279 anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
2280 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
2281 tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
2282 anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
2283 connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
2284 this->addAction(anAction);
2285 mgr->registerAction( anAction, ClockWiseId );
2288 anAction = new QtxAction(tr("MNU_RESET_VIEW"),
2289 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
2290 tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
2291 anAction->setStatusTip(tr("DSC_RESET_VIEW"));
2292 connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView()));
2293 this->addAction(anAction);
2294 mgr->registerAction( anAction, ResetId );
2296 // onViewTrihedron: Shows - Hides Trihedron
2297 anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
2298 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
2299 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
2300 anAction->setCheckable( true );
2301 anAction->setChecked( true );
2303 anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
2304 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
2305 mgr->registerAction( anAction, ViewTrihedronId );
2307 // onNonIsometric: Manage non-isometric params
2308 anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
2309 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
2310 tr( "MNU_SVTK_SCALING" ), 0, this);
2311 anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
2312 anAction->setCheckable(true);
2313 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
2314 mgr->registerAction( anAction, NonIsometric );
2316 // onGraduatedAxes: Manage graduated axes params
2317 anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
2318 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
2319 tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
2320 anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
2321 anAction->setCheckable(true);
2322 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
2323 mgr->registerAction( anAction, GraduatedAxes );
2325 // onGraduatedAxes: Manage graduated axes params
2326 anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"),
2327 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
2328 tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
2329 anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
2330 anAction->setCheckable(true);
2331 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
2332 mgr->registerAction( anAction, UpdateRate );
2334 // Set perspective mode group
2335 anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"),
2336 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
2337 tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
2338 anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
2339 anAction->setCheckable(true);
2340 mgr->registerAction( anAction, ParallelModeId );
2342 anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"),
2343 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
2344 tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
2345 anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
2346 anAction->setCheckable(true);
2347 mgr->registerAction( anAction, ProjectionModeId );
2349 anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
2350 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ),
2351 tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
2352 anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
2353 anAction->setCheckable(true);
2354 connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool)));
2355 mgr->registerAction( anAction, StereoModeId );
2357 QActionGroup* aPerspectiveGroup = new QActionGroup( this );
2358 aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
2359 aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
2360 connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*)));
2363 anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
2364 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
2365 tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
2366 anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
2367 anAction->setCheckable(true);
2368 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
2369 mgr->registerAction( anAction, ViewParametersId );
2372 mgr->registerAction( synchronizeAction(), SynchronizeId );
2374 // Switch between interaction styles
2375 anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
2376 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
2377 tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
2378 anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
2379 anAction->setCheckable(true);
2380 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
2381 mgr->registerAction( anAction, SwitchInteractionStyleId );
2383 // Switch between zooming styles
2384 anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"),
2385 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
2386 tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
2387 anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
2388 anAction->setCheckable(true);
2389 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
2390 mgr->registerAction( anAction, SwitchZoomingStyleId );
2393 QSignalMapper* aSignalMapper = new QSignalMapper( this );
2394 connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int)));
2396 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_STANDARD"),
2397 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ),
2398 tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
2399 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
2400 anAction->setCheckable(true);
2401 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2402 aSignalMapper->setMapping( anAction, Standard_Preselection );
2403 mgr->registerAction( anAction, StandardPreselectionId );
2405 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DYNAMIC"),
2406 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DYNAMIC" ) ),
2407 tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
2408 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
2409 anAction->setCheckable(true);
2410 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2411 aSignalMapper->setMapping( anAction, Dynamic_Preselection );
2412 mgr->registerAction( anAction, DynamicPreselectionId );
2414 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DISABLED"),
2415 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DISABLED" ) ),
2416 tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
2417 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
2418 anAction->setCheckable(true);
2419 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2420 aSignalMapper->setMapping( anAction, Preselection_Disabled );
2421 mgr->registerAction( anAction, DisablePreselectionId );
2423 QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true );
2424 aPreselectionAction->add( getAction( StandardPreselectionId ) );
2425 aPreselectionAction->add( getAction( DynamicPreselectionId ) );
2426 aPreselectionAction->add( getAction( DisablePreselectionId ) );
2427 mgr->registerAction( aPreselectionAction, PreselectionId );
2430 anAction = new QtxAction(tr("MNU_SVTK_ENABLE_SELECTION"),
2431 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SELECTION" ) ),
2432 tr( "MNU_SVTK_ENABLE_SELECTION" ), 0, this);
2433 anAction->setStatusTip(tr("DSC_SVTK_ENABLE_SELECTION"));
2434 anAction->setCheckable(true);
2435 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool)));
2436 mgr->registerAction( anAction, EnableSelectionId );
2439 myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
2440 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
2441 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
2442 myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
2443 connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
2444 mgr->registerAction( myStartAction, StartRecordingId );
2447 myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
2448 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
2449 tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
2450 myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
2451 myPlayAction->setEnabled( false );
2452 connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
2453 mgr->registerAction( myPlayAction, PlayRecordingId );
2456 myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
2457 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
2458 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
2459 myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
2460 myPauseAction->setEnabled( false );
2461 connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
2462 mgr->registerAction( myPauseAction, PauseRecordingId );
2465 myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
2466 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
2467 tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
2468 myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
2469 myStopAction->setEnabled( false );
2470 connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
2471 mgr->registerAction( myStopAction, StopRecordingId );
2475 Creates toolbar of svtk main window
2477 void SVTK_ViewWindow::createToolBar()
2479 QtxActionToolMgr* mgr = toolMgr();
2481 mgr->append( DumpId, myToolBar );
2482 mgr->append( SwitchInteractionStyleId, myToolBar );
2483 mgr->append( SwitchZoomingStyleId, myToolBar );
2485 mgr->append( mgr->separator(), myToolBar );
2487 mgr->append( PreselectionId, myToolBar );
2488 mgr->append( EnableSelectionId, myToolBar );
2490 mgr->append( mgr->separator(), myToolBar );
2492 mgr->append( ViewTrihedronId, myToolBar );
2494 QtxMultiAction* aScaleAction = new QtxMultiAction( this );
2495 aScaleAction->insertAction( getAction( FitAllId ) );
2496 aScaleAction->insertAction( getAction( FitRectId ) );
2497 aScaleAction->insertAction( getAction( FitSelectionId ) );
2498 aScaleAction->insertAction( getAction( ZoomId ) );
2499 mgr->append( aScaleAction, myToolBar );
2501 QtxMultiAction* aPanningAction = new QtxMultiAction( this );
2502 aPanningAction->insertAction( getAction( PanId ) );
2503 aPanningAction->insertAction( getAction( GlobalPanId ) );
2504 mgr->append( aPanningAction, myToolBar );
2506 mgr->append( ChangeRotationPointId, myToolBar );
2508 mgr->append( RotationId, myToolBar );
2510 QtxMultiAction* aViewsAction = new QtxMultiAction( this );
2511 aViewsAction->insertAction( getAction( FrontId ) );
2512 aViewsAction->insertAction( getAction( BackId ) );
2513 aViewsAction->insertAction( getAction( TopId ) );
2514 aViewsAction->insertAction( getAction( BottomId ) );
2515 aViewsAction->insertAction( getAction( LeftId ) );
2516 aViewsAction->insertAction( getAction( RightId ) );
2517 mgr->append( aViewsAction, myToolBar );
2519 mgr->append( AntiClockWiseId, myToolBar );
2520 mgr->append( ClockWiseId, myToolBar );
2522 mgr->append( ResetId, myToolBar );
2524 mgr->append( UpdateRate, myToolBar );
2525 mgr->append( NonIsometric, myToolBar );
2526 mgr->append( GraduatedAxes, myToolBar );
2528 mgr->append( ViewParametersId, myToolBar );
2529 mgr->append( SynchronizeId, myToolBar );
2531 mgr->append( toolMgr()->separator(), myToolBar );
2533 mgr->append( ParallelModeId, myToolBar );
2534 mgr->append( ProjectionModeId, myToolBar );
2535 mgr->append( StereoModeId, myToolBar );
2537 mgr->append( StartRecordingId, myRecordingToolBar );
2538 mgr->append( PlayRecordingId, myRecordingToolBar );
2539 mgr->append( PauseRecordingId, myRecordingToolBar );
2540 mgr->append( StopRecordingId, myRecordingToolBar );
2543 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
2546 myUpdateRateDlg->Update();
2547 myUpdateRateDlg->show();
2549 myUpdateRateDlg->hide();
2552 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
2555 myNonIsometricDlg->Update();
2556 myNonIsometricDlg->show();
2558 myNonIsometricDlg->hide();
2561 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
2564 myCubeAxesDlg->Update();
2565 myCubeAxesDlg->show();
2567 myCubeAxesDlg->hide();
2571 Starts rotation transformation
2573 void SVTK_ViewWindow::activateRotation()
2575 myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
2580 Starts panning transformation
2582 void SVTK_ViewWindow::activatePanning()
2584 myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
2588 Starts zoom transformation
2590 void SVTK_ViewWindow::activateZoom()
2592 myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
2596 Starts window fit transformation
2598 void SVTK_ViewWindow::activateWindowFit()
2600 myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
2604 Starts global panning transformation
2606 void SVTK_ViewWindow::activateGlobalPanning()
2608 myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
2611 void SVTK_ViewWindow::onStartRecording()
2613 myRecorder->CheckExistAVIMaker();
2614 if (myRecorder->ErrorStatus()) {
2615 SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
2618 SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
2620 if( !aRecorderDlg->exec() )
2623 myStartAction->setEnabled( false );
2624 myPlayAction->setEnabled( false );
2625 myPauseAction->setEnabled( true );
2626 myStopAction->setEnabled( true );
2628 // to prevent resizing the window while recording
2629 myPreRecordingMinSize = minimumSize();
2630 myPreRecordingMaxSize = maximumSize();
2631 setFixedSize( size() );
2633 myRecorder->Record();
2637 void SVTK_ViewWindow::onPlayRecording()
2639 myStartAction->setEnabled( false );
2640 myPlayAction->setEnabled( false );
2641 myPauseAction->setEnabled( true );
2642 myStopAction->setEnabled( true );
2644 myRecorder->Pause();
2647 void SVTK_ViewWindow::onPauseRecording()
2649 myStartAction->setEnabled( false );
2650 myPlayAction->setEnabled( true );
2651 myPauseAction->setEnabled( false );
2652 myStopAction->setEnabled( true );
2654 myRecorder->Pause();
2657 void SVTK_ViewWindow::onStopRecording()
2659 myStartAction->setEnabled( true );
2660 myPlayAction->setEnabled( false );
2661 myPauseAction->setEnabled( false );
2662 myStopAction->setEnabled( false );
2666 setMinimumSize( myPreRecordingMinSize );
2667 setMaximumSize( myPreRecordingMaxSize );
2671 To invoke a VTK event on SVTK_RenderWindowInteractor instance
2673 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
2675 GetInteractor()->InvokeEvent(theEvent,theCallData);
2679 Modify view parameters
2681 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
2684 myViewParameterDlg->addObserver();
2685 myViewParameterDlg->show();
2687 myViewParameterDlg->hide();
2691 Custom show event handler
2693 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent )
2695 emit Show( theEvent );
2699 Custom hide event handler
2701 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
2703 emit Hide( theEvent );
2707 Emit transformed signal.
2709 void SVTK_ViewWindow::emitTransformed() {
2716 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
2717 unsigned long theEvent,
2718 void* theClientData,
2721 SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
2723 self->emitTransformed();
2727 Get camera properties for the SVTK view window.
2728 \return shared pointer on camera properties.
2730 SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
2732 SUIT_CameraProperties aProps;
2735 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2739 aProps.setDimension( SUIT_CameraProperties::Dim3D );
2740 if ( toolMgr()->action( ParallelModeId ) ) {
2741 if ( toolMgr()->action( ParallelModeId )->isChecked() )
2742 aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
2744 aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
2747 double aFocalPoint[3];
2748 double aPosition[3];
2750 double anAxialScale[3];
2752 aCamera->OrthogonalizeViewUp();
2753 aCamera->GetFocalPoint( aFocalPoint );
2754 aCamera->GetPosition( aPosition );
2755 aCamera->GetViewUp( aViewUp );
2757 aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2758 aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
2759 aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2760 aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
2762 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2764 aProps.setViewAngle( aCamera->GetViewAngle() );
2767 GetRenderer()->GetScale( anAxialScale );
2768 aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2775 This implementation synchronizes camera propreties.
2777 void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2779 bool blocked = blockSignals( true );
2781 SUIT_CameraProperties aProps = theView->cameraProperties();
2782 if ( !cameraProperties().isCompatible( aProps ) ) {
2783 // other view, this one is being currently synchronized to, seems has become incompatible
2784 // we have to break synchronization
2790 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2792 double aFocalPoint[3];
2793 double aPosition[3];
2795 double anAxialScale[3];
2797 // get common properties
2798 aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2799 aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
2800 aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2801 aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2803 // restore properties to the camera
2804 aCamera->SetViewUp( aViewUp );
2805 aCamera->SetPosition( aPosition );
2806 aCamera->SetFocalPoint( aFocalPoint );
2807 aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
2809 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2811 aCamera->SetViewAngle( aProps.getViewAngle() );
2814 GetRenderer()->SetScale( anAxialScale );
2816 getRenderer()->ResetCameraClippingRange();
2819 blockSignals( blocked );