1 // Copyright (C) 2007-2008 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.
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
22 #include "VTKViewer_ViewWindow.h"
23 #include "VTKViewer_ViewModel.h"
24 #include "VTKViewer_RenderWindow.h"
25 #include "VTKViewer_RenderWindowInteractor.h"
26 #include "VTKViewer_InteractorStyle.h"
27 #include "VTKViewer_Trihedron.h"
28 #include "VTKViewer_Transform.h"
29 #include "VTKViewer_Utilities.h"
31 #include <SUIT_Session.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_Tools.h>
34 #include <SUIT_ResourceMgr.h>
38 #include <vtkRenderer.h>
39 #include <vtkCamera.h>
41 #include <QtxToolBar.h>
42 #include <QtxMultiAction.h>
45 VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop,
46 VTKViewer_Viewer* theModel,
47 VTKViewer_InteractorStyle* iStyle,
48 VTKViewer_RenderWindowInteractor* rw )
49 : SUIT_ViewWindow( theDesktop )
53 myTrihedron = VTKViewer_Trihedron::New();
54 myTransform = VTKViewer_Transform::New();
55 myRenderer = vtkRenderer::New() ;
57 myTrihedron->AddToRender( myRenderer );
59 myRenderWindow = new VTKViewer_RenderWindow( this, "RenderWindow" );
60 setCentralWidget(myRenderWindow);
61 myRenderWindow->setFocusPolicy( Qt::StrongFocus );
62 myRenderWindow->setFocus();
64 myRenderWindow->getRenderWindow()->AddRenderer( myRenderer );
66 myRenderer->GetActiveCamera()->ParallelProjectionOn();
67 myRenderer->LightFollowCameraOn();
68 myRenderer->TwoSidedLightingOn();
70 // Set BackgroundColor
71 QString BgrColorRed = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
72 QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
73 QString BgrColorBlue = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
75 if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() )
76 myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
78 myRenderer->SetBackground( 0, 0, 0 );
80 // Create an interactor.
81 myRWInteractor = rw ? rw : VTKViewer_RenderWindowInteractor::New();
82 myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
84 VTKViewer_InteractorStyle* RWS = iStyle ? iStyle : VTKViewer_InteractorStyle::New();
85 RWS->setGUIWindow( myRenderWindow );
86 myRWInteractor->SetInteractorStyle( RWS );
88 myRWInteractor->Initialize();
89 RWS->setTriedron( myTrihedron );
90 RWS->FindPokedRenderer( 0, 0 );
92 setCentralWidget( myRenderWindow );
94 myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this );
99 connect( myRenderWindow, SIGNAL(KeyPressed( QKeyEvent* )),
100 this, SLOT(onKeyPressed( QKeyEvent* )) );
101 connect( myRenderWindow, SIGNAL(KeyReleased( QKeyEvent* )),
102 this, SLOT(onKeyReleased( QKeyEvent* )) );
103 connect( myRenderWindow, SIGNAL(MouseButtonPressed( QMouseEvent* )),
104 this, SLOT(onMousePressed( QMouseEvent* )) );
105 connect( myRenderWindow, SIGNAL(MouseButtonReleased( QMouseEvent* )),
106 this, SLOT(onMouseReleased( QMouseEvent* )) );
107 connect( myRenderWindow, SIGNAL(MouseDoubleClicked( QMouseEvent* )),
108 this, SLOT(onMouseDoubleClicked( QMouseEvent* )) );
109 connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
110 this, SLOT(onMouseMoving( QMouseEvent* )) );
111 connect( myRWInteractor, SIGNAL(RenderWindowModified()),
112 myRenderWindow, SLOT(update()) );
114 connect( myRenderWindow, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
115 this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
117 connect( myRWInteractor, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
118 this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
125 VTKViewer_ViewWindow::~VTKViewer_ViewWindow()
127 myTransform->Delete();
128 // In order to ensure that the interactor unregisters
129 // this RenderWindow, we assign a NULL RenderWindow to
130 // it before deleting it.
131 myRWInteractor->SetRenderWindow( NULL );
132 myRWInteractor->Delete();
135 myRenderer->RemoveAllViewProps();
136 //m_Renderer->Delete() ;
137 myTrihedron->Delete();
140 /*!Checks: is trihedron displayed.*/
141 bool VTKViewer_ViewWindow::isTrihedronDisplayed(){
142 return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
145 /*!Activates 'zooming' transformation*/
146 void VTKViewer_ViewWindow::activateZoom()
148 myRWInteractor->GetInteractorStyle()->startZoom();
151 /*!Activates 'panning' transformation*/
152 void VTKViewer_ViewWindow::activatePanning()
154 myRWInteractor->GetInteractorStyle()->startPan();
157 /*!Activates 'rotation' transformation*/
158 void VTKViewer_ViewWindow::activateRotation()
160 myRWInteractor->GetInteractorStyle()->startRotate();
163 /*!Activate global panning.*/
164 void VTKViewer_ViewWindow::activateGlobalPanning()
166 //if(myTrihedron->GetVisibleActorCount(myRenderer))
167 myRWInteractor->GetInteractorStyle()->startGlobalPan();
170 /*!Activates 'fit area' transformation*/
171 void VTKViewer_ViewWindow::activateWindowFit()
173 myRWInteractor->GetInteractorStyle()->startFitArea();
177 void VTKViewer_ViewWindow::createActions()
179 if (!myActionsMap.isEmpty()) return;
181 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
186 aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
187 tr( "MNU_DUMP_VIEW" ), 0, this);
188 aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
189 connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
190 myActionsMap[ DumpId ] = aAction;
193 aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
194 tr( "MNU_FITALL" ), 0, this);
195 aAction->setStatusTip(tr("DSC_FITALL"));
196 connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
197 myActionsMap[ FitAllId ] = aAction;
200 aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
201 tr( "MNU_FITRECT" ), 0, this);
202 aAction->setStatusTip(tr("DSC_FITRECT"));
203 connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
204 myActionsMap[ FitRectId ] = aAction;
207 aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
208 tr( "MNU_ZOOM_VIEW" ), 0, this);
209 aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
210 connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
211 myActionsMap[ ZoomId ] = aAction;
214 aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
215 tr( "MNU_PAN_VIEW" ), 0, this);
216 aAction->setStatusTip(tr("DSC_PAN_VIEW"));
217 connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
218 myActionsMap[ PanId ] = aAction;
220 //! \li Global Panning
221 aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
222 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
223 aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
224 connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
225 myActionsMap[ GlobalPanId ] = aAction;
228 aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
229 tr( "MNU_ROTATE_VIEW" ), 0, this);
230 aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
231 connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
232 myActionsMap[ RotationId ] = aAction;
235 aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
236 tr( "MNU_FRONT_VIEW" ), 0, this);
237 aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
238 connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
239 myActionsMap[ FrontId ] = aAction;
242 aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
243 tr( "MNU_BACK_VIEW" ), 0, this);
244 aAction->setStatusTip(tr("DSC_BACK_VIEW"));
245 connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
246 myActionsMap[ BackId ] = aAction;
249 aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
250 tr( "MNU_TOP_VIEW" ), 0, this);
251 aAction->setStatusTip(tr("DSC_TOP_VIEW"));
252 connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
253 myActionsMap[ TopId ] = aAction;
256 aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
257 tr( "MNU_BOTTOM_VIEW" ), 0, this);
258 aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
259 connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
260 myActionsMap[ BottomId ] = aAction;
263 aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
264 tr( "MNU_LEFT_VIEW" ), 0, this);
265 aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
266 connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
267 myActionsMap[ LeftId ] = aAction;
270 aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
271 tr( "MNU_RIGHT_VIEW" ), 0, this);
272 aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
273 connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
274 myActionsMap[ RightId ] = aAction;
277 aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
278 tr( "MNU_RESET_VIEW" ), 0, this);
279 aAction->setStatusTip(tr("DSC_RESET_VIEW"));
280 connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
281 myActionsMap[ ResetId ] = aAction;
283 //! \li Trihedron shown
284 aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
285 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
286 aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
287 connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
288 myActionsMap[ TrihedronShowId ] = aAction;
291 /*!Create tool bar.*/
292 void VTKViewer_ViewWindow::createToolBar()
294 myToolBar->addAction( myActionsMap[DumpId] );
295 myToolBar->addAction( myActionsMap[TrihedronShowId] );
297 QtxMultiAction* aScaleAction = new QtxMultiAction( this );
298 aScaleAction->insertAction( myActionsMap[FitAllId] );
299 aScaleAction->insertAction( myActionsMap[FitRectId] );
300 aScaleAction->insertAction( myActionsMap[ZoomId] );
301 myToolBar->addAction( aScaleAction );
303 QtxMultiAction* aPanningAction = new QtxMultiAction( this );
304 aPanningAction->insertAction( myActionsMap[PanId] );
305 aPanningAction->insertAction( myActionsMap[GlobalPanId] );
306 myToolBar->addAction( aPanningAction );
308 myToolBar->addAction( myActionsMap[RotationId] );
310 QtxMultiAction* aViewsAction = new QtxMultiAction(myToolBar);
311 aViewsAction->insertAction( myActionsMap[FrontId] );
312 aViewsAction->insertAction( myActionsMap[BackId] );
313 aViewsAction->insertAction( myActionsMap[TopId] );
314 aViewsAction->insertAction( myActionsMap[BottomId] );
315 aViewsAction->insertAction( myActionsMap[LeftId] );
316 aViewsAction->insertAction( myActionsMap[RightId] );
317 myToolBar->addAction( aViewsAction );
319 myToolBar->addAction( myActionsMap[ResetId] );
322 /*!On front view event.*/
323 void VTKViewer_ViewWindow::onFrontView()
325 vtkCamera* camera = myRenderer->GetActiveCamera();
326 camera->SetPosition(1,0,0);
327 camera->SetViewUp(0,0,1);
328 camera->SetFocalPoint(0,0,0);
332 /*!On back view slot.*/
333 void VTKViewer_ViewWindow::onBackView()
335 vtkCamera* camera = myRenderer->GetActiveCamera();
336 camera->SetPosition(-1,0,0);
337 camera->SetViewUp(0,0,1);
338 camera->SetFocalPoint(0,0,0);
342 /*!On back view slot.*/
343 void VTKViewer_ViewWindow::onTopView()
345 vtkCamera* camera = myRenderer->GetActiveCamera();
346 camera->SetPosition(0,0,1);
347 camera->SetViewUp(0,1,0);
348 camera->SetFocalPoint(0,0,0);
352 /*!On bottom view slot.*/
353 void VTKViewer_ViewWindow::onBottomView()
355 vtkCamera* camera = myRenderer->GetActiveCamera();
356 camera->SetPosition(0,0,-1);
357 camera->SetViewUp(0,1,0);
358 camera->SetFocalPoint(0,0,0);
362 /*!On left view slot.*/
363 void VTKViewer_ViewWindow::onLeftView()
365 vtkCamera* camera = myRenderer->GetActiveCamera();
366 camera->SetPosition(0,-1,0);
367 camera->SetViewUp(0,0,1);
368 camera->SetFocalPoint(0,0,0);
372 /*!On right view slot.*/
373 void VTKViewer_ViewWindow::onRightView()
375 vtkCamera* camera = myRenderer->GetActiveCamera();
376 camera->SetPosition(0,1,0);
377 camera->SetViewUp(0,0,1);
378 camera->SetFocalPoint(0,0,0);
382 /*!On reset view slot.*/
383 void VTKViewer_ViewWindow::onResetView()
385 int aTriedronIsVisible = isTrihedronDisplayed();
386 myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
387 ::ResetCamera(myRenderer,true);
388 vtkCamera* aCamera = myRenderer->GetActiveCamera();
389 aCamera->SetPosition(1,-1,1);
390 aCamera->SetViewUp(0,0,1);
391 ::ResetCamera(myRenderer,true);
392 if(aTriedronIsVisible) myTrihedron->VisibilityOn();
393 else myTrihedron->VisibilityOff();
394 static vtkFloatingPointType aCoeff = 3.0;
395 aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
399 /*!On fit all slot.*/
400 void VTKViewer_ViewWindow::onFitAll()
402 myRWInteractor->GetInteractorStyle()->ViewFitAll();
406 /*!Set background of the viewport*/
407 void VTKViewer_ViewWindow::setBackgroundColor( const QColor& color )
410 myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
413 /*!Returns background of the viewport*/
414 QColor VTKViewer_ViewWindow::backgroundColor() const
416 vtkFloatingPointType backint[3];
418 myRenderer->GetBackground( backint );
419 return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
421 return palette().color( backgroundRole() );
424 /*!Repaint window. If \a theUpdateTrihedron is true - recalculate trihedron.*/
425 void VTKViewer_ViewWindow::Repaint(bool theUpdateTrihedron)
427 if (theUpdateTrihedron) onAdjustTrihedron();
428 myRenderWindow->update();
431 /*!Get scale of transformation filter.*/
432 void VTKViewer_ViewWindow::GetScale( double theScale[3] ) {
433 myTransform->GetScale( theScale );
436 /*!Set scale of transformation filter and repaint window.*/
437 void VTKViewer_ViewWindow::SetScale( double theScale[3] ) {
438 myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
439 myRWInteractor->Render();
443 /*!Calculation trihedron size.*/
444 void VTKViewer_ViewWindow::onAdjustTrihedron(){
445 if( !isTrihedronDisplayed() )
447 int aVisibleNum = myTrihedron->GetVisibleActorCount(myRenderer);
449 // calculating diagonal of visible props of the renderer
450 vtkFloatingPointType bnd[6];
451 myTrihedron->VisibilityOff();
452 ::ComputeVisiblePropBounds(myRenderer,bnd);
453 myTrihedron->VisibilityOn();
454 vtkFloatingPointType aLength = 0;
455 static bool CalcByDiag = false;
457 aLength = sqrt((bnd[1]-bnd[0])*(bnd[1]-bnd[0])+
458 (bnd[3]-bnd[2])*(bnd[3]-bnd[2])+
459 (bnd[5]-bnd[4])*(bnd[5]-bnd[4]));
461 aLength = bnd[1]-bnd[0];
462 aLength = qMax((bnd[3]-bnd[2]),aLength);
463 aLength = qMax((bnd[5]-bnd[4]),aLength);
466 static vtkFloatingPointType aSizeInPercents = 105;
467 QString aSetting;// = SUIT_CONFIG->getSetting("Viewer:TrihedronSize");
468 if(!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat();
470 static vtkFloatingPointType EPS_SIZE = 5.0E-3;
471 vtkFloatingPointType aSize = myTrihedron->GetSize();
472 vtkFloatingPointType aNewSize = aLength*aSizeInPercents/100.0;
473 // if the new trihedron size have sufficient difference, then apply the value
474 if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE){
475 myTrihedron->SetSize(aNewSize);
478 ::ResetCameraClippingRange(myRenderer);
481 /*!Emit key pressed.*/
482 void VTKViewer_ViewWindow::onKeyPressed(QKeyEvent* event)
484 emit keyPressed( this, event );
487 /*!Emit key released.*/
488 void VTKViewer_ViewWindow::onKeyReleased(QKeyEvent* event)
490 emit keyReleased( this, event );
493 /*!Emit key pressed.*/
494 void VTKViewer_ViewWindow::onMousePressed(QMouseEvent* event)
496 emit mousePressed(this, event);
499 /*!Emit mouse released.*/
500 void VTKViewer_ViewWindow::onMouseReleased(QMouseEvent* event)
502 emit mouseReleased( this, event );
505 /*!Emit mouse moving.*/
506 void VTKViewer_ViewWindow::onMouseMoving(QMouseEvent* event)
508 emit mouseMoving( this, event );
511 /*!Emit mouse double clicked.*/
512 void VTKViewer_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
514 emit mouseDoubleClicked( this, event );
517 /*!Insert actor to renderer and transformation filter.
518 *Move Internal actors, if \a theMoveInternalActors is true.
520 void VTKViewer_ViewWindow::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors ){
521 theActor->AddToRender(myRenderer);
522 theActor->SetTransform(myTransform);
523 if(theMoveInternalActors)
524 myRWInteractor->MoveInternalActors();
527 /*!Add actor.Repaint window if \a theUpdate is true.
528 *@see InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors )
530 void VTKViewer_ViewWindow::AddActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ ){
531 InsertActor(theActor);
536 /*!Remove \a theActor from renderer and pepaint, if \a theUpdate is true.*/
537 void VTKViewer_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ ){
538 theActor->RemoveFromRender(myRenderer);
543 /*!@see RemoveActor() and InsertActor().*/
544 void VTKViewer_ViewWindow::MoveActor( VTKViewer_Actor* theActor)
546 RemoveActor(theActor);
547 InsertActor(theActor,true);
550 /*!On trihedron show slot.*/
551 void VTKViewer_ViewWindow::onTrihedronShow()
553 if (isTrihedronDisplayed())
554 myTrihedron->VisibilityOff();
556 myTrihedron->VisibilityOn();
557 myRenderWindow->update();
561 QImage VTKViewer_ViewWindow::dumpView()
563 QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
567 /*! The method returns the visual parameters of this view as a formated string
569 QString VTKViewer_ViewWindow::getVisualParameters()
571 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
573 vtkCamera* camera = myRenderer->GetActiveCamera();
574 camera->GetPosition( pos );
575 camera->GetFocalPoint( focalPnt );
576 camera->GetViewUp( viewUp );
577 parScale = camera->GetParallelScale();
581 retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e",
582 pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1],
583 viewUp[2], parScale, scale[0], scale[1], scale[2] );
587 /*! The method restors visual parameters of this view from a formated string
589 void VTKViewer_ViewWindow::setVisualParameters( const QString& parameters )
591 QStringList paramsLst = parameters.split( '*' );
592 if ( paramsLst.size() == 13 ) {
593 double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
594 pos[0] = paramsLst[0].toDouble();
595 pos[1] = paramsLst[1].toDouble();
596 pos[2] = paramsLst[2].toDouble();
597 focalPnt[0] = paramsLst[3].toDouble();
598 focalPnt[1] = paramsLst[4].toDouble();
599 focalPnt[2] = paramsLst[5].toDouble();
600 viewUp[0] = paramsLst[6].toDouble();
601 viewUp[1] = paramsLst[7].toDouble();
602 viewUp[2] = paramsLst[8].toDouble();
603 parScale = paramsLst[9].toDouble();
604 scale[0] = paramsLst[10].toDouble();
605 scale[1] = paramsLst[11].toDouble();
606 scale[2] = paramsLst[12].toDouble();
608 vtkCamera* camera = myRenderer->GetActiveCamera();
609 camera->SetPosition( pos );
610 camera->SetFocalPoint( focalPnt );
611 camera->SetViewUp( viewUp );
612 camera->SetParallelScale( parScale );
613 myTransform->SetMatrixScale( scale[0], scale[1], scale[2] );
614 myRWInteractor->Render();