From: ouv Date: Tue, 15 Jan 2013 10:35:58 +0000 (+0000) Subject: 0001481: External 20599, 20605: IMP, save views VTK, GL X-Git-Tag: CTH_1_9_2~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=91ecbe47b25c3265c9aeb618a6b763e337972d56;p=modules%2Fgui.git 0001481: External 20599, 20605: IMP, save views VTK, GL --- diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index 5a6035c5d..0a5961795 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -428,7 +428,11 @@ QString GLViewer_ViewFrame::getVisualParameters() GLfloat xSc, ySc, xPan, yPan; vp2d->getScale( xSc, ySc ); vp2d->getPan( xPan, yPan ); - retStr.sprintf( "%.12e*%.12e*%.12e*%.12e", xSc, ySc, xPan, yPan ); + + QColor aBgColor = vp2d->backgroundColor(); + int r = aBgColor.red(), g = aBgColor.green(), b = aBgColor.blue(); + + retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%d*%d*%d", xSc, ySc, xPan, yPan, r, g, b ); } return retStr; } @@ -439,7 +443,7 @@ QString GLViewer_ViewFrame::getVisualParameters() void GLViewer_ViewFrame::setVisualParameters( const QString& parameters ) { QStringList paramsLst = parameters.split( '*' ); - if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 4) { + if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 7) { GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP; GLfloat xSc, ySc, xPan, yPan; @@ -450,5 +454,10 @@ void GLViewer_ViewFrame::setVisualParameters( const QString& parameters ) vp2d->getGLWidget()->setScale( xSc, ySc, 1. ); vp2d->getGLWidget()->setPan( xPan, yPan, 0. ); + + int r = paramsLst[4].toInt(); + int g = paramsLst[5].toInt(); + int b = paramsLst[6].toInt(); + vp2d->setBackgroundColor( QColor( r, g, b ) ); } } diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index abfe67de3..e647b3c56 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -54,6 +54,7 @@ #include "QtxActionToolMgr.h" #include "QtxMultiAction.h" +#include "VTKViewer_Trihedron.h" #include "VTKViewer_Utilities.h" #include "SVTK_View.h" @@ -1306,6 +1307,12 @@ QString SVTK_ViewWindow::getVisualParameters() parScale = camera->GetParallelScale(); GetScale( scale ); + QColor aBgColor = backgroundColor(); + + int aThrihedronVisibility = VTKViewer_Trihedron::eOn; + if( VTKViewer_Trihedron* aTrihedron = GetTrihedron() ) + aThrihedronVisibility = (int)aTrihedron->GetVisibility(); + // Parameters are given in the following format:view position (3 digits), focal point position (3 digits) // view up values (3 digits), parallel scale (1 digit), scale (3 digits, // Graduated axes parameters (X, Y, Z axes parameters) @@ -1351,6 +1358,16 @@ QString SVTK_ViewWindow::getVisualParameters() getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z"); } + aWriter.writeStartElement("BackgroundColor"); + aWriter.writeAttribute("R", QString::number(aBgColor.red())); + aWriter.writeAttribute("G", QString::number(aBgColor.green())); + aWriter.writeAttribute("B", QString::number(aBgColor.blue())); + aWriter.writeEndElement(); + + aWriter.writeStartElement("Trihedron"); + aWriter.writeAttribute("Visibility", QString::number(aThrihedronVisibility)); + aWriter.writeEndElement(); + aWriter.writeEndElement(); aWriter.writeEndDocument(); @@ -1391,6 +1408,7 @@ void SVTK_ViewWindow::setVisualParameters( const QString& parameters ) void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters ) { double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + QColor aBgColor; QXmlStreamReader aReader(parameters); SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes(); @@ -1433,6 +1451,14 @@ void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters ) setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D()); else if(aAttr.value("Axis") == "Z") setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D()); + } else if (aReader.name() == "BackgroundColor") { + aBgColor.setRed(aAttr.value("R").toString().toInt()); + aBgColor.setGreen(aAttr.value("G").toString().toInt()); + aBgColor.setBlue(aAttr.value("B").toString().toInt()); + } else if (aReader.name() == "Trihedron") { + int aThrihedronVisibility = aAttr.value("Visibility").toString().toInt(); + if( VTKViewer_Trihedron* aTrihedron = GetTrihedron() ) + aTrihedron->SetVisibility((VTKViewer_Trihedron::TVisibility)aThrihedronVisibility); } } } @@ -1443,6 +1469,7 @@ void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters ) camera->SetViewUp( viewUp ); camera->SetParallelScale( parScale ); SetScale( scale ); + setBackgroundColor( aBgColor ); } else { QStringList paramsLst = parameters.split( '*' ); if ( paramsLst.size() >= nNormalParams ) {