1 // Copyright (C) 2007-2020 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"
40 #include <QSignalMapper>
41 #include <QXmlStreamWriter>
42 #include <QXmlStreamReader>
43 #include <QXmlStreamAttributes>
45 #include <vtkTextProperty.h>
46 #include <vtkActorCollection.h>
47 #include <vtkRenderWindow.h>
48 #include <vtkRenderer.h>
49 #include <vtkCamera.h>
50 #include <vtkPointPicker.h>
51 #include <vtkCellPicker.h>
52 #include <vtkAxisActor2D.h>
53 #include <vtkGL2PSExporter.h>
54 #include <vtkInteractorStyle.h>
55 #include <vtkProperty.h>
56 #include <vtkCallbackCommand.h>
57 #include <vtkJPEGReader.h>
58 #include <vtkBMPReader.h>
59 #include <vtkTIFFReader.h>
60 #include <vtkPNGReader.h>
61 #include <vtkMetaImageReader.h>
62 #include <vtkImageMapToColors.h>
63 #include <vtkTexture.h>
65 #include "QtxAction.h"
67 #include "SUIT_Session.h"
68 #include "SUIT_MessageBox.h"
69 #include "SUIT_Accel.h"
70 #include "SUIT_Tools.h"
71 #include "SUIT_ResourceMgr.h"
72 #include "SUIT_Accel.h"
73 #include "SUIT_OverrideCursor.h"
74 #include "SUIT_ViewManager.h"
75 #include "QtxActionToolMgr.h"
76 #include "QtxMultiAction.h"
77 #include "QtxActionGroup.h"
79 #include "VTKViewer_Utilities.h"
80 #include "VTKViewer_Trihedron.h"
81 #include "VTKViewer_Actor.h"
83 #include "SVTK_View.h"
84 #include "SVTK_Selector.h"
86 #include "SVTK_Event.h"
87 #include "SVTK_Renderer.h"
88 #include "SVTK_ViewWindow.h"
89 #include "SVTK_InteractorStyle.h"
90 #include "SVTK_RenderWindowInteractor.h"
91 #include "SVTK_GenericRenderWindowInteractor.h"
92 #include "SVTK_CubeAxesActor2D.h"
93 #include "SVTK_ComboAction.h"
94 #include "SVTK_KeyFreeInteractorStyle.h"
95 #include "SVTK_Selector.h"
96 #include "SVTK_Recorder.h"
97 #include "SVTK_RecorderDlg.h"
99 #include "salomevtkPVAxesWidget.h"
100 #include "salomevtkPVAxesActor.h"
102 #include "SALOME_ListIO.hxx"
104 #include "VTKViewer_Algorithm.h"
105 #include "SVTK_Functor.h"
107 #include <OpenGLUtils_FrameBuffer.h>
110 #include <OpenGL/gl.h>
117 int convertAction( const int accelAction )
119 switch ( accelAction ) {
120 case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
121 case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
122 case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
123 case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
124 case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
125 case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
126 case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
127 case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
128 case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
129 case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
138 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
139 SUIT_ViewWindow(theDesktop),
141 myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
142 myEventCallbackCommand(vtkCallbackCommand::New()),
143 myDumpImage(QImage())
145 setWindowFlags( windowFlags() & ~Qt::Window );
146 // specific of vtkSmartPointer
147 myKeyFreeInteractorStyle->Delete();
151 To initialize #SVTK_ViewWindow instance
153 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
156 myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
158 SVTK_Selector* aSelector = SVTK_Selector::New();
159 int aPreselectionMode = SUIT_Session::session()->resourceMgr()->
160 integerValue( "VTKViewer", "preselection", Standard_Preselection );
161 aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection );
162 aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled );
163 bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
164 booleanValue( "VTKViewer", "enable_selection", true );
165 aSelector->SetSelectionEnabled( isSelectionEnabled );
167 SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
168 aDevice->SetRenderWidget(myInteractor);
169 aDevice->SetSelector(aSelector);
171 SVTK_Renderer* aRenderer = SVTK_Renderer::New();
172 aRenderer->Initialize(aDevice,aSelector);
174 myInteractor->Initialize(aDevice,aRenderer,aSelector);
180 myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant)
181 QString( "VTKViewerViewOperations" ), // name (language-independant)
182 false ); // disable floatable toolbar
184 myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant)
185 QString( "VTKRecordingOperations" ), // name (language-independant)
186 false ); // disable floatable toolbar
188 createActions( SUIT_Session::session()->resourceMgr() );
191 SetEventDispatcher(myInteractor->GetDevice());
192 myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
193 myInteractor->setFocusPolicy(Qt::StrongFocus);
194 myInteractor->setFocus();
195 bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()->
196 booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
197 myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
198 setFocusProxy(myInteractor);
200 myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
201 myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
202 myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
203 myCubeAxesDlg->initialize();
204 mySetRotationPointDlg = new SVTK_SetRotationPointDlg
205 ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
206 myViewParameterDlg = new SVTK_ViewParameterDlg
207 ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
209 myDefaultInteractorStyle = SVTK_InteractorStyle::New();
210 myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
211 myDefaultInteractorStyle->Delete();
213 myRecorder = SVTK_Recorder::New();
215 myRecorder->SetNbFPS( 17.3 );
216 myRecorder->SetQuality( 100 );
217 myRecorder->SetProgressiveMode( true );
218 myRecorder->SetUseSkippedFrames( true );
219 myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
221 setCentralWidget(myInteractor);
223 myAxesWidget = salomevtk::vtkPVAxesWidget::New();
224 myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
225 myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
226 myAxesWidget->SetInteractor(myInteractor->GetDevice());
227 myAxesWidget->SetEnabled(1);
228 myAxesWidget->SetInteractive(0);
230 salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
231 anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 );
232 anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
233 anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
234 anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 );
235 anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
236 anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
237 anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 );
238 anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
239 anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
241 myView = new SVTK_View(this);
242 Initialize(myView,theModel);
245 myEventCallbackCommand->SetClientData(this);
246 myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
247 myEventCallbackCommand->Delete();
249 GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
250 myEventCallbackCommand.GetPointer(), 0.0);
251 myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
252 myEventCallbackCommand.GetPointer(), 0.0);
256 myInteractor->getRenderWindow()->Render();
257 setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
262 To initialize #SVTK_ViewWindow instance
264 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
265 SVTK_ViewModelBase* theModel)
267 connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
268 this,SLOT(onKeyPressed(QKeyEvent*)) );
269 connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
270 this,SLOT(onKeyReleased(QKeyEvent*)));
271 connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
272 this,SLOT(onMousePressed(QMouseEvent*)));
273 connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
274 this,SLOT(onMouseReleased(QMouseEvent*)));
275 connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
276 this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
277 connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
278 this,SLOT(onMouseMoving(QMouseEvent*)));
279 connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
280 this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
281 connect(theView,SIGNAL(selectionChanged()),
282 theModel,SLOT(onSelectionChanged()));
284 connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
290 SVTK_ViewWindow::~SVTK_ViewWindow()
292 myRecorder->Delete();
293 myAxesWidget->Delete();
298 \return corresponding view
300 SVTK_View* SVTK_ViewWindow::getView()
306 \return corresponding vtk render window
308 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
310 return GetInteractor()->getRenderWindow();
314 \return corresponding vtk render window interactor
316 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
322 \return corresponding vtk render window interactor
324 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
326 return myInteractor->GetDevice();
330 \return corresponding vtk renderer
332 vtkRenderer* SVTK_ViewWindow::getRenderer() const
334 return GetInteractor()->getRenderer();
338 Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
340 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
342 return GetInteractor()->GetRenderer();
346 \return corresponding vtk selector
348 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
350 return GetInteractor()->GetSelector();
354 Processes transformation "front view"
356 void SVTK_ViewWindow::onFrontView()
358 GetRenderer()->OnFrontView();
360 emit transformed( this );
364 Processes transformation "back view"
366 void SVTK_ViewWindow::onBackView()
368 GetRenderer()->OnBackView();
370 emit transformed( this );
374 Processes transformation "top view"
376 void SVTK_ViewWindow::onTopView()
378 GetRenderer()->OnTopView();
380 emit transformed( this );
384 Processes transformation "bottom view"
386 void SVTK_ViewWindow::onBottomView()
388 GetRenderer()->OnBottomView();
390 emit transformed( this );
394 Processes transformation "left view"
396 void SVTK_ViewWindow::onLeftView()
398 GetRenderer()->OnLeftView();
400 emit transformed( this );
404 Processes transformation "right view"
406 void SVTK_ViewWindow::onRightView()
408 GetRenderer()->OnRightView();
410 emit transformed( this );
414 \brief Rotate view 90 degrees clockwise
416 void SVTK_ViewWindow::onClockWiseView()
418 GetRenderer()->onClockWiseView();
420 emit transformed( this );
424 \brief Rotate view 90 degrees conterclockwise
426 void SVTK_ViewWindow::onAntiClockWiseView()
428 GetRenderer()->onAntiClockWiseView();
430 emit transformed( this );
434 Processes transformation "reset view": sets default orientation of viewport camera
436 void SVTK_ViewWindow::onResetView()
438 GetRenderer()->OnResetView();
440 emit transformed( this );
444 Processes transformation "fit all"
446 void SVTK_ViewWindow::onFitAll()
448 GetRenderer()->OnFitAll();
450 emit transformed( this );
454 Processes transformation "fit selection"
456 void SVTK_ViewWindow::onFitSelection()
458 GetRenderer()->onFitSelection();
460 emit transformed( this );
464 Processes transformation "fit given objects"
466 void SVTK_ViewWindow::onFitIObjects(const SALOME_ListIO& objects)
468 GetRenderer()->OnFitIObjects(objects);
470 emit transformed( this );
474 SLOT: called if selection is changed
476 void SVTK_ViewWindow::onSelectionChanged()
478 myView->onSelectionChanged();
482 Change selection mode
483 \param theMode - new selection mode
485 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
487 GetSelector()->SetSelectionMode(theMode);
491 \return selection mode
493 Selection_Mode SVTK_ViewWindow::SelectionMode() const
495 return GetSelector()->SelectionMode();
499 Unhilights all objects in viewer
501 void SVTK_ViewWindow::unHighlightAll()
503 myView->unHighlightAll();
507 Hilights/unhilights object in viewer
508 \param theIO - object to be updated
509 \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
510 \param theIsUpdate - update current viewer
512 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO,
516 myView->highlight( theIO, theIsHighlight, theIsUpdate );
520 \return true if object is in viewer or in collector
521 \param theIO - object to be checked
523 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
525 return myView->isInViewer( theIO );
529 \return true if object is displayed in viewer
530 \param theIO - object to be checked
532 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
534 return myView->isVisible( theIO );
539 \param theEntry - entry that corresponds to intractive objects
541 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry)
543 return myView->FindIObject(theEntry);
548 \param theIO - object
549 \param theImmediatly - update viewer
551 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
554 myView->Display(theIO,theImmediatly);
559 \param theIO - object
560 \param theImmediatly - update viewer
562 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
565 myView->Erase(theIO,theImmediatly);
569 Display only passed object
570 \param theIO - object
572 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
574 myView->DisplayOnly(theIO);
578 Display all objects in view
580 void SVTK_ViewWindow::DisplayAll()
582 myView->DisplayAll();
586 Erase all objects in view
588 void SVTK_ViewWindow::EraseAll()
594 Sets background color [obsolete]
595 \param color - new background color
597 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
599 Qtx::BackgroundData bg = background();
605 \return background color of viewer [obsolete]
607 QColor SVTK_ViewWindow::backgroundColor() const
609 return background().color();
614 \param bgData - new background data
616 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
620 if ( bgData.isValid() ) {
621 switch ( bgData.mode() ) {
622 case Qtx::ColorBackground:
624 QColor c = bgData.color();
626 // show solid-colored background
627 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
628 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
629 getRenderer()->SetBackground( c.red()/255.0,
631 c.blue()/255.0 ); // set background color
636 case Qtx::SimpleGradientBackground:
639 int type = bgData.gradient( c1, c2 );
645 // show two-color gradient background
646 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
647 getRenderer()->SetGradientBackground( true ); // switch to gradient mode
649 VTKViewer_OpenGLRenderer* aRenderer =
650 VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
653 aRenderer->SetGradientType( type );
654 aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
655 aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
661 case Qtx::CustomGradientBackground:
663 // NOT IMPLEMENTED YET
664 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
665 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
672 if ( bgData.isTextureShown() ) {
674 int textureMode = bgData.texture( fileName );
675 QFileInfo fi( fileName );
676 if ( !fileName.isEmpty() && fi.exists() ) {
677 // read texture from file
678 QString extension = fi.suffix().toLower();
679 vtkImageReader2* aReader = 0;
680 if ( extension == "jpg" || extension == "jpeg" )
681 aReader = vtkJPEGReader::New();
682 else if ( extension == "bmp" )
683 aReader = vtkBMPReader::New();
684 else if ( extension == "tif" || extension == "tiff" )
685 aReader = vtkTIFFReader::New();
686 else if ( extension == "png" )
687 aReader = vtkPNGReader::New();
688 else if ( extension == "mhd" || extension == "mha" )
689 aReader = vtkMetaImageReader::New();
692 aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
694 VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
695 vtkImageMapToColors* aMap = 0;
696 vtkAlgorithmOutput* anOutput;
698 // special processing for BMP reader
699 vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
701 // Special processing for BMP file
702 aBMPReader->SetAllow8BitBMP(1);
704 aMap = vtkImageMapToColors::New();
705 aMap->SetInputConnection( aBMPReader->GetOutputPort() );
706 aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
707 aMap->SetOutputFormatToRGB();
709 anOutput = aMap->GetOutputPort();
714 anOutput = aReader->GetOutputPort( 0 );
715 aTexture->SetInputConnection( anOutput );
717 // VSR: Currently, VTK only supports Stretch mode, so below code will give
718 // the same results for all modes
719 switch ( textureMode ) {
720 case Qtx::TileTexture:
721 aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
723 case Qtx::StretchTexture:
724 aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
726 case Qtx::CenterTexture:
727 aTexture->SetPosition((int)VTKViewer_Texture::Centered);
731 // show textured background
732 getRenderer()->SetTexturedBackground( true );
733 getRenderer()->SetBackgroundTexture( aTexture );
735 // clean-up resources
746 myBackground = bgData;
750 \return background data of viewer
752 Qtx::BackgroundData SVTK_ViewWindow::background() const
759 Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
761 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
763 return GetInteractor()->GetInteractorStyle();
767 Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
769 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
771 GetInteractor()->PushInteractorStyle(theStyle);
775 Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
777 void SVTK_ViewWindow::PopInteractorStyle()
779 GetInteractor()->PopInteractorStyle();
783 Updates current viewer
785 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
787 if(theUpdateTrihedron)
788 GetRenderer()->OnAdjustTrihedron();
790 GetInteractor()->update();
792 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
794 #ifdef VGL_WORKAROUND
795 if ( aStyle->GetCurrentRenderer() == nullptr ) {
796 if( GetRenderer() ) {
797 aStyle->SetCurrentRenderer(GetRenderer()->GetDevice());
806 Redirect the request to #SVTK_Renderer::GetScale
808 void SVTK_ViewWindow::GetScale( double theScale[3] )
810 GetRenderer()->GetScale( theScale );
814 Redirect the request to #SVTK_Renderer::SetScale
816 void SVTK_ViewWindow::SetScale( double theScale[3] )
818 GetRenderer()->SetScale( theScale );
820 emit transformed( this );
824 Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
826 bool SVTK_ViewWindow::isTrihedronDisplayed()
828 return GetRenderer()->IsTrihedronDisplayed();
832 Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
834 bool SVTK_ViewWindow::isCubeAxesDisplayed()
836 return GetRenderer()->IsCubeAxesDisplayed();
840 Redirect the request to #SVTK_Renderer::OnViewTrihedron
842 void SVTK_ViewWindow::onViewTrihedron(bool show)
844 GetRenderer()->SetTrihedronVisibility(show);
849 Redirect the request to #SVTK_Renderer::OnViewCubeAxes
851 void SVTK_ViewWindow::onViewCubeAxes()
853 GetRenderer()->OnViewCubeAxes();
858 Redirect the request to #SVTK_Renderer::GetTrihedron
860 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
862 return GetRenderer()->GetTrihedron();
866 Redirect the request to #SVTK_Renderer::GetCubeAxes
868 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
870 return GetRenderer()->GetCubeAxes();
874 \return trihedron size
876 double SVTK_ViewWindow::GetTrihedronSize() const
878 return GetRenderer()->GetTrihedronSize();
883 \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo )
885 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
887 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
888 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
889 QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
893 onProjectionMode( aParallelAction );
896 onProjectionMode( aProjectionAction );
899 onStereoMode( true );
903 // update action state if method is called outside
904 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
905 QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
906 if ( theMode == Parallel && !aParallelAction->isChecked() ) {
907 aParallelAction->setChecked( true );
908 aSwitchZoomingStyle->setEnabled(true);
909 aStereoAction->setChecked( false );
911 if ( theMode == Projection && !aProjectionAction->isChecked() ) {
912 aProjectionAction->setChecked( true );
913 aSwitchZoomingStyle->setEnabled(false);
915 if ( theMode == Stereo ) {
916 aStereoAction->setChecked( true );
917 if ( aParallelAction->isEnabled() ) {
918 aParallelAction->setEnabled( false );
919 aParallelAction->setChecked( false );
920 aStereoAction->setChecked( false );
923 aParallelAction->setEnabled( true );
924 aStereoAction->setChecked( false );
925 aParallelAction->setChecked( aViewer->projectionMode() == Parallel );
927 if ( aProjectionAction->isEnabled() ) {
928 aProjectionAction->setEnabled( false );
929 aProjectionAction->setChecked( true );
930 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
931 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
932 toolMgr()->action( StereoModeId )->isChecked() ) {
933 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
937 aProjectionAction->setEnabled( true );
938 aStereoAction->setChecked( false );
939 aProjectionAction->setChecked( aViewer->projectionMode() == Projection );
944 if ( !aParallelAction->isEnabled() )
945 aParallelAction->setEnabled( true );
946 if ( !aProjectionAction->isEnabled() )
947 aProjectionAction->setEnabled( true );
953 \param theType - stereo type
955 void SVTK_ViewWindow::SetStereoType(const int theType)
957 vtkRenderWindow* aWindow = getRenderWindow();
960 aWindow->SetStereoTypeToCrystalEyes();
963 aWindow->SetStereoTypeToRedBlue();
966 aWindow->SetStereoTypeToInterlaced();
969 aWindow->SetStereoTypeToLeft();
972 aWindow->SetStereoTypeToRight();
975 aWindow->SetStereoTypeToDresden();
978 aWindow->SetStereoTypeToAnaglyph();
981 aWindow->SetStereoTypeToCheckerboard();
983 case SplitViewPortHorizontal:
984 aWindow->SetStereoTypeToSplitViewportHorizontal();
991 \param theFilter - anaglyph filter
993 void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter)
995 vtkRenderWindow* aWindow = getRenderWindow();
996 switch (theFilter ) {
998 aWindow->SetAnaglyphColorMask(4,3);
1001 aWindow->SetAnaglyphColorMask(6,1);
1004 aWindow->SetAnaglyphColorMask(2,5);
1010 Set support quad-buffered stereo
1011 \param theEnable - enable/disable support quad-buffered stereo
1013 void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable)
1015 vtkRenderWindow* aWindow = getRenderWindow();
1016 aWindow->SetStereoCapableWindow((int)theEnable);
1020 \return OpenGl stereo support
1022 bool SVTK_ViewWindow::isOpenGlStereoSupport() const
1024 GLboolean support[1];
1025 glGetBooleanv (GL_STEREO, support);
1032 Set the gravity center as a focal point
1034 void SVTK_ViewWindow::activateSetFocalPointGravity()
1036 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
1040 Set the selected point as a focal point
1042 void SVTK_ViewWindow::activateSetFocalPointSelected()
1044 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
1048 Set the point selected by user as a focal point
1050 void SVTK_ViewWindow::activateStartFocalPointSelection()
1052 myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
1055 void SVTK_ViewWindow::activateProjectionMode(int theMode)
1057 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
1058 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
1060 aParallelAction->setChecked( true );
1062 aProjectionAction->setChecked( true );
1064 if ( !aParallelAction->isEnabled() )
1065 aParallelAction->setEnabled( true );
1066 if ( !aProjectionAction->isEnabled() )
1067 aProjectionAction->setEnabled( true );
1071 Sets actual interaction style
1072 \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
1074 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
1076 onSwitchInteractionStyle( theStyle==1 );
1080 Sets actual zooming style
1081 \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) )
1083 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
1085 onSwitchZoomingStyle( theStyle==1 );
1089 Set preselection mode.
1090 \param theMode the mode to set (standard, dynamic or disabled)
1092 void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
1094 onSwitchPreSelectionMode( theMode );
1098 Enables/disables selection.
1099 \param theEnable if true - selection will be enabled
1101 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
1103 GetSelector()->SetSelectionEnabled( theEnable );
1104 QtxAction* a = getAction( EnableSelectionId );
1105 if ( a->isChecked() != theEnable)
1106 a->setChecked( theEnable );
1107 QtxActionGroup* aPreselectionGroup =
1108 dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
1109 if ( aPreselectionGroup )
1110 aPreselectionGroup->setEnabled( theEnable );
1113 vtkActorCollection *actors = getRenderer()->GetActors();
1114 for (int i = 0; i < actors->GetNumberOfItems(); ++i )
1115 if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
1117 actor->EnableSelection( theEnable );
1122 Switches "keyboard free" interaction style on/off
1124 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
1127 // check if style is already set
1128 if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
1130 // keep the same style extensions
1131 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
1133 myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
1134 myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
1137 PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
1141 // pop only key free style
1142 if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
1143 PopInteractorStyle();
1146 // update action state if method is called outside
1147 QtxAction* a = getAction( SwitchInteractionStyleId );
1148 if ( a->isChecked() != theOn ) a->setChecked( theOn );
1152 Toogles advanced zooming style (relatively to the cursor position) on/off
1154 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
1156 if( myDefaultInteractorStyle.GetPointer() )
1157 myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1158 if( myKeyFreeInteractorStyle.GetPointer() )
1159 myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1161 // update action state if method is called outside
1162 QtxAction* a = getAction( SwitchZoomingStyleId );
1163 if ( a->isChecked() != theOn )
1164 a->setChecked( theOn );
1168 Switch preselection mode.
1169 \param theMode the preselection mode
1171 void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
1173 GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection );
1174 GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled );
1176 // update action state if method is called outside
1177 QtxAction* a = getAction( StandardPreselectionId + theMode );
1178 if ( a && !a->isChecked() )
1179 a->setChecked( true );
1183 Enables/disables selection.
1184 \param theOn if true - selection will be enabled
1186 void SVTK_ViewWindow::onEnableSelection( bool on )
1188 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
1190 aViewer->enableSelection(on);
1194 Sets incremental speed
1195 \param theValue - new incremental speed
1196 \param theMode - modification mode
1198 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
1200 if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
1201 ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
1205 Sets spacemouse buttons for the functions
1206 \param theBtn1 - spacemouse button for the "decrease speed increment"
1207 \param theBtn2 - spacemouse button for the "increase speed increment"
1208 \param theBtn3 - spacemouse button for the "dominant combined switch"
1210 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1,
1215 myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
1217 myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
1219 myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
1224 \param theSize - new trihedron size
1225 \param theRelative - trihedron relativeness
1227 void SVTK_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative)
1229 GetRenderer()->SetTrihedronSize(theSize, theRelative);
1233 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
1234 * trihedron and cube axes, even if trihedron and cube axes is invisible.
1236 void SVTK_ViewWindow::AdjustTrihedrons(const bool /*theIsForcedUpdate*/)
1238 GetRenderer()->AdjustActors();
1243 Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
1245 void SVTK_ViewWindow::onAdjustTrihedron()
1247 GetRenderer()->OnAdjustTrihedron();
1251 Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
1253 void SVTK_ViewWindow::onAdjustCubeAxes()
1255 GetRenderer()->OnAdjustCubeAxes();
1258 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
1260 if ( otherViewWindow ) {
1261 bool blocked = blockSignals( true );
1262 doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
1263 blockSignals( blocked );
1270 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
1272 emit keyPressed( this, event );
1278 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
1280 emit keyReleased( this, event );
1286 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
1288 emit mousePressed(this, event);
1292 Emits mouse released
1294 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
1296 emit mouseReleased( this, event );
1302 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
1304 emit mouseMoving( this, event );
1308 Emits mouse double clicked
1310 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
1312 emit mouseDoubleClicked( this, event );
1316 Redirect the request to #SVTK_Renderer::AddActor
1318 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor,
1320 bool theIsAdjustActors )
1322 GetRenderer()->AddActor(theActor, theIsAdjustActors);
1325 emit actorAdded(theActor);
1329 Redirect the request to #SVTK_Renderer::RemoveActor
1331 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor,
1333 bool theIsAdjustActors )
1335 GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
1336 if ( myDefaultInteractorStyle )
1337 myDefaultInteractorStyle->FreeActors();
1338 if ( myKeyFreeInteractorStyle )
1339 myKeyFreeInteractorStyle->FreeActors();
1342 emit actorRemoved(theActor);
1345 QImage SVTK_ViewWindow::dumpViewContent()
1347 vtkRenderWindow* aWindow = getRenderWindow();
1348 int* aSize = aWindow->GetSize();
1349 int aWidth = aSize[0];
1350 int aHeight = aSize[1];
1352 #ifndef DISABLE_GLVIEWER
1353 OpenGLUtils_FrameBuffer aFrameBuffer;
1354 if( aFrameBuffer.init( aWidth, aHeight ) )
1356 glPushAttrib( GL_VIEWPORT_BIT );
1357 glViewport( 0, 0, aWidth, aHeight );
1358 aFrameBuffer.bind();
1363 //aFrameBuffer.unbind();
1366 QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1367 //aFrameBuffer.bind();
1369 glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1370 aFrameBuffer.unbind();
1372 anImage = anImage.rgbSwapped();
1373 anImage = anImage.mirrored();
1378 // if frame buffers are unsupported, use old functionality
1379 unsigned char *aData =
1380 aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
1382 QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
1384 anImage = anImage.rgbSwapped();
1385 anImage = anImage.mirrored();
1390 \return QImage, containing all scene rendering in window
1392 QImage SVTK_ViewWindow::dumpView()
1394 if( myDumpImage.isNull() )
1395 return dumpViewContent();
1401 QString SVTK_ViewWindow::filter() const
1403 return tr( "SVTK_IMAGE_FILES" );
1406 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
1408 if ( format != "PS" && format != "EPS" && format != "PDF" )
1409 return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1411 SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
1412 if ( optionsDlg->exec() == QDialog::Accepted ) {
1413 SUIT_OverrideCursor wc;
1415 vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
1416 anExporter->SetRenderWindow(getRenderWindow());
1419 anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
1420 anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
1421 anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
1422 anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
1423 anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
1425 if ( format == "PS" ) {
1426 anExporter->SetFileFormatToPS();
1427 anExporter->CompressOff();
1430 if ( format == "EPS" ) {
1431 anExporter->SetFileFormatToEPS();
1432 anExporter->CompressOff();
1435 if ( format == "PDF" ) {
1436 anExporter->SetFileFormatToPDF();
1439 QString aFilePrefix(fileName);
1440 QString anExtension(SUIT_Tools::extension(fileName));
1441 aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
1442 anExporter->SetFilePrefix(aFilePrefix.toUtf8().data());
1443 anExporter->Write();
1444 anExporter->Delete();
1451 \refresh QImage, containing all scene rendering in window
1453 void SVTK_ViewWindow::RefreshDumpImage()
1455 myDumpImage = dumpViewContent();
1459 Redirect the request to #SVTK_Renderer::SetSelectionProp
1461 void SVTK_ViewWindow::SetSelectionProp(const double& theRed,
1462 const double& theGreen,
1463 const double& theBlue,
1464 const int& theWidth)
1466 myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
1470 Redirect the request to #SVTK_Renderer::SetSelectionProp
1472 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed,
1473 const double& theGreen,
1474 const double& theBlue,
1475 const int& theWidth)
1477 myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
1481 Redirect the request to #SVTK_Renderer::SetSelectionTolerance
1483 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes,
1484 const double& theTolItems,
1485 const double& theTolObjects)
1487 myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
1491 Get visibility status of the static trihedron
1493 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
1495 return (bool)myAxesWidget->GetEnabled();
1499 Set visibility status of the static trihedron
1501 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
1503 myAxesWidget->SetEnabled( (int)theIsVisible );
1508 \param accelAction - action
1510 bool SVTK_ViewWindow::action( const int accelAction )
1512 if ( accelAction == SUIT_Accel::ZoomFit )
1515 int anEvent = SVTK::convertAction( accelAction );
1516 GetInteractor()->InvokeEvent(anEvent, 0);
1522 \return action by it's id
1524 QtxAction* SVTK_ViewWindow::getAction( int id ) const
1526 return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
1530 // old visual parameters had 13 values. New format added additional
1531 // 76 values for graduated axes, so both numbers are processed.
1532 const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
1533 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
1534 const int nTrihedronParams = 3; // number of parameters for Trihedron
1535 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
1537 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
1539 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
1546 bool isVisible = actor->GetTitleVisibility();
1547 QString title ( actor->GetTitle() );
1549 int font = VTK_ARIAL;
1554 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1557 txtProp->GetColor( color );
1558 font = txtProp->GetFontFamily();
1559 bold = txtProp->GetBold();
1560 italic = txtProp->GetItalic();
1561 shadow = txtProp->GetShadow();
1563 writer.writeStartElement("GraduatedAxis");
1564 writer.writeAttribute("Axis", theAxis);
1566 writer.writeStartElement("Title");
1567 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1568 writer.writeAttribute("Text", title);
1569 writer.writeAttribute("Font", QString("%1").arg(font));
1570 writer.writeAttribute("Bold", QString("%1").arg(bold));
1571 writer.writeAttribute("Italic", QString("%1").arg(italic));
1572 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1574 writer.writeStartElement("Color");
1575 writer.writeAttribute("R", QString("%1").arg(color[0]));
1576 writer.writeAttribute("G", QString("%1").arg(color[1]));
1577 writer.writeAttribute("B", QString("%1").arg(color[2]));
1578 writer.writeEndElement();
1579 writer.writeEndElement();
1581 //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
1582 // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1585 isVisible = actor->GetLabelVisibility();
1586 int labels = actor->GetNumberOfLabels();
1587 int offset = actor->GetTickOffset();
1593 txtProp = actor->GetLabelTextProperty();
1596 txtProp->GetColor( color );
1597 font = txtProp->GetFontFamily();
1598 bold = txtProp->GetBold();
1599 italic = txtProp->GetItalic();
1600 shadow = txtProp->GetShadow();
1603 writer.writeStartElement("Labels");
1604 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1605 writer.writeAttribute("Number", QString("%1").arg(labels));
1606 writer.writeAttribute("Offset", QString("%1").arg(offset));
1607 writer.writeAttribute("Font", QString("%1").arg(font));
1608 writer.writeAttribute("Bold", QString("%1").arg(bold));
1609 writer.writeAttribute("Italic", QString("%1").arg(italic));
1610 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1612 writer.writeStartElement("Color");
1613 writer.writeAttribute("R", QString("%1").arg(color[0]));
1614 writer.writeAttribute("G", QString("%1").arg(color[1]));
1615 writer.writeAttribute("B", QString("%1").arg(color[2]));
1616 writer.writeEndElement();
1617 writer.writeEndElement();
1618 // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
1619 // color[0], color[1], color[2], font, bold, italic, shadow );
1622 isVisible = actor->GetTickVisibility();
1623 int length = actor->GetTickLength();
1624 writer.writeStartElement("TickMarks");
1625 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1626 writer.writeAttribute("Length", QString("%1").arg(length));
1627 writer.writeEndElement();
1629 //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1631 writer.writeEndElement();
1635 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1642 } while (!reader.isStartElement());
1644 // Read title params
1645 QXmlStreamAttributes aAttr = reader.attributes();
1646 bool isVisible = aAttr.value("isVisible").toString().toUShort();
1647 QString title = aAttr.value("Text").toString();
1648 int font = aAttr.value("Font").toString().toInt();
1649 int bold = aAttr.value("Bold").toString().toInt();
1650 int italic = aAttr.value("Italic").toString().toInt();
1651 int shadow = aAttr.value("Shadow").toString().toInt();
1653 //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1657 } while (!reader.isStartElement());
1660 aAttr = reader.attributes();
1663 color[0] = aAttr.value("R").toString().toDouble();
1664 color[1] = aAttr.value("G").toString().toDouble();
1665 color[2] = aAttr.value("B").toString().toDouble();
1666 //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1668 actor->SetTitleVisibility( isVisible );
1669 actor->SetTitle( title.toUtf8() );
1670 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1672 txtProp->SetColor( color );
1673 txtProp->SetFontFamily( font );
1674 txtProp->SetBold( bold );
1675 txtProp->SetItalic( italic );
1676 txtProp->SetShadow( shadow );
1683 } while (!reader.isStartElement());
1685 aAttr = reader.attributes();
1686 isVisible = aAttr.value("isVisible").toString().toUShort();
1687 int labels = aAttr.value("Number").toString().toInt();
1688 int offset = aAttr.value("Offset").toString().toInt();
1689 font = aAttr.value("Font").toString().toInt();
1690 bold = aAttr.value("Bold").toString().toInt();
1691 italic = aAttr.value("Italic").toString().toInt();
1692 shadow = aAttr.value("Shadow").toString().toInt();
1696 } while (!reader.isStartElement());
1698 aAttr = reader.attributes();
1700 color[0] = aAttr.value("R").toString().toDouble();
1701 color[1] = aAttr.value("G").toString().toDouble();
1702 color[2] = aAttr.value("B").toString().toDouble();
1704 actor->SetLabelVisibility( isVisible );
1705 actor->SetNumberOfLabels( labels );
1706 actor->SetTickOffset( offset );
1707 txtProp = actor->GetLabelTextProperty();
1709 txtProp->SetColor( color );
1710 txtProp->SetFontFamily( font );
1711 txtProp->SetBold( bold );
1712 txtProp->SetItalic( italic );
1713 txtProp->SetShadow( shadow );
1719 } while (!reader.isStartElement());
1720 aAttr = reader.attributes();
1722 // retrieve and set tick marks properties
1723 isVisible = aAttr.value("isVisible").toString().toUShort();
1724 int length = aAttr.value("Length").toString().toInt();
1726 actor->SetTickVisibility( isVisible );
1727 actor->SetTickLength( length );
1730 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1732 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1737 QStringList paramsLst = params.split( '*' );
1739 if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1741 // retrieve and set name parameters
1742 bool isVisible = paramsLst[2].toUShort();
1743 QString title = paramsLst[3];
1745 color[0] = paramsLst[4].toDouble();
1746 color[1] = paramsLst[5].toDouble();
1747 color[2] = paramsLst[6].toDouble();
1748 int font = paramsLst[7].toInt();
1749 int bold = paramsLst[8].toInt();
1750 int italic = paramsLst[9].toInt();
1751 int shadow = paramsLst[10].toInt();
1753 actor->SetTitleVisibility( isVisible );
1754 actor->SetTitle( title.toUtf8() );
1755 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1757 txtProp->SetColor( color );
1758 txtProp->SetFontFamily( font );
1759 txtProp->SetBold( bold );
1760 txtProp->SetItalic( italic );
1761 txtProp->SetShadow( shadow );
1764 // retrieve and set lable parameters
1765 isVisible = paramsLst[12].toUShort();
1766 int labels = paramsLst[13].toInt();
1767 int offset = paramsLst[14].toInt();
1768 color[0] = paramsLst[15].toDouble();
1769 color[1] = paramsLst[16].toDouble();
1770 color[2] = paramsLst[17].toDouble();
1771 font = paramsLst[18].toInt();
1772 bold = paramsLst[19].toInt();
1773 italic = paramsLst[20].toInt();
1774 shadow = paramsLst[21].toInt();
1776 actor->SetLabelVisibility( isVisible );
1777 actor->SetNumberOfLabels( labels );
1778 actor->SetTickOffset( offset );
1779 txtProp = actor->GetLabelTextProperty();
1781 txtProp->SetColor( color );
1782 txtProp->SetFontFamily( font );
1783 txtProp->SetBold( bold );
1784 txtProp->SetItalic( italic );
1785 txtProp->SetShadow( shadow );
1788 // retrieve and set tick marks properties
1789 isVisible = paramsLst[23].toUShort();
1790 int length = paramsLst[24].toInt();
1792 actor->SetTickVisibility( isVisible );
1793 actor->SetTickLength( length );
1797 /*! The method returns the visual parameters of this view as a formated string
1799 QString SVTK_ViewWindow::getVisualParameters()
1801 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1803 // save position, focal point, viewUp, scale
1804 vtkCamera* camera = getRenderer()->GetActiveCamera();
1805 camera->GetPosition( pos );
1806 camera->GetFocalPoint( focalPnt );
1807 camera->GetViewUp( viewUp );
1808 parScale = camera->GetParallelScale();
1811 // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1812 // view up values (3 digits), parallel scale (1 digit), scale (3 digits,
1813 // Graduated axes parameters (X, Y, Z axes parameters)
1815 QXmlStreamWriter aWriter(&retStr);
1816 aWriter.setAutoFormatting(true);
1818 aWriter.writeStartDocument();
1819 aWriter.writeStartElement("ViewState");
1821 aWriter.writeStartElement("Position");
1822 aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1823 aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1824 aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1825 aWriter.writeEndElement();
1827 aWriter.writeStartElement("FocalPoint");
1828 aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1829 aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1830 aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1831 aWriter.writeEndElement();
1833 aWriter.writeStartElement("ViewUp");
1834 aWriter.writeAttribute("X", QString::number(viewUp[0]));
1835 aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1836 aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1837 aWriter.writeEndElement();
1839 aWriter.writeStartElement("ViewScale");
1840 aWriter.writeAttribute("Parallel", QString::number(parScale));
1841 aWriter.writeAttribute("X", QString::number(scale[0]));
1842 aWriter.writeAttribute("Y", QString::number(scale[1]));
1843 aWriter.writeAttribute("Z", QString::number(scale[2]));
1844 aWriter.writeEndElement();
1846 if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1847 aWriter.writeStartElement("DisplayCubeAxis");
1848 aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1849 aWriter.writeEndElement();
1851 getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1852 getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1853 getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1856 aWriter.writeStartElement("Trihedron");
1857 aWriter.writeAttribute("isShown", QString( "%1" ).arg( isTrihedronDisplayed()));
1858 aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1859 aWriter.writeEndElement();
1861 aWriter.writeStartElement("Background");
1862 aWriter.writeAttribute("Value", QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
1863 aWriter.writeEndElement();
1865 aWriter.writeEndElement();
1866 aWriter.writeEndDocument();
1872 The method restores visual parameters of this view or postpones it untill the view is shown
1874 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1876 //printf("#### %s\n", qPrintable(parameters));
1877 SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1878 if ( anInteractor->isVisible() ) {
1879 doSetVisualParameters( parameters );
1882 myVisualParams = parameters;
1883 anInteractor->installEventFilter(this);
1888 The method restores visual parameters of this view from a formated string
1890 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
1893 double pos[3], focalPnt[3], viewUp[3], parScale = 1.0, scale[3];
1895 QXmlStreamReader aReader(parameters);
1896 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1898 while(!aReader.atEnd()) {
1900 if (aReader.isStartElement()) {
1901 QXmlStreamAttributes aAttr = aReader.attributes();
1902 //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1903 if (aReader.name() == "Position") {
1904 pos[0] = aAttr.value("X").toString().toDouble();
1905 pos[1] = aAttr.value("Y").toString().toDouble();
1906 pos[2] = aAttr.value("Z").toString().toDouble();
1907 //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1909 else if (aReader.name() == "FocalPoint") {
1910 focalPnt[0] = aAttr.value("X").toString().toDouble();
1911 focalPnt[1] = aAttr.value("Y").toString().toDouble();
1912 focalPnt[2] = aAttr.value("Z").toString().toDouble();
1913 //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1915 else if (aReader.name() == "ViewUp") {
1916 viewUp[0] = aAttr.value("X").toString().toDouble();
1917 viewUp[1] = aAttr.value("Y").toString().toDouble();
1918 viewUp[2] = aAttr.value("Z").toString().toDouble();
1919 //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1921 else if (aReader.name() == "ViewScale") {
1922 parScale = aAttr.value("Parallel").toString().toDouble();
1923 scale[0] = aAttr.value("X").toString().toDouble();
1924 scale[1] = aAttr.value("Y").toString().toDouble();
1925 scale[2] = aAttr.value("Z").toString().toDouble();
1926 //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1928 else if (aReader.name() == "DisplayCubeAxis") {
1929 if ( !baseParamsOnly ) {
1930 if (aAttr.value("Show") == "0")
1931 gradAxesActor->VisibilityOff();
1933 gradAxesActor->VisibilityOn();
1936 else if (aReader.name() == "GraduatedAxis") {
1937 if ( !baseParamsOnly ) {
1938 if(aAttr.value("Axis") == "X")
1939 setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1940 else if(aAttr.value("Axis") == "Y")
1941 setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1942 else if(aAttr.value("Axis") == "Z")
1943 setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1946 else if (aReader.name() == "Trihedron") {
1947 if ( !baseParamsOnly ) {
1948 if (aAttr.value("isShown") == "0")
1949 GetTrihedron()->VisibilityOff();
1951 GetTrihedron()->VisibilityOn();
1952 SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1955 else if (aReader.name() == "Background") {
1956 if ( !baseParamsOnly ) {
1957 setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
1962 if (!aReader.hasError()) {
1963 vtkCamera* camera = getRenderer()->GetActiveCamera();
1964 camera->SetPosition( pos );
1965 camera->SetFocalPoint( focalPnt );
1966 camera->SetViewUp( viewUp );
1967 camera->SetParallelScale( parScale );
1968 GetRenderer()->SetScale( scale );
1969 //SetScale( scale );
1972 QStringList paramsLst = parameters.split( '*' );
1973 if ( paramsLst.size() >= nNormalParams ) {
1974 // 'reading' list of parameters
1975 pos[0] = paramsLst[0].toDouble();
1976 pos[1] = paramsLst[1].toDouble();
1977 pos[2] = paramsLst[2].toDouble();
1978 focalPnt[0] = paramsLst[3].toDouble();
1979 focalPnt[1] = paramsLst[4].toDouble();
1980 focalPnt[2] = paramsLst[5].toDouble();
1981 viewUp[0] = paramsLst[6].toDouble();
1982 viewUp[1] = paramsLst[7].toDouble();
1983 viewUp[2] = paramsLst[8].toDouble();
1984 parScale = paramsLst[9].toDouble();
1985 scale[0] = paramsLst[10].toDouble();
1986 scale[1] = paramsLst[11].toDouble();
1987 scale[2] = paramsLst[12].toDouble();
1989 // applying parameters
1990 vtkCamera* camera = getRenderer()->GetActiveCamera();
1991 camera->SetPosition( pos );
1992 camera->SetFocalPoint( focalPnt );
1993 camera->SetViewUp( viewUp );
1994 camera->SetParallelScale( parScale );
1995 GetRenderer()->SetScale( scale );
1996 //SetScale( scale );
1998 // apply graduated axes parameters
1999 if ( !baseParamsOnly ) {
2000 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
2001 if ( gradAxesActor && paramsLst.size() == nAllParams ) {
2002 int i = nNormalParams+1, j = i + nGradAxisParams - 1;
2003 ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
2004 i = j + 1; j += nGradAxisParams;
2005 ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
2006 i = j + 1; j += nGradAxisParams;
2007 ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
2009 if ( paramsLst[13].toUShort() )
2010 gradAxesActor->VisibilityOn();
2012 gradAxesActor->VisibilityOff();
2014 else if ( paramsLst.size() == nAllParams ) {
2015 if ( paramsLst[90].toUShort() )
2016 GetTrihedron()->VisibilityOn();
2018 GetTrihedron()->VisibilityOff();
2020 SetTrihedronSize(paramsLst[91].toDouble());
2030 Delayed setVisualParameters
2032 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
2034 if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
2035 SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
2036 if ( anInteractor->isVisible() ) {
2037 doSetVisualParameters( myVisualParams );
2038 anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
2041 return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
2046 Change rotation point
2048 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
2051 mySetRotationPointDlg->addObserver();
2052 if ( mySetRotationPointDlg->IsFirstShown() )
2053 activateSetRotationGravity();
2054 mySetRotationPointDlg->show();
2056 mySetRotationPointDlg->hide();
2060 Set the gravity center as a rotation point
2062 void SVTK_ViewWindow::activateSetRotationGravity()
2064 myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
2068 Set the selected point as a rotation point
2070 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
2072 myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
2076 Set the gravity center of element selected by user as a rotation point
2078 void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
2080 SetSelectionMode( theSelectionMode );
2081 myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
2085 \brief Set the given projection mode.
2087 Set the given projection mode: Orthographic or Perspective.
2089 void SVTK_ViewWindow::onProjectionMode( QAction* theAction )
2091 int aMode = Parallel;
2092 if (theAction == toolMgr()->action( ProjectionModeId ))
2094 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2095 aViewer->setProjectionMode(aMode);
2096 bool anIsParallelMode = (aMode == Parallel);
2097 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2098 aCamera->SetParallelProjection(anIsParallelMode);
2099 GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
2100 getRenderWindow()->SetStereoRender(0);
2105 \brief Sets Stereo projection mode.
2107 Sets Stereo projection mode.
2109 void SVTK_ViewWindow::onStereoMode( bool activate )
2112 toolMgr()->action( ProjectionModeId )->setChecked(true);
2113 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2114 aCamera->SetParallelProjection(false);
2115 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false);
2116 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2117 SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
2118 getRenderWindow()->SetStereoRender(1);
2122 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true);
2123 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2124 if (aViewer->projectionMode() == Parallel) {
2125 toolMgr()->action( ParallelModeId )->setChecked(true);
2126 onProjectionMode(toolMgr()->action( ParallelModeId ));
2128 else if (aViewer->projectionMode() == Projection) {
2129 toolMgr()->action( ProjectionModeId )->setChecked(true);
2130 onProjectionMode(toolMgr()->action( ProjectionModeId ));
2133 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
2134 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
2135 toolMgr()->action( StereoModeId )->isChecked() )
2136 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
2140 Set the view projection mode: orthogonal or perspective
2142 void SVTK_ViewWindow::onProjectionMode()
2144 if (toolMgr()->action( ParallelModeId )->isChecked())
2145 SetProjectionMode( Parallel);
2146 if (toolMgr()->action( ProjectionModeId )->isChecked())
2147 SetProjectionMode( Projection);
2148 if (toolMgr()->action( StereoModeId )->isChecked())
2149 SetProjectionMode( Stereo);
2150 emit transformed( this );
2153 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
2155 myEventDispatcher = theDispatcher;
2159 Creates all actions of svtk main window
2161 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
2163 QtxAction* anAction;
2164 QtxActionToolMgr* mgr = toolMgr();
2167 anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
2168 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
2169 tr( "MNU_DUMP_VIEW" ), 0, this);
2170 anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
2171 connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
2172 mgr->registerAction( anAction, DumpId );
2175 anAction = new QtxAction(tr("MNU_FITALL"),
2176 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
2177 tr( "MNU_FITALL" ), 0, this);
2178 anAction->setStatusTip(tr("DSC_FITALL"));
2179 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
2180 mgr->registerAction( anAction, FitAllId );
2183 anAction = new QtxAction(tr("MNU_FITRECT"),
2184 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
2185 tr( "MNU_FITRECT" ), 0, this);
2186 anAction->setStatusTip(tr("DSC_FITRECT"));
2187 connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
2188 mgr->registerAction( anAction, FitRectId );
2191 anAction = new QtxAction(tr("MNU_FITSELECTION"),
2192 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
2193 tr( "MNU_FITSELECTION" ), 0, this);
2194 anAction->setStatusTip(tr("DSC_FITSELECTION"));
2195 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
2196 mgr->registerAction( anAction, FitSelectionId );
2199 anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
2200 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
2201 tr( "MNU_ZOOM_VIEW" ), 0, this);
2202 anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
2203 connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
2204 mgr->registerAction( anAction, ZoomId );
2207 anAction = new QtxAction(tr("MNU_PAN_VIEW"),
2208 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
2209 tr( "MNU_PAN_VIEW" ), 0, this);
2210 anAction->setStatusTip(tr("DSC_PAN_VIEW"));
2211 connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
2212 mgr->registerAction( anAction, PanId );
2215 anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
2216 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
2217 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
2218 anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
2219 connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
2220 mgr->registerAction( anAction, GlobalPanId );
2222 // Change rotation point
2223 anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
2224 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
2225 tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
2226 anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
2227 anAction->setCheckable(true);
2228 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
2229 mgr->registerAction( anAction, ChangeRotationPointId );
2232 anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
2233 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
2234 tr( "MNU_ROTATE_VIEW" ), 0, this);
2235 anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
2236 connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
2237 mgr->registerAction( anAction, RotationId );
2240 anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
2241 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
2242 tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
2243 anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
2244 connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
2245 this->addAction(anAction);
2246 mgr->registerAction( anAction, FrontId );
2248 anAction = new QtxAction(tr("MNU_BACK_VIEW"),
2249 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
2250 tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
2251 anAction->setStatusTip(tr("DSC_BACK_VIEW"));
2252 connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView()));
2253 this->addAction(anAction);
2254 mgr->registerAction( anAction, BackId );
2256 anAction = new QtxAction(tr("MNU_TOP_VIEW"),
2257 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
2258 tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
2259 anAction->setStatusTip(tr("DSC_TOP_VIEW"));
2260 connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView()));
2261 this->addAction(anAction);
2262 mgr->registerAction( anAction, TopId );
2264 anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
2265 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
2266 tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
2267 anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
2268 connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
2269 this->addAction(anAction);
2270 mgr->registerAction( anAction, BottomId );
2272 anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
2273 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
2274 tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
2275 anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
2276 connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
2277 this->addAction(anAction);
2278 mgr->registerAction( anAction, LeftId );
2280 anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
2281 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
2282 tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
2283 anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
2284 connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView()));
2285 this->addAction(anAction);
2286 mgr->registerAction( anAction, RightId );
2288 // rotate anticlockwise
2289 anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
2290 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
2291 tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
2292 anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
2293 connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
2294 this->addAction(anAction);
2295 mgr->registerAction( anAction, AntiClockWiseId );
2298 anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
2299 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
2300 tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
2301 anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
2302 connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
2303 this->addAction(anAction);
2304 mgr->registerAction( anAction, ClockWiseId );
2307 anAction = new QtxAction(tr("MNU_RESET_VIEW"),
2308 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
2309 tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
2310 anAction->setStatusTip(tr("DSC_RESET_VIEW"));
2311 connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView()));
2312 this->addAction(anAction);
2313 mgr->registerAction( anAction, ResetId );
2315 // onViewTrihedron: Shows - Hides Trihedron
2316 anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
2317 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
2318 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
2319 anAction->setCheckable( true );
2320 anAction->setChecked( true );
2322 anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
2323 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
2324 mgr->registerAction( anAction, ViewTrihedronId );
2326 // onNonIsometric: Manage non-isometric params
2327 anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
2328 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
2329 tr( "MNU_SVTK_SCALING" ), 0, this);
2330 anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
2331 anAction->setCheckable(true);
2332 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
2333 mgr->registerAction( anAction, NonIsometric );
2335 // onGraduatedAxes: Manage graduated axes params
2336 anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
2337 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
2338 tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
2339 anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
2340 anAction->setCheckable(true);
2341 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
2342 mgr->registerAction( anAction, GraduatedAxes );
2344 // onGraduatedAxes: Manage graduated axes params
2345 anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"),
2346 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
2347 tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
2348 anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
2349 anAction->setCheckable(true);
2350 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
2351 mgr->registerAction( anAction, UpdateRate );
2353 // Set perspective mode group
2354 anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"),
2355 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
2356 tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
2357 anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
2358 anAction->setCheckable(true);
2359 mgr->registerAction( anAction, ParallelModeId );
2361 anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"),
2362 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
2363 tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
2364 anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
2365 anAction->setCheckable(true);
2366 mgr->registerAction( anAction, ProjectionModeId );
2368 anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
2369 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ),
2370 tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
2371 anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
2372 anAction->setCheckable(true);
2373 connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool)));
2374 mgr->registerAction( anAction, StereoModeId );
2376 QActionGroup* aPerspectiveGroup = new QActionGroup( this );
2377 aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
2378 aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
2379 connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*)));
2382 anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
2383 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
2384 tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
2385 anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
2386 anAction->setCheckable(true);
2387 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
2388 mgr->registerAction( anAction, ViewParametersId );
2391 mgr->registerAction( synchronizeAction(), SynchronizeId );
2393 // Switch between interaction styles
2394 anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
2395 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
2396 tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
2397 anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
2398 anAction->setCheckable(true);
2399 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
2400 mgr->registerAction( anAction, SwitchInteractionStyleId );
2402 // Switch between zooming styles
2403 anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"),
2404 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
2405 tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
2406 anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
2407 anAction->setCheckable(true);
2408 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
2409 mgr->registerAction( anAction, SwitchZoomingStyleId );
2412 QSignalMapper* aSignalMapper = new QSignalMapper( this );
2413 connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int)));
2415 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_STANDARD"),
2416 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ),
2417 tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
2418 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
2419 anAction->setCheckable(true);
2420 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2421 aSignalMapper->setMapping( anAction, Standard_Preselection );
2422 mgr->registerAction( anAction, StandardPreselectionId );
2424 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DYNAMIC"),
2425 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DYNAMIC" ) ),
2426 tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
2427 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
2428 anAction->setCheckable(true);
2429 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2430 aSignalMapper->setMapping( anAction, Dynamic_Preselection );
2431 mgr->registerAction( anAction, DynamicPreselectionId );
2433 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DISABLED"),
2434 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DISABLED" ) ),
2435 tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
2436 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
2437 anAction->setCheckable(true);
2438 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2439 aSignalMapper->setMapping( anAction, Preselection_Disabled );
2440 mgr->registerAction( anAction, DisablePreselectionId );
2442 QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true );
2443 aPreselectionAction->add( getAction( StandardPreselectionId ) );
2444 aPreselectionAction->add( getAction( DynamicPreselectionId ) );
2445 aPreselectionAction->add( getAction( DisablePreselectionId ) );
2446 mgr->registerAction( aPreselectionAction, PreselectionId );
2449 anAction = new QtxAction(tr("MNU_SVTK_ENABLE_SELECTION"),
2450 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SELECTION" ) ),
2451 tr( "MNU_SVTK_ENABLE_SELECTION" ), 0, this);
2452 anAction->setStatusTip(tr("DSC_SVTK_ENABLE_SELECTION"));
2453 anAction->setCheckable(true);
2454 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool)));
2455 mgr->registerAction( anAction, EnableSelectionId );
2458 myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
2459 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
2460 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
2461 myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
2462 connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
2463 mgr->registerAction( myStartAction, StartRecordingId );
2466 myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
2467 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
2468 tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
2469 myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
2470 myPlayAction->setEnabled( false );
2471 connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
2472 mgr->registerAction( myPlayAction, PlayRecordingId );
2475 myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
2476 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
2477 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
2478 myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
2479 myPauseAction->setEnabled( false );
2480 connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
2481 mgr->registerAction( myPauseAction, PauseRecordingId );
2484 myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
2485 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
2486 tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
2487 myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
2488 myStopAction->setEnabled( false );
2489 connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
2490 mgr->registerAction( myStopAction, StopRecordingId );
2494 Creates toolbar of svtk main window
2496 void SVTK_ViewWindow::createToolBar()
2498 QtxActionToolMgr* mgr = toolMgr();
2500 mgr->append( DumpId, myToolBar );
2501 mgr->append( SwitchInteractionStyleId, myToolBar );
2502 mgr->append( SwitchZoomingStyleId, myToolBar );
2504 mgr->append( mgr->separator(), myToolBar );
2506 mgr->append( PreselectionId, myToolBar );
2507 mgr->append( EnableSelectionId, myToolBar );
2509 mgr->append( mgr->separator(), myToolBar );
2511 mgr->append( ViewTrihedronId, myToolBar );
2513 QtxMultiAction* aScaleAction = new QtxMultiAction( this );
2514 aScaleAction->insertAction( getAction( FitAllId ) );
2515 aScaleAction->insertAction( getAction( FitRectId ) );
2516 aScaleAction->insertAction( getAction( FitSelectionId ) );
2517 aScaleAction->insertAction( getAction( ZoomId ) );
2518 mgr->append( aScaleAction, myToolBar );
2520 QtxMultiAction* aPanningAction = new QtxMultiAction( this );
2521 aPanningAction->insertAction( getAction( PanId ) );
2522 aPanningAction->insertAction( getAction( GlobalPanId ) );
2523 mgr->append( aPanningAction, myToolBar );
2525 mgr->append( ChangeRotationPointId, myToolBar );
2527 mgr->append( RotationId, myToolBar );
2529 QtxMultiAction* aViewsAction = new QtxMultiAction( this );
2530 aViewsAction->insertAction( getAction( FrontId ) );
2531 aViewsAction->insertAction( getAction( BackId ) );
2532 aViewsAction->insertAction( getAction( TopId ) );
2533 aViewsAction->insertAction( getAction( BottomId ) );
2534 aViewsAction->insertAction( getAction( LeftId ) );
2535 aViewsAction->insertAction( getAction( RightId ) );
2536 mgr->append( aViewsAction, myToolBar );
2538 mgr->append( AntiClockWiseId, myToolBar );
2539 mgr->append( ClockWiseId, myToolBar );
2541 mgr->append( ResetId, myToolBar );
2543 mgr->append( UpdateRate, myToolBar );
2544 mgr->append( NonIsometric, myToolBar );
2545 mgr->append( GraduatedAxes, myToolBar );
2547 mgr->append( ViewParametersId, myToolBar );
2548 mgr->append( SynchronizeId, myToolBar );
2550 mgr->append( toolMgr()->separator(), myToolBar );
2552 mgr->append( ParallelModeId, myToolBar );
2553 mgr->append( ProjectionModeId, myToolBar );
2554 mgr->append( StereoModeId, myToolBar );
2556 mgr->append( StartRecordingId, myRecordingToolBar );
2557 mgr->append( PlayRecordingId, myRecordingToolBar );
2558 mgr->append( PauseRecordingId, myRecordingToolBar );
2559 mgr->append( StopRecordingId, myRecordingToolBar );
2562 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
2565 myUpdateRateDlg->Update();
2566 myUpdateRateDlg->show();
2568 myUpdateRateDlg->hide();
2571 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
2574 myNonIsometricDlg->Update();
2575 myNonIsometricDlg->show();
2577 myNonIsometricDlg->hide();
2580 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
2583 myCubeAxesDlg->Update();
2584 myCubeAxesDlg->show();
2586 myCubeAxesDlg->hide();
2590 Starts rotation transformation
2592 void SVTK_ViewWindow::activateRotation()
2594 myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
2599 Starts panning transformation
2601 void SVTK_ViewWindow::activatePanning()
2603 myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
2607 Starts zoom transformation
2609 void SVTK_ViewWindow::activateZoom()
2611 myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
2615 Starts window fit transformation
2617 void SVTK_ViewWindow::activateWindowFit()
2619 myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
2623 Starts global panning transformation
2625 void SVTK_ViewWindow::activateGlobalPanning()
2627 myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
2630 void SVTK_ViewWindow::onStartRecording()
2632 myRecorder->CheckExistAVIMaker();
2633 if (myRecorder->ErrorStatus()) {
2634 SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
2637 SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
2639 if( !aRecorderDlg->exec() )
2642 myStartAction->setEnabled( false );
2643 myPlayAction->setEnabled( false );
2644 myPauseAction->setEnabled( true );
2645 myStopAction->setEnabled( true );
2647 // to prevent resizing the window while recording
2648 myPreRecordingMinSize = minimumSize();
2649 myPreRecordingMaxSize = maximumSize();
2650 setFixedSize( size() );
2652 myRecorder->Record();
2656 void SVTK_ViewWindow::onPlayRecording()
2658 myStartAction->setEnabled( false );
2659 myPlayAction->setEnabled( false );
2660 myPauseAction->setEnabled( true );
2661 myStopAction->setEnabled( true );
2663 myRecorder->Pause();
2666 void SVTK_ViewWindow::onPauseRecording()
2668 myStartAction->setEnabled( false );
2669 myPlayAction->setEnabled( true );
2670 myPauseAction->setEnabled( false );
2671 myStopAction->setEnabled( true );
2673 myRecorder->Pause();
2676 void SVTK_ViewWindow::onStopRecording()
2678 myStartAction->setEnabled( true );
2679 myPlayAction->setEnabled( false );
2680 myPauseAction->setEnabled( false );
2681 myStopAction->setEnabled( false );
2685 setMinimumSize( myPreRecordingMinSize );
2686 setMaximumSize( myPreRecordingMaxSize );
2690 To invoke a VTK event on SVTK_RenderWindowInteractor instance
2692 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
2694 GetInteractor()->InvokeEvent(theEvent,theCallData);
2698 Modify view parameters
2700 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
2703 myViewParameterDlg->addObserver();
2704 myViewParameterDlg->show();
2706 myViewParameterDlg->hide();
2710 Custom show event handler
2712 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent )
2714 emit Show( theEvent );
2718 Custom hide event handler
2720 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
2722 emit Hide( theEvent );
2726 Emit transformed signal.
2728 void SVTK_ViewWindow::emitTransformed() {
2735 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
2736 unsigned long /*theEvent*/,
2737 void* theClientData,
2738 void* /*theCallData*/)
2740 SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
2742 self->emitTransformed();
2746 Get camera properties for the SVTK view window.
2747 \return shared pointer on camera properties.
2749 SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
2751 SUIT_CameraProperties aProps;
2754 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2758 aProps.setDimension( SUIT_CameraProperties::Dim3D );
2759 if ( toolMgr()->action( ParallelModeId ) ) {
2760 if ( toolMgr()->action( ParallelModeId )->isChecked() )
2761 aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
2763 aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
2766 double aFocalPoint[3];
2767 double aPosition[3];
2769 double anAxialScale[3];
2771 aCamera->OrthogonalizeViewUp();
2772 aCamera->GetFocalPoint( aFocalPoint );
2773 aCamera->GetPosition( aPosition );
2774 aCamera->GetViewUp( aViewUp );
2776 aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2777 aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
2778 aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2779 aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
2781 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2783 aProps.setViewAngle( aCamera->GetViewAngle() );
2786 GetRenderer()->GetScale( anAxialScale );
2787 aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2794 This implementation synchronizes camera propreties.
2796 void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2798 bool blocked = blockSignals( true );
2800 SUIT_CameraProperties aProps = theView->cameraProperties();
2801 if ( !cameraProperties().isCompatible( aProps ) ) {
2802 // other view, this one is being currently synchronized to, seems has become incompatible
2803 // we have to break synchronization
2809 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2811 double aFocalPoint[3];
2812 double aPosition[3];
2814 double anAxialScale[3];
2816 // get common properties
2817 aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2818 aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
2819 aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2820 aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2822 // restore properties to the camera
2823 aCamera->SetViewUp( aViewUp );
2824 aCamera->SetPosition( aPosition );
2825 aCamera->SetFocalPoint( aFocalPoint );
2826 aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
2828 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2830 aCamera->SetViewAngle( aProps.getViewAngle() );
2833 GetRenderer()->SetScale( anAxialScale );
2835 getRenderer()->ResetCameraClippingRange();
2838 blockSignals( blocked );
2841 void SVTK_ViewWindow::resizeEvent( QResizeEvent* theEvent )
2843 #ifdef VGL_WORKAROUND