From ead5959b1a8d7ce3bad7f425729191ff083733b7 Mon Sep 17 00:00:00 2001 From: ana Date: Wed, 26 Oct 2011 12:16:10 +0000 Subject: [PATCH] Implementation of the "21384: [CEA 508] Plot2d Allow user to rescale curve" isuue. --- src/VISU_I/VISU_Table_i.cc | 29 +++++++++++++++++++++++++++++ src/VISU_I/VISU_Table_i.hh | 5 +++++ src/VISU_I/VISU_Tools.cxx | 1 + src/VISU_I/VISU_ViewManager_i.cc | 1 + 4 files changed, 36 insertions(+) diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 66c97581..852f1404 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -520,6 +520,7 @@ VISU::Curve_i::Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, myLineWidth = 0; myMarker = VISU::Curve::CIRCLE; myColor.R = 0.0; myColor.G = 0.0; myColor.B = 0.0; + myScale = 1.0; } /*! Destructor @@ -605,6 +606,31 @@ VISU::Curve_i return myLineWidth; } +//---------------------------------------------------------------------------- +void +VISU::Curve_i +::SetScale( CORBA::Double theCoef ) +{ + myScale = theCoef; + UpdatePlot2d( this, eUpdateData ); +} + +//---------------------------------------------------------------------------- +CORBA::Double +VISU::Curve_i +::GetScale() +{ + return myScale; +} + +//---------------------------------------------------------------------------- +void +VISU::Curve_i +::RemoveScale() +{ + SetScale( 1.0 ); +} + //---------------------------------------------------------------------------- /*! Creates curve object @@ -952,6 +978,8 @@ VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap, S QString v2_str = VISU::Storable::FindValue(theMap,"myIsV2", &ok); myIsV2 = ok ? v2_str.toInt() : false; + QString scale_str = VISU::Storable::FindValue(theMap,"myScale", &ok); + myScale = ok ? scale_str.toDouble() : 1.0; myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); @@ -971,6 +999,7 @@ void VISU::Curve_i::ToStream( std::ostringstream& theStr ) Storable::DataToStream( theStr, "myVRow", myVRow ); Storable::DataToStream( theStr, "myZRow", myZRow ); Storable::DataToStream( theStr, "myIsV2", myIsV2 ); + Storable::DataToStream( theStr, "myScale", myScale ); Storable::DataToStream( theStr, "myColor.R", myColor.R ); Storable::DataToStream( theStr, "myColor.G", myColor.G ); Storable::DataToStream( theStr, "myColor.B", myColor.B ); diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index 29a30b9c..c187a450 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -125,6 +125,10 @@ namespace VISU{ virtual VISU::Curve::LineType GetLine(); virtual CORBA::Long GetLineWidth(); + virtual void SetScale( CORBA::Double theCoef ); + virtual CORBA::Double GetScale(); + virtual void RemoveScale(); + virtual void addContainer(const QString& id); virtual void removeContainer(const QString& id); virtual ContainerSet getContainers() const; @@ -142,6 +146,7 @@ namespace VISU{ int myVRow; int myZRow; bool myIsV2; + double myScale; struct SALOMEDS::Color myColor; VISU::Curve::MarkerType myMarker; VISU::Curve::LineType myLine; diff --git a/src/VISU_I/VISU_Tools.cxx b/src/VISU_I/VISU_Tools.cxx index 2b9e98a4..f1eb0639 100644 --- a/src/VISU_I/VISU_Tools.cxx +++ b/src/VISU_I/VISU_Tools.cxx @@ -64,6 +64,7 @@ namespace VISU plotCurve->setVerTitle( theCurve->GetName().c_str() ); plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() ); plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() ); + plotCurve->setScale( theCurve->GetScale() ); double* xList = 0; double* yList = 0; QStringList zList; diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index cf359450..d87a546c 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -439,6 +439,7 @@ namespace VISU { !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { if (theDisplaying == eUpdateData) { if(MYDEBUG) MESSAGE("UpdatePlot2d - updating data : curve - " << aSPlot2dC); + aSPlot2dC->setScale(theCurve->GetScale()); } else { if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC); -- 2.39.2