From: asv Date: Tue, 31 Jan 2006 08:37:49 +0000 (+0000) Subject: further implementation of get/setVisualParameters() X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7a8d0e3c8115451a95ea5501ce3418b6e86c34d;p=modules%2Fgui.git further implementation of get/setVisualParameters() --- diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index c72b71eb9..1bb6c8a38 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -552,11 +552,32 @@ void GLViewer_ViewFrame::wheelEvent( QWheelEvent* e ) */ QString GLViewer_ViewFrame::getVisualParameters() { - return " "; + QString retStr; + if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) ) { + GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP; + GLfloat xSc, ySc, xPan, yPan; + vp2d->getScale( xSc, ySc ); + vp2d->getPan( xPan, yPan ); + retStr.sprintf( "%.12f*%.12f*%.12f*%.12f", xSc, ySc, xPan, yPan ); + } + return retStr; } /* The method restors visual parameters of this view from a formated string */ void GLViewer_ViewFrame::setVisualParameters( const QString& parameters ) { + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 4) { + GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP; + + GLfloat xSc, ySc, xPan, yPan; + xSc = paramsLst[0].toDouble(); + ySc = paramsLst[1].toDouble(); + xPan = paramsLst[2].toDouble(); + yPan = paramsLst[3].toDouble(); + + vp2d->getGLWidget()->setScale( xSc, ySc, 1. ); + vp2d->getGLWidget()->setPan( xPan, yPan, 0. ); + } } diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 67933dbae..dde345b4f 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -1926,3 +1926,43 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const return res; #endif } + +QString Plot2d_ViewFrame::getVisualParameters() +{ + double xmin, xmax, ymin, ymax, y2min, y2max; + getFitRanges( xmin, xmax, ymin, ymax, y2min, y2max ); + QString retStr; + retStr.sprintf( "%d*%d*%d*%.12f*%.12f*%.12f*%.12f*%.12f*%.12f", myXMode, + myYMode, mySecondY, xmin, xmax, ymin, ymax, y2min, y2max ); + return retStr; +} + +void Plot2d_ViewFrame::setVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( paramsLst.size() == 9 ) { + double xmin, xmax, ymin, ymax, y2min, y2max; + myXMode = paramsLst[0].toInt(); + myYMode = paramsLst[1].toInt(); + mySecondY = (bool)paramsLst[2].toInt(); + xmin = paramsLst[3].toDouble(); + xmax = paramsLst[4].toDouble(); + ymin = paramsLst[5].toDouble(); + ymax = paramsLst[6].toDouble(); + y2min = paramsLst[7].toDouble(); + y2max = paramsLst[8].toDouble(); + + if (mySecondY) + setTitle( myY2TitleEnabled, myY2Title, Y2Title, false ); + setHorScaleMode( myXMode, /*update=*/false ); + setVerScaleMode( myYMode, /*update=*/false ); + + if (mySecondY) { + QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); + myYDistance2 = yMap2.d2() - yMap2.d1(); + } + + fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max ); + fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max ); + } +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 51faa0898..5d1faccb5 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -118,6 +118,9 @@ public: virtual bool print( const QString& file, const QString& format ) const; + QString getVisualParameters(); + void setVisualParameters( const QString& parameters ); + protected: int testOperation( const QMouseEvent& ); void readPreferences(); diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 7d21b50ca..017e8fada 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -470,11 +470,12 @@ QString Plot2d_ViewWindow::filter() const */ QString Plot2d_ViewWindow::getVisualParameters() { - return " "; + return myViewFrame->getVisualParameters(); } /* The method restors visual parameters of this view from a formated string */ void Plot2d_ViewWindow::setVisualParameters( const QString& parameters ) { + myViewFrame->setVisualParameters( parameters ); }