-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : Plot2d_Curve.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#include "Plot2d_Curve.h"
-#include <qcolor.h>
+#include <QColor>
/*!
Constructor
*/
Plot2d_Curve::Plot2d_Curve()
: myHorTitle( "" ), myVerTitle( "" ),
-myHorUnits( "" ), myVerUnits( "" ),
-myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 ),
-myYAxis( QwtPlot::yLeft )
+ myHorUnits( "" ), myVerUnits( "" ),
+ myAutoAssign( true ),
+ myColor( 0,0,0 ),
+ myMarker( Plot2d::Circle ),
+ myLine( Plot2d::Solid ),
+ myLineWidth( 0 ),
+ myYAxis( QwtPlot::yLeft )
{
}
return *this;
}
+/*!
+ \return title of table
+*/
QString Plot2d_Curve::getTableTitle() const
{
return QString();
/*!
Adds one point for curve.
*/
-void Plot2d_Curve::addPoint(double theX, double theY)
+void Plot2d_Curve::addPoint(double theX, double theY, const QString& txt )
{
Plot2d_Point aPoint;
aPoint.x = theX;
aPoint.y = theY;
+ aPoint.text = txt;
myPoints.append(aPoint);
}
/*!
Insert one point for curve on some position.
*/
-void Plot2d_Curve::insertPoint(int thePos, double theX, double theY)
+void Plot2d_Curve::insertPoint(int thePos, double theX, double theY, const QString& txt)
{
Plot2d_Point aPoint;
aPoint.x = theX;
aPoint.y = theY;
+ aPoint.text = txt;
- QValueList<Plot2d_Point>::iterator aIt;
+ pointList::iterator aIt;
int aCurrent = 0;
for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
if (thePos == aCurrent) {
*/
void Plot2d_Curve::deletePoint(int thePos)
{
- QValueList<Plot2d_Point>::iterator aIt;
- int aCurrent = 0;
- for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
- if (thePos == aCurrent) {
- myPoints.remove(aIt);
- return;
- }
- aCurrent++;
- }
+ if ( thePos >= 0 && thePos < myPoints.count() )
+ myPoints.removeAt( thePos );
}
/*!
/*!
Sets curve's data.
*/
-void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
+void Plot2d_Curve::setData( const double* hData, const double* vData, long size, const QStringList& lst )
{
clearAllPoints();
- for(long i = 0; i < size; i++) addPoint(hData[i], vData[i]);
+ QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();
+ for( long i = 0; i < size; i++, anIt++ )
+ addPoint( hData[i], vData[i], anIt==aLast ? QString() : *anIt );
}
/*!
/*!
Sets curve's marker ( and resets AutoAssign flag )
*/
-void Plot2d_Curve::setMarker( MarkerType marker )
+void Plot2d_Curve::setMarker( Plot2d::MarkerType marker )
{
myMarker = marker;
myAutoAssign = false;
/*!
Gets curve's marker
*/
-Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
+Plot2d::MarkerType Plot2d_Curve::getMarker() const
{
return myMarker;
}
algorithm for diagonals.
For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
*/
-void Plot2d_Curve::setLine( LineType line, const int lineWidth )
+void Plot2d_Curve::setLine( Plot2d::LineType line, const int lineWidth )
{
myLine = line;
myLineWidth = lineWidth;
/*!
Gets curve's line type
*/
-Plot2d_Curve::LineType Plot2d_Curve::getLine() const
+Plot2d::LineType Plot2d_Curve::getLine() const
{
return myLine;
}
{
return myYAxis;
}
+
+/*!
+ Gets curve's minimal abscissa
+*/
+double Plot2d_Curve::getMinX() const
+{
+ pointList::const_iterator aIt;
+ double aMinX = 1e150;
+ //int aCurrent = 0;
+ for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
+ if ( (*aIt).x < aMinX )
+ aMinX = (*aIt).x;
+ }
+ return aMinX;
+}
+
+/*!
+ Gets curve's minimal ordinate
+*/
+double Plot2d_Curve::getMinY() const
+{
+ pointList::const_iterator aIt;
+ double aMinY = 1e150;
+ //int aCurrent = 0;
+ for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
+ if ( (*aIt).y < aMinY )
+ aMinY = (*aIt).y;
+ }
+ return aMinY;
+}
+
+/*!
+ Changes text assigned to point of curve
+ \param ind -- index of point
+ \param txt -- new text
+*/
+void Plot2d_Curve::setText( const int ind, const QString& txt )
+{
+ if( ind<0 || ind>=myPoints.count() )
+ return;
+
+ myPoints[ind].text = txt;
+}
+
+/*!
+ \return text assigned to point
+ \param ind -- index of point
+*/
+QString Plot2d_Curve::text( const int ind ) const
+{
+ if( ind<0 || ind>=myPoints.count() )
+ return QString();
+ else
+ return myPoints[ind].text;
+}