*/
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. );
+ }
}
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 );
+ }
+}