1 // Copyright (C) 2007-2023 CEA, EDF, 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>
115 // Use workaround for rendering transparent object over MESA
116 #define USE_WORKAROUND_FOR_MESA
120 int convertAction( const int accelAction )
122 switch ( accelAction ) {
123 case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
124 case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
125 case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
126 case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
127 case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
128 case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
129 case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
130 case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
131 case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
132 case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
141 SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
142 SUIT_ViewWindow(theDesktop),
144 myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
145 myEventCallbackCommand(vtkCallbackCommand::New()),
146 myDumpImage(QImage())
148 setWindowFlags( windowFlags() & ~Qt::Window );
149 // specific of vtkSmartPointer
150 myKeyFreeInteractorStyle->Delete();
154 To initialize #SVTK_ViewWindow instance
156 void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
159 myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
161 SVTK_Selector* aSelector = SVTK_Selector::New();
162 int aPreselectionMode = SUIT_Session::session()->resourceMgr()->
163 integerValue( "VTKViewer", "preselection", Standard_Preselection );
164 aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection );
165 aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled );
166 bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
167 booleanValue( "VTKViewer", "enable_selection", true );
168 aSelector->SetSelectionEnabled( isSelectionEnabled );
170 SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
171 aDevice->SetRenderWidget(myInteractor);
172 aDevice->SetSelector(aSelector);
174 SVTK_Renderer* aRenderer = SVTK_Renderer::New();
175 aRenderer->Initialize(aDevice,aSelector);
177 myInteractor->Initialize(aDevice,aRenderer,aSelector);
183 myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant)
184 QString( "VTKViewerViewOperations" ), // name (language-independant)
185 false ); // disable floatable toolbar
187 myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant)
188 QString( "VTKRecordingOperations" ), // name (language-independant)
189 false ); // disable floatable toolbar
191 createActions( SUIT_Session::session()->resourceMgr() );
194 SetEventDispatcher(myInteractor->GetDevice());
195 myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
196 myInteractor->setFocusPolicy(Qt::StrongFocus);
197 myInteractor->setFocus();
198 bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()->
199 booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
200 myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
201 setFocusProxy(myInteractor);
203 myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
204 myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
205 myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
206 myCubeAxesDlg->initialize();
207 mySetRotationPointDlg = new SVTK_SetRotationPointDlg
208 ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
209 myViewParameterDlg = new SVTK_ViewParameterDlg
210 ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
212 myDefaultInteractorStyle = SVTK_InteractorStyle::New();
213 myInteractor->PushInteractorStyle(myDefaultInteractorStyle);
214 myDefaultInteractorStyle->Delete();
216 myRecorder = SVTK_Recorder::New();
218 myRecorder->SetNbFPS( 17.3 );
219 myRecorder->SetQuality( 100 );
220 myRecorder->SetProgressiveMode( true );
221 myRecorder->SetUseSkippedFrames( true );
222 myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
224 setCentralWidget(myInteractor);
226 myAxesWidget = salomevtk::vtkPVAxesWidget::New();
227 myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
228 myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
229 myAxesWidget->SetInteractor(myInteractor->GetDevice());
230 myAxesWidget->SetEnabled(1);
231 myAxesWidget->SetInteractive(0);
233 salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
234 anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 );
235 anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
236 anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
237 anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 );
238 anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
239 anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
240 anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 );
241 anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
242 anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
244 myView = new SVTK_View(this);
245 Initialize(myView,theModel);
248 myEventCallbackCommand->SetClientData(this);
249 myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
250 myEventCallbackCommand->Delete();
252 GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
253 myEventCallbackCommand.GetPointer(), 0.0);
254 myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
255 myEventCallbackCommand.GetPointer(), 0.0);
257 #ifdef USE_WORKAROUND_FOR_MESA
258 char *mesavar = getenv("SALOME_USE_MESA");
260 getRenderer()->SetUseDepthPeeling(1);
261 #endif //USE_WORKAROUND_FOR_MESA
263 getRenderer()->SetBackgroundAlpha(1.0);
264 myInteractor->getRenderWindow()->SetMultiSamples(0);
265 myInteractor->getRenderWindow()->Render();
266 setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
271 To initialize #SVTK_ViewWindow instance
273 void SVTK_ViewWindow::Initialize(SVTK_View* theView,
274 SVTK_ViewModelBase* theModel)
276 connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
277 this,SLOT(onKeyPressed(QKeyEvent*)) );
278 connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
279 this,SLOT(onKeyReleased(QKeyEvent*)));
280 connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
281 this,SLOT(onMousePressed(QMouseEvent*)));
282 connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
283 this,SLOT(onMouseReleased(QMouseEvent*)));
284 connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
285 this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
286 connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
287 this,SLOT(onMouseMoving(QMouseEvent*)));
288 connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
289 this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
290 connect(theView,SIGNAL(selectionChanged()),
291 theModel,SLOT(onSelectionChanged()));
293 connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
299 SVTK_ViewWindow::~SVTK_ViewWindow()
301 myRecorder->Delete();
302 myAxesWidget->Delete();
307 \return corresponding view
309 SVTK_View* SVTK_ViewWindow::getView()
315 \return corresponding vtk render window
317 vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
319 return GetInteractor()->getRenderWindow();
323 \return corresponding vtk render window interactor
325 SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
331 \return corresponding vtk render window interactor
333 vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
335 return myInteractor->GetDevice();
339 \return corresponding vtk renderer
341 vtkRenderer* SVTK_ViewWindow::getRenderer() const
343 return GetInteractor()->getRenderer();
347 Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
349 SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
351 return GetInteractor()->GetRenderer();
355 \return corresponding vtk selector
357 SVTK_Selector* SVTK_ViewWindow::GetSelector() const
359 return GetInteractor()->GetSelector();
363 Processes transformation "front view"
365 void SVTK_ViewWindow::onFrontView()
367 GetRenderer()->OnFrontView();
369 emit transformed( this );
373 Processes transformation "back view"
375 void SVTK_ViewWindow::onBackView()
377 GetRenderer()->OnBackView();
379 emit transformed( this );
383 Processes transformation "top view"
385 void SVTK_ViewWindow::onTopView()
387 GetRenderer()->OnTopView();
389 emit transformed( this );
393 Processes transformation "bottom view"
395 void SVTK_ViewWindow::onBottomView()
397 GetRenderer()->OnBottomView();
399 emit transformed( this );
403 Processes transformation "left view"
405 void SVTK_ViewWindow::onLeftView()
407 GetRenderer()->OnLeftView();
409 emit transformed( this );
413 Processes transformation "right view"
415 void SVTK_ViewWindow::onRightView()
417 GetRenderer()->OnRightView();
419 emit transformed( this );
423 \brief Rotate view 90 degrees clockwise
425 void SVTK_ViewWindow::onClockWiseView()
427 GetRenderer()->onClockWiseView();
429 emit transformed( this );
433 \brief Rotate view 90 degrees conterclockwise
435 void SVTK_ViewWindow::onAntiClockWiseView()
437 GetRenderer()->onAntiClockWiseView();
439 emit transformed( this );
443 Processes transformation "reset view": sets default orientation of viewport camera
445 void SVTK_ViewWindow::onResetView()
447 GetRenderer()->OnResetView();
449 emit transformed( this );
453 Processes transformation "fit all"
455 void SVTK_ViewWindow::onFitAll()
457 GetRenderer()->OnFitAll();
459 emit transformed( this );
463 Processes transformation "fit selection"
465 void SVTK_ViewWindow::onFitSelection()
467 GetRenderer()->onFitSelection();
469 emit transformed( this );
473 Processes transformation "fit given objects"
475 void SVTK_ViewWindow::onFitIObjects(const SALOME_ListIO& objects)
477 GetRenderer()->OnFitIObjects(objects);
479 emit transformed( this );
483 SLOT: called if selection is changed
485 void SVTK_ViewWindow::onSelectionChanged()
487 myView->onSelectionChanged();
491 Change selection mode
492 \param theMode - new selection mode
494 void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
496 GetSelector()->SetSelectionMode(theMode);
500 \return selection mode
502 Selection_Mode SVTK_ViewWindow::SelectionMode() const
504 return GetSelector()->SelectionMode();
508 Unhilights all objects in viewer
510 void SVTK_ViewWindow::unHighlightAll()
512 myView->unHighlightAll();
516 Hilights/unhilights object in viewer
517 \param theIO - object to be updated
518 \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
519 \param theIsUpdate - update current viewer
521 void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO,
525 myView->highlight( theIO, theIsHighlight, theIsUpdate );
529 \return true if object is in viewer or in collector
530 \param theIO - object to be checked
532 bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
534 return myView->isInViewer( theIO );
538 \return true if object is displayed in viewer
539 \param theIO - object to be checked
541 bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
543 return myView->isVisible( theIO );
548 \param theEntry - entry that corresponds to intractive objects
550 Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry)
552 return myView->FindIObject(theEntry);
557 \param theIO - object
558 \param theImmediatly - update viewer
560 void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
563 myView->Display(theIO,theImmediatly);
568 \param theIO - object
569 \param theImmediatly - update viewer
571 void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
574 myView->Erase(theIO,theImmediatly);
578 Display only passed object
579 \param theIO - object
581 void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
583 myView->DisplayOnly(theIO);
587 Display all objects in view
589 void SVTK_ViewWindow::DisplayAll()
591 myView->DisplayAll();
595 Erase all objects in view
597 void SVTK_ViewWindow::EraseAll()
603 Sets background color [obsolete]
604 \param color - new background color
606 void SVTK_ViewWindow::setBackgroundColor( const QColor& c )
608 Qtx::BackgroundData bg = background();
614 \return background color of viewer [obsolete]
616 QColor SVTK_ViewWindow::backgroundColor() const
618 return background().color();
623 \param bgData - new background data
625 void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
629 if ( bgData.isValid() ) {
630 switch ( bgData.mode() ) {
631 case Qtx::ColorBackground:
633 QColor c = bgData.color();
635 // show solid-colored background
636 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
637 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
638 getRenderer()->SetBackground( c.red()/255.0,
640 c.blue()/255.0 ); // set background color
645 case Qtx::SimpleGradientBackground:
648 int type = bgData.gradient( c1, c2 );
654 // show two-color gradient background
655 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
656 getRenderer()->SetGradientBackground( true ); // switch to gradient mode
658 VTKViewer_OpenGLRenderer* aRenderer =
659 VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
662 aRenderer->SetGradientType( type );
663 aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
664 aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
670 case Qtx::CustomGradientBackground:
672 // NOT IMPLEMENTED YET
673 getRenderer()->SetTexturedBackground( false ); // cancel texture mode
674 getRenderer()->SetGradientBackground( false ); // cancel gradient mode
681 if ( bgData.isTextureShown() ) {
683 int textureMode = bgData.texture( fileName );
684 QFileInfo fi( fileName );
685 if ( !fileName.isEmpty() && fi.exists() ) {
686 // read texture from file
687 QString extension = fi.suffix().toLower();
688 vtkImageReader2* aReader = 0;
689 if ( extension == "jpg" || extension == "jpeg" )
690 aReader = vtkJPEGReader::New();
691 else if ( extension == "bmp" )
692 aReader = vtkBMPReader::New();
693 else if ( extension == "tif" || extension == "tiff" )
694 aReader = vtkTIFFReader::New();
695 else if ( extension == "png" )
696 aReader = vtkPNGReader::New();
697 else if ( extension == "mhd" || extension == "mha" )
698 aReader = vtkMetaImageReader::New();
701 aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
703 VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
704 vtkImageMapToColors* aMap = 0;
705 vtkAlgorithmOutput* anOutput;
707 // special processing for BMP reader
708 vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
710 // Special processing for BMP file
711 aBMPReader->SetAllow8BitBMP(1);
713 aMap = vtkImageMapToColors::New();
714 aMap->SetInputConnection( aBMPReader->GetOutputPort() );
715 aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
716 aMap->SetOutputFormatToRGB();
718 anOutput = aMap->GetOutputPort();
723 anOutput = aReader->GetOutputPort( 0 );
724 aTexture->SetInputConnection( anOutput );
726 // VSR: Currently, VTK only supports Stretch mode, so below code will give
727 // the same results for all modes
728 switch ( textureMode ) {
729 case Qtx::TileTexture:
730 aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
732 case Qtx::StretchTexture:
733 aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
735 case Qtx::CenterTexture:
736 aTexture->SetPosition((int)VTKViewer_Texture::Centered);
740 // show textured background
741 getRenderer()->SetTexturedBackground( true );
742 getRenderer()->SetBackgroundTexture( aTexture );
744 // clean-up resources
755 myBackground = bgData;
759 \return background data of viewer
761 Qtx::BackgroundData SVTK_ViewWindow::background() const
768 Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
770 vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
772 return GetInteractor()->GetInteractorStyle();
776 Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
778 void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
780 GetInteractor()->PushInteractorStyle(theStyle);
784 Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
786 void SVTK_ViewWindow::PopInteractorStyle()
788 GetInteractor()->PopInteractorStyle();
792 Updates current viewer
794 void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
796 if(theUpdateTrihedron)
797 GetRenderer()->OnAdjustTrihedron();
799 GetInteractor()->update();
801 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
803 #ifdef VGL_WORKAROUND
804 if ( aStyle->GetCurrentRenderer() == nullptr ) {
805 if( GetRenderer() ) {
806 aStyle->SetCurrentRenderer(GetRenderer()->GetDevice());
815 Redirect the request to #SVTK_Renderer::GetScale
817 void SVTK_ViewWindow::GetScale( double theScale[3] )
819 GetRenderer()->GetScale( theScale );
823 Redirect the request to #SVTK_Renderer::SetScale
825 void SVTK_ViewWindow::SetScale( double theScale[3] )
827 GetRenderer()->SetScale( theScale );
829 emit transformed( this );
833 Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
835 bool SVTK_ViewWindow::isTrihedronDisplayed()
837 return GetRenderer()->IsTrihedronDisplayed();
841 Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
843 bool SVTK_ViewWindow::isCubeAxesDisplayed()
845 return GetRenderer()->IsCubeAxesDisplayed();
849 Redirect the request to #SVTK_Renderer::OnViewTrihedron
851 void SVTK_ViewWindow::onViewTrihedron(bool show)
853 GetRenderer()->SetTrihedronVisibility(show);
858 Redirect the request to #SVTK_Renderer::OnViewCubeAxes
860 void SVTK_ViewWindow::onViewCubeAxes()
862 GetRenderer()->OnViewCubeAxes();
867 Redirect the request to #SVTK_Renderer::GetTrihedron
869 VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
871 return GetRenderer()->GetTrihedron();
875 Redirect the request to #SVTK_Renderer::GetCubeAxes
877 SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
879 return GetRenderer()->GetCubeAxes();
883 \return trihedron size
885 double SVTK_ViewWindow::GetTrihedronSize() const
887 return GetRenderer()->GetTrihedronSize();
892 \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo )
894 void SVTK_ViewWindow::SetProjectionMode(const int theMode)
896 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
897 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
898 QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
902 onProjectionMode( aParallelAction );
905 onProjectionMode( aProjectionAction );
908 onStereoMode( true );
912 // update action state if method is called outside
913 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
914 QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
915 if ( theMode == Parallel && !aParallelAction->isChecked() ) {
916 aParallelAction->setChecked( true );
917 aSwitchZoomingStyle->setEnabled(true);
918 aStereoAction->setChecked( false );
920 if ( theMode == Projection && !aProjectionAction->isChecked() ) {
921 aProjectionAction->setChecked( true );
922 aSwitchZoomingStyle->setEnabled(false);
924 if ( theMode == Stereo ) {
925 aStereoAction->setChecked( true );
926 if ( aParallelAction->isEnabled() ) {
927 aParallelAction->setEnabled( false );
928 aParallelAction->setChecked( false );
929 aStereoAction->setChecked( false );
932 aParallelAction->setEnabled( true );
933 aStereoAction->setChecked( false );
934 aParallelAction->setChecked( aViewer->projectionMode() == Parallel );
936 if ( aProjectionAction->isEnabled() ) {
937 aProjectionAction->setEnabled( false );
938 aProjectionAction->setChecked( true );
939 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
940 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
941 toolMgr()->action( StereoModeId )->isChecked() ) {
942 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
946 aProjectionAction->setEnabled( true );
947 aStereoAction->setChecked( false );
948 aProjectionAction->setChecked( aViewer->projectionMode() == Projection );
953 if ( !aParallelAction->isEnabled() )
954 aParallelAction->setEnabled( true );
955 if ( !aProjectionAction->isEnabled() )
956 aProjectionAction->setEnabled( true );
962 \param theType - stereo type
964 void SVTK_ViewWindow::SetStereoType(const int theType)
966 vtkRenderWindow* aWindow = getRenderWindow();
969 aWindow->SetStereoTypeToCrystalEyes();
972 aWindow->SetStereoTypeToRedBlue();
975 aWindow->SetStereoTypeToInterlaced();
978 aWindow->SetStereoTypeToLeft();
981 aWindow->SetStereoTypeToRight();
984 aWindow->SetStereoTypeToDresden();
987 aWindow->SetStereoTypeToAnaglyph();
990 aWindow->SetStereoTypeToCheckerboard();
992 case SplitViewPortHorizontal:
993 aWindow->SetStereoTypeToSplitViewportHorizontal();
1000 \param theFilter - anaglyph filter
1002 void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter)
1004 vtkRenderWindow* aWindow = getRenderWindow();
1005 switch (theFilter ) {
1007 aWindow->SetAnaglyphColorMask(4,3);
1010 aWindow->SetAnaglyphColorMask(6,1);
1013 aWindow->SetAnaglyphColorMask(2,5);
1019 Set support quad-buffered stereo
1020 \param theEnable - enable/disable support quad-buffered stereo
1022 void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable)
1024 vtkRenderWindow* aWindow = getRenderWindow();
1025 aWindow->SetStereoCapableWindow((int)theEnable);
1029 \return OpenGl stereo support
1031 bool SVTK_ViewWindow::isOpenGlStereoSupport() const
1033 GLboolean support[1];
1034 glGetBooleanv (GL_STEREO, support);
1041 Set the gravity center as a focal point
1043 void SVTK_ViewWindow::activateSetFocalPointGravity()
1045 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
1049 Activate interactive selection
1051 void SVTK_ViewWindow::activateInteractiveSelection()
1053 myEventDispatcher->InvokeEvent(SVTK::StartInteractiveSelection, 0);
1057 Deactivate current active operation
1059 void SVTK_ViewWindow::deactivateCurrectOperation() {
1060 myEventDispatcher->InvokeEvent(SVTK::StopCurrentOperation, 0);
1064 Set the selected point as a focal point
1066 void SVTK_ViewWindow::activateSetFocalPointSelected()
1068 myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
1072 Set the point selected by user as a focal point
1074 void SVTK_ViewWindow::activateStartFocalPointSelection()
1076 myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
1079 void SVTK_ViewWindow::activateProjectionMode(int theMode)
1081 QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
1082 QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
1084 aParallelAction->setChecked( true );
1086 aProjectionAction->setChecked( true );
1088 if ( !aParallelAction->isEnabled() )
1089 aParallelAction->setEnabled( true );
1090 if ( !aProjectionAction->isEnabled() )
1091 aProjectionAction->setEnabled( true );
1095 Sets actual interaction style
1096 \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
1098 void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
1100 onSwitchInteractionStyle( theStyle==1 );
1104 Sets actual zooming style
1105 \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) )
1107 void SVTK_ViewWindow::SetZoomingStyle(const int theStyle)
1109 onSwitchZoomingStyle( theStyle==1 );
1113 Set preselection mode.
1114 \param theMode the mode to set (standard, dynamic or disabled)
1116 void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode )
1118 onSwitchPreSelectionMode( theMode );
1122 Enables/disables selection.
1123 \param theEnable if true - selection will be enabled
1125 void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable )
1127 GetSelector()->SetSelectionEnabled( theEnable );
1128 QtxAction* a = getAction( EnableSelectionId );
1129 if ( a->isChecked() != theEnable)
1130 a->setChecked( theEnable );
1131 QtxActionGroup* aPreselectionGroup =
1132 dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
1133 if ( aPreselectionGroup )
1134 aPreselectionGroup->setEnabled( theEnable );
1137 vtkActorCollection *actors = getRenderer()->GetActors();
1138 for (int i = 0; i < actors->GetNumberOfItems(); ++i )
1139 if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
1141 actor->EnableSelection( theEnable );
1146 Switches "keyboard free" interaction style on/off
1148 void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
1151 // check if style is already set
1152 if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
1154 // keep the same style extensions
1155 SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
1157 myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
1158 myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
1161 PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
1165 // pop only key free style
1166 if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
1167 PopInteractorStyle();
1170 // update action state if method is called outside
1171 QtxAction* a = getAction( SwitchInteractionStyleId );
1172 if ( a->isChecked() != theOn ) a->setChecked( theOn );
1176 Toogles advanced zooming style (relatively to the cursor position) on/off
1178 void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn )
1180 if( myDefaultInteractorStyle.GetPointer() )
1181 myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1182 if( myKeyFreeInteractorStyle.GetPointer() )
1183 myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn );
1185 // update action state if method is called outside
1186 QtxAction* a = getAction( SwitchZoomingStyleId );
1187 if ( a->isChecked() != theOn )
1188 a->setChecked( theOn );
1192 Switch preselection mode.
1193 \param theMode the preselection mode
1195 void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode )
1197 GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection );
1198 GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled );
1200 // update action state if method is called outside
1201 QtxAction* a = getAction( StandardPreselectionId + theMode );
1202 if ( a && !a->isChecked() )
1203 a->setChecked( true );
1207 Enables/disables selection.
1208 \param theOn if true - selection will be enabled
1210 void SVTK_ViewWindow::onEnableSelection( bool on )
1212 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
1214 aViewer->enableSelection(on);
1218 Sets incremental speed
1219 \param theValue - new incremental speed
1220 \param theMode - modification mode
1222 void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
1224 if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
1225 ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
1229 Sets spacemouse buttons for the functions
1230 \param theBtn1 - spacemouse button for the "decrease speed increment"
1231 \param theBtn2 - spacemouse button for the "increase speed increment"
1232 \param theBtn3 - spacemouse button for the "dominant combined switch"
1234 void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1,
1239 myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
1241 myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
1243 myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
1248 \param theSize - new trihedron size
1249 \param theRelative - trihedron relativeness
1251 void SVTK_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative)
1253 GetRenderer()->SetTrihedronSize(theSize, theRelative);
1257 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
1258 * trihedron and cube axes, even if trihedron and cube axes is invisible.
1260 void SVTK_ViewWindow::AdjustTrihedrons(const bool /*theIsForcedUpdate*/)
1262 GetRenderer()->AdjustActors();
1267 Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
1269 void SVTK_ViewWindow::onAdjustTrihedron()
1271 GetRenderer()->OnAdjustTrihedron();
1275 Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
1277 void SVTK_ViewWindow::onAdjustCubeAxes()
1279 GetRenderer()->OnAdjustCubeAxes();
1282 void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
1284 if ( otherViewWindow ) {
1285 bool blocked = blockSignals( true );
1286 doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
1287 blockSignals( blocked );
1294 void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
1296 emit keyPressed( this, event );
1302 void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
1304 emit keyReleased( this, event );
1310 void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
1312 emit mousePressed(this, event);
1316 Emits mouse released
1318 void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
1320 emit mouseReleased( this, event );
1326 void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
1328 emit mouseMoving( this, event );
1332 Emits mouse double clicked
1334 void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
1336 emit mouseDoubleClicked( this, event );
1340 Redirect the request to #SVTK_Renderer::AddActor
1342 void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor,
1344 bool theIsAdjustActors )
1346 GetRenderer()->AddActor(theActor, theIsAdjustActors);
1349 emit actorAdded(theActor);
1353 Redirect the request to #SVTK_Renderer::RemoveActor
1355 void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor,
1357 bool theIsAdjustActors )
1359 GetRenderer()->RemoveActor(theActor, theIsAdjustActors);
1360 if ( myDefaultInteractorStyle )
1361 myDefaultInteractorStyle->FreeActors();
1362 if ( myKeyFreeInteractorStyle )
1363 myKeyFreeInteractorStyle->FreeActors();
1366 emit actorRemoved(theActor);
1369 QImage SVTK_ViewWindow::dumpViewContent()
1371 vtkRenderWindow* aWindow = getRenderWindow();
1372 int* aSize = aWindow->GetSize();
1373 int aWidth = aSize[0];
1374 int aHeight = aSize[1];
1376 #ifndef DISABLE_GLVIEWER
1377 OpenGLUtils_FrameBuffer aFrameBuffer;
1378 if( aFrameBuffer.init( aWidth, aHeight ) )
1380 glPushAttrib( GL_VIEWPORT_BIT );
1381 glViewport( 0, 0, aWidth, aHeight );
1382 aFrameBuffer.bind();
1387 //aFrameBuffer.unbind();
1390 QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1391 //aFrameBuffer.bind();
1393 glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1394 aFrameBuffer.unbind();
1396 anImage = anImage.rgbSwapped();
1397 anImage = anImage.mirrored();
1402 // if frame buffers are unsupported, use old functionality
1403 unsigned char *aData =
1404 aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 );
1406 QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 );
1408 anImage = anImage.rgbSwapped();
1409 anImage = anImage.mirrored();
1414 \return QImage, containing all scene rendering in window
1416 QImage SVTK_ViewWindow::dumpView()
1418 if( myDumpImage.isNull() )
1419 return dumpViewContent();
1425 QString SVTK_ViewWindow::filter() const
1427 return tr( "SVTK_IMAGE_FILES" );
1430 bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
1432 if ( format != "PS" && format != "EPS" && format != "PDF" )
1433 return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1435 SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
1436 if ( optionsDlg->exec() == QDialog::Accepted ) {
1437 SUIT_OverrideCursor wc;
1439 vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
1440 anExporter->SetRenderWindow(getRenderWindow());
1443 anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
1444 anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
1445 anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
1446 anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
1447 anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
1449 if ( format == "PS" ) {
1450 anExporter->SetFileFormatToPS();
1451 anExporter->CompressOff();
1454 if ( format == "EPS" ) {
1455 anExporter->SetFileFormatToEPS();
1456 anExporter->CompressOff();
1459 if ( format == "PDF" ) {
1460 anExporter->SetFileFormatToPDF();
1463 QString aFilePrefix(fileName);
1464 QString anExtension(SUIT_Tools::extension(fileName));
1465 aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
1466 anExporter->SetFilePrefix(aFilePrefix.toUtf8().data());
1467 anExporter->Write();
1468 anExporter->Delete();
1475 \refresh QImage, containing all scene rendering in window
1477 void SVTK_ViewWindow::RefreshDumpImage()
1479 myDumpImage = dumpViewContent();
1483 Redirect the request to #SVTK_Renderer::SetSelectionProp
1485 void SVTK_ViewWindow::SetSelectionProp(const double& theRed,
1486 const double& theGreen,
1487 const double& theBlue,
1488 const int& theWidth)
1490 myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
1494 Redirect the request to #SVTK_Renderer::SetSelectionProp
1496 void SVTK_ViewWindow::SetPreselectionProp(const double& theRed,
1497 const double& theGreen,
1498 const double& theBlue,
1499 const int& theWidth)
1501 myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
1505 Redirect the request to #SVTK_Renderer::SetSelectionTolerance
1507 void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes,
1508 const double& theTolItems,
1509 const double& theTolObjects)
1511 myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
1515 Get visibility status of the static trihedron
1517 bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
1519 return (bool)myAxesWidget->GetEnabled();
1523 Set visibility status of the static trihedron
1525 void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
1527 myAxesWidget->SetEnabled( (int)theIsVisible );
1532 \param accelAction - action
1534 bool SVTK_ViewWindow::action( const int accelAction )
1536 if ( accelAction == SUIT_Accel::ZoomFit )
1539 int anEvent = SVTK::convertAction( accelAction );
1540 GetInteractor()->InvokeEvent(anEvent, 0);
1546 \return action by it's id
1548 QtxAction* SVTK_ViewWindow::getAction( int id ) const
1550 return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
1554 // old visual parameters had 13 values. New format added additional
1555 // 76 values for graduated axes, so both numbers are processed.
1556 const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
1557 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
1558 const int nTrihedronParams = 3; // number of parameters for Trihedron
1559 const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters
1561 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
1563 void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
1570 bool isVisible = actor->GetTitleVisibility();
1571 QString title ( actor->GetTitle() );
1573 int font = VTK_ARIAL;
1578 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1581 txtProp->GetColor( color );
1582 font = txtProp->GetFontFamily();
1583 bold = txtProp->GetBold();
1584 italic = txtProp->GetItalic();
1585 shadow = txtProp->GetShadow();
1587 writer.writeStartElement("GraduatedAxis");
1588 writer.writeAttribute("Axis", theAxis);
1590 writer.writeStartElement("Title");
1591 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1592 writer.writeAttribute("Text", title);
1593 writer.writeAttribute("Font", QString("%1").arg(font));
1594 writer.writeAttribute("Bold", QString("%1").arg(bold));
1595 writer.writeAttribute("Italic", QString("%1").arg(italic));
1596 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1598 writer.writeStartElement("Color");
1599 writer.writeAttribute("R", QString("%1").arg(color[0]));
1600 writer.writeAttribute("G", QString("%1").arg(color[1]));
1601 writer.writeAttribute("B", QString("%1").arg(color[2]));
1602 writer.writeEndElement();
1603 writer.writeEndElement();
1605 //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
1606 // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
1609 isVisible = actor->GetLabelVisibility();
1610 int labels = actor->GetNumberOfLabels();
1611 int offset = actor->GetTickOffset();
1617 txtProp = actor->GetLabelTextProperty();
1620 txtProp->GetColor( color );
1621 font = txtProp->GetFontFamily();
1622 bold = txtProp->GetBold();
1623 italic = txtProp->GetItalic();
1624 shadow = txtProp->GetShadow();
1627 writer.writeStartElement("Labels");
1628 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1629 writer.writeAttribute("Number", QString("%1").arg(labels));
1630 writer.writeAttribute("Offset", QString("%1").arg(offset));
1631 writer.writeAttribute("Font", QString("%1").arg(font));
1632 writer.writeAttribute("Bold", QString("%1").arg(bold));
1633 writer.writeAttribute("Italic", QString("%1").arg(italic));
1634 writer.writeAttribute("Shadow", QString("%1").arg(shadow));
1636 writer.writeStartElement("Color");
1637 writer.writeAttribute("R", QString("%1").arg(color[0]));
1638 writer.writeAttribute("G", QString("%1").arg(color[1]));
1639 writer.writeAttribute("B", QString("%1").arg(color[2]));
1640 writer.writeEndElement();
1641 writer.writeEndElement();
1642 // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
1643 // color[0], color[1], color[2], font, bold, italic, shadow );
1646 isVisible = actor->GetTickVisibility();
1647 int length = actor->GetTickLength();
1648 writer.writeStartElement("TickMarks");
1649 writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
1650 writer.writeAttribute("Length", QString("%1").arg(length));
1651 writer.writeEndElement();
1653 //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
1655 writer.writeEndElement();
1659 void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
1666 } while (!reader.isStartElement());
1668 // Read title params
1669 QXmlStreamAttributes aAttr = reader.attributes();
1670 bool isVisible = aAttr.value("isVisible").toString().toUShort();
1671 QString title = aAttr.value("Text").toString();
1672 int font = aAttr.value("Font").toString().toInt();
1673 int bold = aAttr.value("Bold").toString().toInt();
1674 int italic = aAttr.value("Italic").toString().toInt();
1675 int shadow = aAttr.value("Shadow").toString().toInt();
1677 //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
1681 } while (!reader.isStartElement());
1684 aAttr = reader.attributes();
1687 color[0] = aAttr.value("R").toString().toDouble();
1688 color[1] = aAttr.value("G").toString().toDouble();
1689 color[2] = aAttr.value("B").toString().toDouble();
1690 //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
1692 actor->SetTitleVisibility( isVisible );
1693 actor->SetTitle( title.toUtf8() );
1694 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1696 txtProp->SetColor( color );
1697 txtProp->SetFontFamily( font );
1698 txtProp->SetBold( bold );
1699 txtProp->SetItalic( italic );
1700 txtProp->SetShadow( shadow );
1707 } while (!reader.isStartElement());
1709 aAttr = reader.attributes();
1710 isVisible = aAttr.value("isVisible").toString().toUShort();
1711 int labels = aAttr.value("Number").toString().toInt();
1712 int offset = aAttr.value("Offset").toString().toInt();
1713 font = aAttr.value("Font").toString().toInt();
1714 bold = aAttr.value("Bold").toString().toInt();
1715 italic = aAttr.value("Italic").toString().toInt();
1716 shadow = aAttr.value("Shadow").toString().toInt();
1720 } while (!reader.isStartElement());
1722 aAttr = reader.attributes();
1724 color[0] = aAttr.value("R").toString().toDouble();
1725 color[1] = aAttr.value("G").toString().toDouble();
1726 color[2] = aAttr.value("B").toString().toDouble();
1728 actor->SetLabelVisibility( isVisible );
1729 actor->SetNumberOfLabels( labels );
1730 actor->SetTickOffset( offset );
1731 txtProp = actor->GetLabelTextProperty();
1733 txtProp->SetColor( color );
1734 txtProp->SetFontFamily( font );
1735 txtProp->SetBold( bold );
1736 txtProp->SetItalic( italic );
1737 txtProp->SetShadow( shadow );
1743 } while (!reader.isStartElement());
1744 aAttr = reader.attributes();
1746 // retrieve and set tick marks properties
1747 isVisible = aAttr.value("isVisible").toString().toUShort();
1748 int length = aAttr.value("Length").toString().toInt();
1750 actor->SetTickVisibility( isVisible );
1751 actor->SetTickLength( length );
1754 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
1756 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
1761 QStringList paramsLst = params.split( '*' );
1763 if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
1765 // retrieve and set name parameters
1766 bool isVisible = paramsLst[2].toUShort();
1767 QString title = paramsLst[3];
1769 color[0] = paramsLst[4].toDouble();
1770 color[1] = paramsLst[5].toDouble();
1771 color[2] = paramsLst[6].toDouble();
1772 int font = paramsLst[7].toInt();
1773 int bold = paramsLst[8].toInt();
1774 int italic = paramsLst[9].toInt();
1775 int shadow = paramsLst[10].toInt();
1777 actor->SetTitleVisibility( isVisible );
1778 actor->SetTitle( title.toUtf8() );
1779 vtkTextProperty* txtProp = actor->GetTitleTextProperty();
1781 txtProp->SetColor( color );
1782 txtProp->SetFontFamily( font );
1783 txtProp->SetBold( bold );
1784 txtProp->SetItalic( italic );
1785 txtProp->SetShadow( shadow );
1788 // retrieve and set lable parameters
1789 isVisible = paramsLst[12].toUShort();
1790 int labels = paramsLst[13].toInt();
1791 int offset = paramsLst[14].toInt();
1792 color[0] = paramsLst[15].toDouble();
1793 color[1] = paramsLst[16].toDouble();
1794 color[2] = paramsLst[17].toDouble();
1795 font = paramsLst[18].toInt();
1796 bold = paramsLst[19].toInt();
1797 italic = paramsLst[20].toInt();
1798 shadow = paramsLst[21].toInt();
1800 actor->SetLabelVisibility( isVisible );
1801 actor->SetNumberOfLabels( labels );
1802 actor->SetTickOffset( offset );
1803 txtProp = actor->GetLabelTextProperty();
1805 txtProp->SetColor( color );
1806 txtProp->SetFontFamily( font );
1807 txtProp->SetBold( bold );
1808 txtProp->SetItalic( italic );
1809 txtProp->SetShadow( shadow );
1812 // retrieve and set tick marks properties
1813 isVisible = paramsLst[23].toUShort();
1814 int length = paramsLst[24].toInt();
1816 actor->SetTickVisibility( isVisible );
1817 actor->SetTickLength( length );
1821 /*! The method returns the visual parameters of this view as a formated string
1823 QString SVTK_ViewWindow::getVisualParameters()
1825 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
1827 // save position, focal point, viewUp, scale
1828 vtkCamera* camera = getRenderer()->GetActiveCamera();
1829 camera->GetPosition( pos );
1830 camera->GetFocalPoint( focalPnt );
1831 camera->GetViewUp( viewUp );
1832 parScale = camera->GetParallelScale();
1835 // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
1836 // view up values (3 digits), parallel scale (1 digit), scale (3 digits,
1837 // Graduated axes parameters (X, Y, Z axes parameters)
1839 QXmlStreamWriter aWriter(&retStr);
1840 aWriter.setAutoFormatting(true);
1842 aWriter.writeStartDocument();
1843 aWriter.writeStartElement("ViewState");
1845 aWriter.writeStartElement("Position");
1846 aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
1847 aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
1848 aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
1849 aWriter.writeEndElement();
1851 aWriter.writeStartElement("FocalPoint");
1852 aWriter.writeAttribute("X", QString::number(focalPnt[0]));
1853 aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
1854 aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
1855 aWriter.writeEndElement();
1857 aWriter.writeStartElement("ViewUp");
1858 aWriter.writeAttribute("X", QString::number(viewUp[0]));
1859 aWriter.writeAttribute("Y", QString::number(viewUp[1]));
1860 aWriter.writeAttribute("Z", QString::number(viewUp[2]));
1861 aWriter.writeEndElement();
1863 aWriter.writeStartElement("ViewScale");
1864 aWriter.writeAttribute("Parallel", QString::number(parScale));
1865 aWriter.writeAttribute("X", QString::number(scale[0]));
1866 aWriter.writeAttribute("Y", QString::number(scale[1]));
1867 aWriter.writeAttribute("Z", QString::number(scale[2]));
1868 aWriter.writeEndElement();
1870 if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
1871 aWriter.writeStartElement("DisplayCubeAxis");
1872 aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
1873 aWriter.writeEndElement();
1875 getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
1876 getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
1877 getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
1880 aWriter.writeStartElement("Trihedron");
1881 aWriter.writeAttribute("isShown", QString( "%1" ).arg( isTrihedronDisplayed()));
1882 aWriter.writeAttribute("Size", QString::number(GetTrihedronSize()));
1883 aWriter.writeEndElement();
1885 aWriter.writeStartElement("Background");
1886 aWriter.writeAttribute("Value", QString( "%1" ).arg( Qtx::backgroundToString(background()) ));
1887 aWriter.writeEndElement();
1889 aWriter.writeEndElement();
1890 aWriter.writeEndDocument();
1896 The method restores visual parameters of this view or postpones it untill the view is shown
1898 void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
1900 //printf("#### %s\n", qPrintable(parameters));
1901 SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
1902 if ( anInteractor->isVisible() ) {
1903 doSetVisualParameters( parameters );
1906 myVisualParams = parameters;
1907 anInteractor->installEventFilter(this);
1912 The method restores visual parameters of this view from a formated string
1914 void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
1917 double pos[3], focalPnt[3], viewUp[3], parScale = 1.0, scale[3];
1919 QXmlStreamReader aReader(parameters);
1920 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
1922 while(!aReader.atEnd()) {
1924 if (aReader.isStartElement()) {
1925 QXmlStreamAttributes aAttr = aReader.attributes();
1926 //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
1927 if (aReader.name() == "Position") {
1928 pos[0] = aAttr.value("X").toString().toDouble();
1929 pos[1] = aAttr.value("Y").toString().toDouble();
1930 pos[2] = aAttr.value("Z").toString().toDouble();
1931 //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
1933 else if (aReader.name() == "FocalPoint") {
1934 focalPnt[0] = aAttr.value("X").toString().toDouble();
1935 focalPnt[1] = aAttr.value("Y").toString().toDouble();
1936 focalPnt[2] = aAttr.value("Z").toString().toDouble();
1937 //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
1939 else if (aReader.name() == "ViewUp") {
1940 viewUp[0] = aAttr.value("X").toString().toDouble();
1941 viewUp[1] = aAttr.value("Y").toString().toDouble();
1942 viewUp[2] = aAttr.value("Z").toString().toDouble();
1943 //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
1945 else if (aReader.name() == "ViewScale") {
1946 parScale = aAttr.value("Parallel").toString().toDouble();
1947 scale[0] = aAttr.value("X").toString().toDouble();
1948 scale[1] = aAttr.value("Y").toString().toDouble();
1949 scale[2] = aAttr.value("Z").toString().toDouble();
1950 //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
1952 else if (aReader.name() == "DisplayCubeAxis") {
1953 if ( !baseParamsOnly ) {
1954 if (aAttr.value("Show") == "0")
1955 gradAxesActor->VisibilityOff();
1957 gradAxesActor->VisibilityOn();
1960 else if (aReader.name() == "GraduatedAxis") {
1961 if ( !baseParamsOnly ) {
1962 if(aAttr.value("Axis") == "X")
1963 setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
1964 else if(aAttr.value("Axis") == "Y")
1965 setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
1966 else if(aAttr.value("Axis") == "Z")
1967 setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
1970 else if (aReader.name() == "Trihedron") {
1971 if ( !baseParamsOnly ) {
1972 if (aAttr.value("isShown") == "0")
1973 GetTrihedron()->VisibilityOff();
1975 GetTrihedron()->VisibilityOn();
1976 SetTrihedronSize(aAttr.value("Size").toString().toDouble());
1979 else if (aReader.name() == "Background") {
1980 if ( !baseParamsOnly ) {
1981 setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
1986 if (!aReader.hasError()) {
1987 vtkCamera* camera = getRenderer()->GetActiveCamera();
1988 camera->SetPosition( pos );
1989 camera->SetFocalPoint( focalPnt );
1990 camera->SetViewUp( viewUp );
1991 camera->SetParallelScale( parScale );
1992 GetRenderer()->SetScale( scale );
1993 //SetScale( scale );
1996 QStringList paramsLst = parameters.split( '*' );
1997 if ( paramsLst.size() >= nNormalParams ) {
1998 // 'reading' list of parameters
1999 pos[0] = paramsLst[0].toDouble();
2000 pos[1] = paramsLst[1].toDouble();
2001 pos[2] = paramsLst[2].toDouble();
2002 focalPnt[0] = paramsLst[3].toDouble();
2003 focalPnt[1] = paramsLst[4].toDouble();
2004 focalPnt[2] = paramsLst[5].toDouble();
2005 viewUp[0] = paramsLst[6].toDouble();
2006 viewUp[1] = paramsLst[7].toDouble();
2007 viewUp[2] = paramsLst[8].toDouble();
2008 parScale = paramsLst[9].toDouble();
2009 scale[0] = paramsLst[10].toDouble();
2010 scale[1] = paramsLst[11].toDouble();
2011 scale[2] = paramsLst[12].toDouble();
2013 // applying parameters
2014 vtkCamera* camera = getRenderer()->GetActiveCamera();
2015 camera->SetPosition( pos );
2016 camera->SetFocalPoint( focalPnt );
2017 camera->SetViewUp( viewUp );
2018 camera->SetParallelScale( parScale );
2019 GetRenderer()->SetScale( scale );
2020 //SetScale( scale );
2022 // apply graduated axes parameters
2023 if ( !baseParamsOnly ) {
2024 SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
2025 if ( gradAxesActor && paramsLst.size() == nAllParams ) {
2026 int i = nNormalParams+1, j = i + nGradAxisParams - 1;
2027 ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
2028 i = j + 1; j += nGradAxisParams;
2029 ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
2030 i = j + 1; j += nGradAxisParams;
2031 ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
2033 if ( paramsLst[13].toUShort() )
2034 gradAxesActor->VisibilityOn();
2036 gradAxesActor->VisibilityOff();
2038 else if ( paramsLst.size() == nAllParams ) {
2039 if ( paramsLst[90].toUShort() )
2040 GetTrihedron()->VisibilityOn();
2042 GetTrihedron()->VisibilityOff();
2044 SetTrihedronSize(paramsLst[91].toDouble());
2054 Delayed setVisualParameters
2056 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
2058 if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
2059 SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
2060 if ( anInteractor->isVisible() ) {
2061 doSetVisualParameters( myVisualParams );
2062 anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
2065 return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
2070 Change rotation point
2072 void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
2075 mySetRotationPointDlg->addObserver();
2076 if ( mySetRotationPointDlg->IsFirstShown() )
2077 activateSetRotationGravity();
2078 mySetRotationPointDlg->show();
2080 mySetRotationPointDlg->hide();
2084 Set the gravity center as a rotation point
2086 void SVTK_ViewWindow::activateSetRotationGravity()
2088 myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
2092 Set the selected point as a rotation point
2094 void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
2096 myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
2100 Set the gravity center of element selected by user as a rotation point
2102 void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode )
2104 SetSelectionMode( theSelectionMode );
2105 myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
2109 \brief Set the given projection mode.
2111 Set the given projection mode: Orthographic or Perspective.
2113 void SVTK_ViewWindow::onProjectionMode( QAction* theAction )
2115 int aMode = Parallel;
2116 if (theAction == toolMgr()->action( ProjectionModeId ))
2118 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2119 aViewer->setProjectionMode(aMode);
2120 bool anIsParallelMode = (aMode == Parallel);
2121 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2122 aCamera->SetParallelProjection(anIsParallelMode);
2123 GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
2124 getRenderWindow()->SetStereoRender(0);
2129 \brief Sets Stereo projection mode.
2131 Sets Stereo projection mode.
2133 void SVTK_ViewWindow::onStereoMode( bool activate )
2136 toolMgr()->action( ProjectionModeId )->setChecked(true);
2137 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2138 aCamera->SetParallelProjection(false);
2139 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false);
2140 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2141 SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
2142 getRenderWindow()->SetStereoRender(1);
2146 toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true);
2147 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
2148 if (aViewer->projectionMode() == Parallel) {
2149 toolMgr()->action( ParallelModeId )->setChecked(true);
2150 onProjectionMode(toolMgr()->action( ParallelModeId ));
2152 else if (aViewer->projectionMode() == Projection) {
2153 toolMgr()->action( ProjectionModeId )->setChecked(true);
2154 onProjectionMode(toolMgr()->action( ProjectionModeId ));
2157 if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
2158 strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
2159 toolMgr()->action( StereoModeId )->isChecked() )
2160 SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
2164 Set the view projection mode: orthogonal or perspective
2166 void SVTK_ViewWindow::onProjectionMode()
2168 if (toolMgr()->action( ParallelModeId )->isChecked())
2169 SetProjectionMode( Parallel);
2170 if (toolMgr()->action( ProjectionModeId )->isChecked())
2171 SetProjectionMode( Projection);
2172 if (toolMgr()->action( StereoModeId )->isChecked())
2173 SetProjectionMode( Stereo);
2174 emit transformed( this );
2177 void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
2179 myEventDispatcher = theDispatcher;
2183 Creates all actions of svtk main window
2185 void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
2187 QtxAction* anAction;
2188 QtxActionToolMgr* mgr = toolMgr();
2191 anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
2192 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
2193 tr( "MNU_DUMP_VIEW" ), 0, this);
2194 anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
2195 connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
2196 mgr->registerAction( anAction, DumpId );
2199 anAction = new QtxAction(tr("MNU_FITALL"),
2200 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
2201 tr( "MNU_FITALL" ), 0, this);
2202 anAction->setStatusTip(tr("DSC_FITALL"));
2203 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
2204 mgr->registerAction( anAction, FitAllId );
2207 anAction = new QtxAction(tr("MNU_FITRECT"),
2208 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
2209 tr( "MNU_FITRECT" ), 0, this);
2210 anAction->setStatusTip(tr("DSC_FITRECT"));
2211 connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
2212 mgr->registerAction( anAction, FitRectId );
2215 anAction = new QtxAction(tr("MNU_FITSELECTION"),
2216 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
2217 tr( "MNU_FITSELECTION" ), 0, this);
2218 anAction->setStatusTip(tr("DSC_FITSELECTION"));
2219 connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
2220 mgr->registerAction( anAction, FitSelectionId );
2223 anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
2224 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
2225 tr( "MNU_ZOOM_VIEW" ), 0, this);
2226 anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
2227 connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
2228 mgr->registerAction( anAction, ZoomId );
2231 anAction = new QtxAction(tr("MNU_PAN_VIEW"),
2232 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
2233 tr( "MNU_PAN_VIEW" ), 0, this);
2234 anAction->setStatusTip(tr("DSC_PAN_VIEW"));
2235 connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
2236 mgr->registerAction( anAction, PanId );
2239 anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
2240 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
2241 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
2242 anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
2243 connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
2244 mgr->registerAction( anAction, GlobalPanId );
2246 // Change rotation point
2247 anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
2248 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
2249 tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
2250 anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
2251 anAction->setCheckable(true);
2252 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
2253 mgr->registerAction( anAction, ChangeRotationPointId );
2256 anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
2257 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
2258 tr( "MNU_ROTATE_VIEW" ), 0, this);
2259 anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
2260 connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
2261 mgr->registerAction( anAction, RotationId );
2264 anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
2265 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
2266 tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
2267 anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
2268 connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
2269 this->addAction(anAction);
2270 mgr->registerAction( anAction, FrontId );
2272 anAction = new QtxAction(tr("MNU_BACK_VIEW"),
2273 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
2274 tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
2275 anAction->setStatusTip(tr("DSC_BACK_VIEW"));
2276 connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView()));
2277 this->addAction(anAction);
2278 mgr->registerAction( anAction, BackId );
2280 anAction = new QtxAction(tr("MNU_TOP_VIEW"),
2281 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
2282 tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
2283 anAction->setStatusTip(tr("DSC_TOP_VIEW"));
2284 connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView()));
2285 this->addAction(anAction);
2286 mgr->registerAction( anAction, TopId );
2288 anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
2289 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
2290 tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
2291 anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
2292 connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
2293 this->addAction(anAction);
2294 mgr->registerAction( anAction, BottomId );
2296 anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
2297 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
2298 tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
2299 anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
2300 connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
2301 this->addAction(anAction);
2302 mgr->registerAction( anAction, LeftId );
2304 anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
2305 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
2306 tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
2307 anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
2308 connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView()));
2309 this->addAction(anAction);
2310 mgr->registerAction( anAction, RightId );
2312 // rotate anticlockwise
2313 anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
2314 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
2315 tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
2316 anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
2317 connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
2318 this->addAction(anAction);
2319 mgr->registerAction( anAction, AntiClockWiseId );
2322 anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
2323 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
2324 tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
2325 anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
2326 connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
2327 this->addAction(anAction);
2328 mgr->registerAction( anAction, ClockWiseId );
2331 anAction = new QtxAction(tr("MNU_RESET_VIEW"),
2332 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
2333 tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
2334 anAction->setStatusTip(tr("DSC_RESET_VIEW"));
2335 connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView()));
2336 this->addAction(anAction);
2337 mgr->registerAction( anAction, ResetId );
2339 // onViewTrihedron: Shows - Hides Trihedron
2340 anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
2341 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
2342 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
2343 anAction->setCheckable( true );
2344 anAction->setChecked( true );
2346 anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
2347 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool)));
2348 mgr->registerAction( anAction, ViewTrihedronId );
2350 // onNonIsometric: Manage non-isometric params
2351 anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
2352 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
2353 tr( "MNU_SVTK_SCALING" ), 0, this);
2354 anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
2355 anAction->setCheckable(true);
2356 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
2357 mgr->registerAction( anAction, NonIsometric );
2359 // onGraduatedAxes: Manage graduated axes params
2360 anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
2361 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
2362 tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
2363 anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
2364 anAction->setCheckable(true);
2365 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
2366 mgr->registerAction( anAction, GraduatedAxes );
2368 // onGraduatedAxes: Manage graduated axes params
2369 anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"),
2370 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
2371 tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
2372 anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
2373 anAction->setCheckable(true);
2374 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
2375 mgr->registerAction( anAction, UpdateRate );
2377 // Set perspective mode group
2378 anAction = new QtxAction(tr("MNU_SVTK_PARALLEL_MODE"),
2379 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ),
2380 tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
2381 anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
2382 anAction->setCheckable(true);
2383 mgr->registerAction( anAction, ParallelModeId );
2385 anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"),
2386 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ),
2387 tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
2388 anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
2389 anAction->setCheckable(true);
2390 mgr->registerAction( anAction, ProjectionModeId );
2392 anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
2393 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ),
2394 tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
2395 anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
2396 anAction->setCheckable(true);
2397 connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool)));
2398 mgr->registerAction( anAction, StereoModeId );
2400 QActionGroup* aPerspectiveGroup = new QActionGroup( this );
2401 aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
2402 aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
2403 connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*)));
2406 anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
2407 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
2408 tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
2409 anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
2410 anAction->setCheckable(true);
2411 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
2412 mgr->registerAction( anAction, ViewParametersId );
2415 mgr->registerAction( synchronizeAction(), SynchronizeId );
2417 // Switch between interaction styles
2418 anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
2419 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
2420 tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
2421 anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
2422 anAction->setCheckable(true);
2423 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
2424 mgr->registerAction( anAction, SwitchInteractionStyleId );
2426 // Switch between zooming styles
2427 anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"),
2428 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
2429 tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
2430 anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH"));
2431 anAction->setCheckable(true);
2432 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
2433 mgr->registerAction( anAction, SwitchZoomingStyleId );
2436 QSignalMapper* aSignalMapper = new QSignalMapper( this );
2437 connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int)));
2439 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_STANDARD"),
2440 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ),
2441 tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
2442 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
2443 anAction->setCheckable(true);
2444 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2445 aSignalMapper->setMapping( anAction, Standard_Preselection );
2446 mgr->registerAction( anAction, StandardPreselectionId );
2448 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DYNAMIC"),
2449 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DYNAMIC" ) ),
2450 tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
2451 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
2452 anAction->setCheckable(true);
2453 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2454 aSignalMapper->setMapping( anAction, Dynamic_Preselection );
2455 mgr->registerAction( anAction, DynamicPreselectionId );
2457 anAction = new QtxAction(tr("MNU_SVTK_PRESELECTION_DISABLED"),
2458 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_DISABLED" ) ),
2459 tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
2460 anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
2461 anAction->setCheckable(true);
2462 connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
2463 aSignalMapper->setMapping( anAction, Preselection_Disabled );
2464 mgr->registerAction( anAction, DisablePreselectionId );
2466 QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true );
2467 aPreselectionAction->add( getAction( StandardPreselectionId ) );
2468 aPreselectionAction->add( getAction( DynamicPreselectionId ) );
2469 aPreselectionAction->add( getAction( DisablePreselectionId ) );
2470 mgr->registerAction( aPreselectionAction, PreselectionId );
2473 anAction = new QtxAction(tr("MNU_SVTK_ENABLE_SELECTION"),
2474 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SELECTION" ) ),
2475 tr( "MNU_SVTK_ENABLE_SELECTION" ), 0, this);
2476 anAction->setStatusTip(tr("DSC_SVTK_ENABLE_SELECTION"));
2477 anAction->setCheckable(true);
2478 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool)));
2479 mgr->registerAction( anAction, EnableSelectionId );
2482 myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
2483 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
2484 tr( "MNU_SVTK_RECORDING_START" ), 0, this);
2485 myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
2486 connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
2487 mgr->registerAction( myStartAction, StartRecordingId );
2490 myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
2491 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
2492 tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
2493 myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
2494 myPlayAction->setEnabled( false );
2495 connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
2496 mgr->registerAction( myPlayAction, PlayRecordingId );
2499 myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
2500 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
2501 tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
2502 myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
2503 myPauseAction->setEnabled( false );
2504 connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
2505 mgr->registerAction( myPauseAction, PauseRecordingId );
2508 myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
2509 theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
2510 tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
2511 myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
2512 myStopAction->setEnabled( false );
2513 connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
2514 mgr->registerAction( myStopAction, StopRecordingId );
2518 Creates toolbar of svtk main window
2520 void SVTK_ViewWindow::createToolBar()
2522 QtxActionToolMgr* mgr = toolMgr();
2524 mgr->append( DumpId, myToolBar );
2525 mgr->append( SwitchInteractionStyleId, myToolBar );
2526 mgr->append( SwitchZoomingStyleId, myToolBar );
2528 mgr->append( mgr->separator(), myToolBar );
2530 mgr->append( PreselectionId, myToolBar );
2531 mgr->append( EnableSelectionId, myToolBar );
2533 mgr->append( mgr->separator(), myToolBar );
2535 mgr->append( ViewTrihedronId, myToolBar );
2537 QtxMultiAction* aScaleAction = new QtxMultiAction( this );
2538 aScaleAction->insertAction( getAction( FitAllId ) );
2539 aScaleAction->insertAction( getAction( FitRectId ) );
2540 aScaleAction->insertAction( getAction( FitSelectionId ) );
2541 aScaleAction->insertAction( getAction( ZoomId ) );
2542 mgr->append( aScaleAction, myToolBar );
2544 QtxMultiAction* aPanningAction = new QtxMultiAction( this );
2545 aPanningAction->insertAction( getAction( PanId ) );
2546 aPanningAction->insertAction( getAction( GlobalPanId ) );
2547 mgr->append( aPanningAction, myToolBar );
2549 mgr->append( ChangeRotationPointId, myToolBar );
2551 mgr->append( RotationId, myToolBar );
2553 QtxMultiAction* aViewsAction = new QtxMultiAction( this );
2554 aViewsAction->insertAction( getAction( FrontId ) );
2555 aViewsAction->insertAction( getAction( BackId ) );
2556 aViewsAction->insertAction( getAction( TopId ) );
2557 aViewsAction->insertAction( getAction( BottomId ) );
2558 aViewsAction->insertAction( getAction( LeftId ) );
2559 aViewsAction->insertAction( getAction( RightId ) );
2560 mgr->append( aViewsAction, myToolBar );
2562 mgr->append( AntiClockWiseId, myToolBar );
2563 mgr->append( ClockWiseId, myToolBar );
2565 mgr->append( ResetId, myToolBar );
2567 mgr->append( UpdateRate, myToolBar );
2568 mgr->append( NonIsometric, myToolBar );
2569 mgr->append( GraduatedAxes, myToolBar );
2571 mgr->append( ViewParametersId, myToolBar );
2572 mgr->append( SynchronizeId, myToolBar );
2574 mgr->append( toolMgr()->separator(), myToolBar );
2576 mgr->append( ParallelModeId, myToolBar );
2577 mgr->append( ProjectionModeId, myToolBar );
2578 mgr->append( StereoModeId, myToolBar );
2580 mgr->append( StartRecordingId, myRecordingToolBar );
2581 mgr->append( PlayRecordingId, myRecordingToolBar );
2582 mgr->append( PauseRecordingId, myRecordingToolBar );
2583 mgr->append( StopRecordingId, myRecordingToolBar );
2586 void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
2589 myUpdateRateDlg->Update();
2590 myUpdateRateDlg->show();
2592 myUpdateRateDlg->hide();
2595 void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
2598 myNonIsometricDlg->Update();
2599 myNonIsometricDlg->show();
2601 myNonIsometricDlg->hide();
2604 void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
2607 myCubeAxesDlg->Update();
2608 myCubeAxesDlg->show();
2610 myCubeAxesDlg->hide();
2614 Starts rotation transformation
2616 void SVTK_ViewWindow::activateRotation()
2618 myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
2623 Starts panning transformation
2625 void SVTK_ViewWindow::activatePanning()
2627 myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
2631 Starts zoom transformation
2633 void SVTK_ViewWindow::activateZoom()
2635 myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
2639 Starts window fit transformation
2641 void SVTK_ViewWindow::activateWindowFit()
2643 myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
2647 Starts global panning transformation
2649 void SVTK_ViewWindow::activateGlobalPanning()
2651 myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
2654 void SVTK_ViewWindow::onStartRecording()
2656 myRecorder->CheckExistAVIMaker();
2657 if (myRecorder->ErrorStatus()) {
2658 SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
2661 SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
2663 if( !aRecorderDlg->exec() )
2666 myStartAction->setEnabled( false );
2667 myPlayAction->setEnabled( false );
2668 myPauseAction->setEnabled( true );
2669 myStopAction->setEnabled( true );
2671 // to prevent resizing the window while recording
2672 myPreRecordingMinSize = minimumSize();
2673 myPreRecordingMaxSize = maximumSize();
2674 setFixedSize( size() );
2676 myRecorder->Record();
2680 void SVTK_ViewWindow::onPlayRecording()
2682 myStartAction->setEnabled( false );
2683 myPlayAction->setEnabled( false );
2684 myPauseAction->setEnabled( true );
2685 myStopAction->setEnabled( true );
2687 myRecorder->Pause();
2690 void SVTK_ViewWindow::onPauseRecording()
2692 myStartAction->setEnabled( false );
2693 myPlayAction->setEnabled( true );
2694 myPauseAction->setEnabled( false );
2695 myStopAction->setEnabled( true );
2697 myRecorder->Pause();
2700 void SVTK_ViewWindow::onStopRecording()
2702 myStartAction->setEnabled( true );
2703 myPlayAction->setEnabled( false );
2704 myPauseAction->setEnabled( false );
2705 myStopAction->setEnabled( false );
2709 setMinimumSize( myPreRecordingMinSize );
2710 setMaximumSize( myPreRecordingMaxSize );
2714 To invoke a VTK event on SVTK_RenderWindowInteractor instance
2716 void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
2718 GetInteractor()->InvokeEvent(theEvent,theCallData);
2722 Modify view parameters
2724 void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
2727 myViewParameterDlg->addObserver();
2728 myViewParameterDlg->show();
2730 myViewParameterDlg->hide();
2734 Custom show event handler
2736 void SVTK_ViewWindow::showEvent( QShowEvent * theEvent )
2738 emit Show( theEvent );
2742 Custom hide event handler
2744 void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
2746 emit Hide( theEvent );
2750 Emit transformed signal.
2752 void SVTK_ViewWindow::emitTransformed() {
2759 void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
2760 unsigned long /*theEvent*/,
2761 void* theClientData,
2762 void* /*theCallData*/)
2764 SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
2766 self->emitTransformed();
2770 Get camera properties for the SVTK view window.
2771 \return shared pointer on camera properties.
2773 SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
2775 SUIT_CameraProperties aProps;
2778 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2782 aProps.setDimension( SUIT_CameraProperties::Dim3D );
2783 if ( toolMgr()->action( ParallelModeId ) ) {
2784 if ( toolMgr()->action( ParallelModeId )->isChecked() )
2785 aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
2787 aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
2790 double aFocalPoint[3];
2791 double aPosition[3];
2793 double anAxialScale[3];
2795 aCamera->OrthogonalizeViewUp();
2796 aCamera->GetFocalPoint( aFocalPoint );
2797 aCamera->GetPosition( aPosition );
2798 aCamera->GetViewUp( aViewUp );
2800 aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2801 aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] );
2802 aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2803 aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 );
2805 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2807 aProps.setViewAngle( aCamera->GetViewAngle() );
2810 GetRenderer()->GetScale( anAxialScale );
2811 aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2818 This implementation synchronizes camera propreties.
2820 void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2822 bool blocked = blockSignals( true );
2824 SUIT_CameraProperties aProps = theView->cameraProperties();
2825 if ( !cameraProperties().isCompatible( aProps ) ) {
2826 // other view, this one is being currently synchronized to, seems has become incompatible
2827 // we have to break synchronization
2833 vtkCamera* aCamera = getRenderer()->GetActiveCamera();
2835 double aFocalPoint[3];
2836 double aPosition[3];
2838 double anAxialScale[3];
2840 // get common properties
2841 aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] );
2842 aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
2843 aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
2844 aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
2846 // restore properties to the camera
2847 aCamera->SetViewUp( aViewUp );
2848 aCamera->SetPosition( aPosition );
2849 aCamera->SetFocalPoint( aFocalPoint );
2850 aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 );
2852 if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective )
2854 aCamera->SetViewAngle( aProps.getViewAngle() );
2857 GetRenderer()->SetScale( anAxialScale );
2859 getRenderer()->ResetCameraClippingRange();
2862 blockSignals( blocked );
2865 void SVTK_ViewWindow::resizeEvent( QResizeEvent* theEvent )
2867 #ifdef VGL_WORKAROUND