From: asv Date: Fri, 27 Jan 2006 12:55:54 +0000 (+0000) Subject: further implementation of get/setVisualParameters() X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc0dcd5fa440f5dd9f6e0ca1a895cbe78df396d9;p=modules%2Fgui.git further implementation of get/setVisualParameters() --- diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 6ee41df13..df7766392 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -1080,3 +1080,65 @@ SVTK_ViewWindow case SUIT_Accel::RotateDown : onRotateDown(); break; } } + + +//---------------------------------------------------------------------------- +/*! The method returns the visual parameters of this view as a formated string + */ +QString +SVTK_ViewWindow +::getVisualParameters() +{ + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + + vtkCamera* camera = myRenderer->GetActiveCamera(); + camera->GetPosition( pos ); + camera->GetFocalPoint( focalPnt ); + camera->GetViewUp( viewUp ); + parScale = camera->GetParallelScale(); + GetScale( scale ); + + return QString( "%1*%2*%3*%4*%5*%6*%7*%8*%9*%10*%11*%12*%13" ).arg( + pos[0] ).arg( pos[1] ).arg( pos[2] ).arg( focalPnt[0] ).arg( focalPnt[1] ).arg( + focalPnt[2] ).arg( viewUp[0] ).arg( viewUp[1] ).arg( viewUp[2] ).arg( parScale ).arg( + scale[0] ).arg( scale[1] ).arg( scale[2] ); +} + +//---------------------------------------------------------------------------- +/* The method restors visual parameters of this view from a formated string + */ +void +SVTK_ViewWindow +::setVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( paramsLst.size() == 13 ) { + printf( "-- VTK::setVisualParameters = %f %f %f %f %f %f %f %f %f %f %f %f %f\n", paramsLst[0].toDouble(), + paramsLst[1].toDouble(), paramsLst[2].toDouble(), paramsLst[3].toDouble(), paramsLst[4].toDouble(), + paramsLst[5].toDouble(), paramsLst[6].toDouble(), paramsLst[7].toDouble(), paramsLst[8].toDouble(), + paramsLst[9].toDouble(), paramsLst[10].toDouble(), paramsLst[11].toDouble(), paramsLst[12].toDouble() ); + + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + pos[0] = paramsLst[0].toDouble(); + pos[1] = paramsLst[1].toDouble(); + pos[2] = paramsLst[2].toDouble(); + focalPnt[0] = paramsLst[3].toDouble(); + focalPnt[1] = paramsLst[4].toDouble(); + focalPnt[2] = paramsLst[5].toDouble(); + viewUp[0] = paramsLst[6].toDouble(); + viewUp[1] = paramsLst[7].toDouble(); + viewUp[2] = paramsLst[8].toDouble(); + parScale = paramsLst[9].toDouble(); + scale[0] = paramsLst[10].toDouble(); + scale[1] = paramsLst[11].toDouble(); + scale[2] = paramsLst[12].toDouble(); + + vtkCamera* camera = myRenderer->GetActiveCamera(); + camera->SetPosition( pos ); + camera->SetFocalPoint( focalPnt ); + camera->SetViewUp( viewUp ); + camera->SetParallelScale( parScale ); + myTransform->SetMatrixScale( scale[0], scale[1], scale[2] ); + myRWInteractor->Render(); + } +} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 2aec73b8d..b306ee3ad 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -107,6 +107,9 @@ public: VTKViewer_Trihedron* GetTrihedron() {return this->myTrihedron;}; SVTK_CubeAxesActor2D* GetCubeAxes() {return this->myCubeAxes;}; + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& parameters ); + public slots: void onSelectionChanged(); diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index d8f607235..83b5e5615 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -592,23 +592,25 @@ void VTKViewer_ViewWindow::setVisualParameters( const QString& parameters ) double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; pos[0] = paramsLst[0].toDouble(); - pos[0] = paramsLst[1].toDouble(); - pos[0] = paramsLst[2].toDouble(); + pos[1] = paramsLst[1].toDouble(); + pos[2] = paramsLst[2].toDouble(); focalPnt[0] = paramsLst[3].toDouble(); - focalPnt[0] = paramsLst[4].toDouble(); - focalPnt[0] = paramsLst[5].toDouble(); + focalPnt[1] = paramsLst[4].toDouble(); + focalPnt[2] = paramsLst[5].toDouble(); viewUp[0] = paramsLst[6].toDouble(); - viewUp[0] = paramsLst[7].toDouble(); - viewUp[0] = paramsLst[8].toDouble(); + viewUp[1] = paramsLst[7].toDouble(); + viewUp[2] = paramsLst[8].toDouble(); parScale = paramsLst[9].toDouble(); scale[0] = paramsLst[10].toDouble(); - scale[0] = paramsLst[11].toDouble(); - scale[0] = paramsLst[12].toDouble(); + scale[1] = paramsLst[11].toDouble(); + scale[2] = paramsLst[12].toDouble(); + vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition( pos ); camera->SetFocalPoint( focalPnt ); camera->SetViewUp( viewUp ); camera->SetParallelScale( parScale ); - SetScale( scale ); + myTransform->SetMatrixScale( scale[0], scale[1], scale[2] ); + myRWInteractor->Render(); } }