From e14b5d5eec8c5c979007e58971357eb092514e53 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 26 Dec 2007 08:09:10 +0000 Subject: [PATCH] Apends parameter for curve name. --- src/Plot2d/Plot2d_Curve.cxx | 18 ++++++++++++++++++ src/Plot2d/Plot2d_Curve.h | 4 ++++ src/Plot2d/Plot2d_ViewFrame.cxx | 9 ++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 7224d857f..0116e249a 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -29,6 +29,7 @@ Plot2d_Curve::Plot2d_Curve() : myHorTitle( "" ), myVerTitle( "" ), myHorUnits( "" ), myVerUnits( "" ), + myName( "" ), myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Plot2d::Circle ), @@ -55,6 +56,7 @@ Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve ) myVerTitle = curve.getVerTitle(); myHorUnits = curve.getHorUnits(); myVerUnits = curve.getVerUnits(); + myName = curve.getName(); myColor = curve.getColor(); myMarker = curve.getMarker(); myLine = curve.getLine(); @@ -72,6 +74,7 @@ Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve ) myVerTitle = curve.getVerTitle(); myHorUnits = curve.getHorUnits(); myVerUnits = curve.getVerUnits(); + myName = curve.getName(); myColor = curve.getColor(); myMarker = curve.getMarker(); myLine = curve.getLine(); @@ -152,6 +155,21 @@ QString Plot2d_Curve::getVerUnits() const return myVerUnits; } +/*! + Sets curve's name + */ +void Plot2d_Curve::setName( const QString& theName ) +{ + myName = theName; +} +/*! + Gets curve's name + */ +QString Plot2d_Curve::getName() const +{ + return myName; +} + /*! Adds one point for curve. */ diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index 3474a56b7..e73f5a192 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -59,6 +59,9 @@ public: void setVerUnits( const QString& ); QString getVerUnits() const; + void setName( const QString& ); + QString getName() const; + void addPoint( double, double, const QString& = QString() ); void insertPoint( int, double, double, const QString& = QString() ); void deletePoint( int ); @@ -104,6 +107,7 @@ protected: QString myVerTitle; QString myHorUnits; QString myVerUnits; + QString myName; QColor myColor; Plot2d::MarkerType myMarker; Plot2d::LineType myLine; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 5afc21af0..7cfd97679 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -546,7 +546,8 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) updateCurve( curve, update ); } else { - QwtPlotCurve* aPCurve = new QwtPlotCurve( curve->getVerTitle() ); + QwtPlotCurve* aPCurve = new QwtPlotCurve( !curve->getName().isEmpty() ? + curve->getName() : curve->getVerTitle() ); aPCurve->attach( myPlot ); //myPlot->setCurveYAxis(curveKey, curve->getYAxis()); @@ -655,7 +656,8 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) QSize( myMarkerSize, myMarkerSize ) ) ); aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() ); } - aPCurve->setTitle( curve->getVerTitle() ); + aPCurve->setTitle( !curve->getName().isEmpty() ? curve->getName() : + curve->getVerTitle() ); aPCurve->setVisible( true ); if ( update ) myPlot->replot(); @@ -707,7 +709,8 @@ void Plot2d_ViewFrame::updateLegend( const Plot2d_Prs* prs ) for (; it != aCurves.end(); ++it ) { aCurve = *it; if ( hasPlotCurve( aCurve ) ) - getPlotCurve( aCurve )->setTitle( aCurve->getVerTitle() ); + getPlotCurve( aCurve )->setTitle( !aCurve->getName().isEmpty() ? + aCurve->getName() : aCurve->getVerTitle() ); } } -- 2.39.2