Version: 6.3.1

src/Plot2d/Plot2d_Object.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : Plot2d_Object.h
00023 //  Author : Natalia ERMOLAEVA, Open CASCADE S.A.S. (natalia.donis@opencascade.com)
00024 //
00025 
00026 #ifndef PLOT2D_OBJECT_H
00027 #define PLOT2D_OBJECT_H
00028 
00029 #include "Plot2d.h"
00030 
00031 #include <QList>
00032 #include <qwt_plot.h>
00033 
00034 struct PLOT2D_EXPORT Plot2d_Point
00035 {
00036   double x;
00037   double y;
00038   QString text;
00039   Plot2d_Point();
00040   Plot2d_Point( double theX, double theY, const QString& theText = QString() );
00041 };
00042 
00043 typedef QList<Plot2d_Point> pointList;
00044 
00045 class PLOT2D_EXPORT Plot2d_Object
00046 {
00047 public:
00048   Plot2d_Object();
00049   Plot2d_Object( const Plot2d_Object& );
00050 
00051   virtual ~Plot2d_Object();
00052   Plot2d_Object& operator= ( const Plot2d_Object& );
00053 
00054   virtual int          rtti() = 0;
00055   virtual QwtPlotItem* createPlotItem() = 0;
00056   virtual void         autoFill( const QwtPlot* );
00057   virtual void         updatePlotItem( QwtPlotItem* );
00058 
00059   virtual QString      getTableTitle() const;
00060   
00061   void                 setHorTitle( const QString& );
00062   QString              getHorTitle() const;
00063   void                 setVerTitle( const QString& );
00064   QString              getVerTitle() const;
00065 
00066   void                 setHorUnits( const QString& );
00067   QString              getHorUnits() const;
00068   void                 setVerUnits( const QString& );
00069   QString              getVerUnits() const;
00070 
00071   void                 setName( const QString& );
00072   QString              getName() const;
00073 
00074   void                 addPoint( double, double, const QString& = QString() );
00075   void                 addPoint( const Plot2d_Point& );
00076   void                 insertPoint( int, double, double, const QString& = QString() );
00077   void                 insertPoint( int, const Plot2d_Point& );
00078   void                 deletePoint( int );
00079   void                 clearAllPoints();
00080   pointList            getPointList() const;
00081   void                 setPointList( const pointList& points );
00082 
00083   void                 setData( const double*, const double*, 
00084                     long, const QStringList& = QStringList() );
00085   double*              horData() const;
00086   double*              verData() const;
00087   long                 getData( double**, double** ) const;
00088 
00089   void                 setText( const int, const QString& );
00090   QString              text( const int ) const;
00091 
00092   int                  nbPoints() const;
00093   bool                 isEmpty() const;
00094 
00095   void                 setAutoAssign( bool );
00096   bool                 isAutoAssign() const;
00097 
00098   void                 setXAxis( QwtPlot::Axis );
00099   QwtPlot::Axis        getXAxis() const;
00100   void                 setYAxis( QwtPlot::Axis );
00101   QwtPlot::Axis        getYAxis() const;
00102 
00103   // Protection against QwtObject::drawLines() bug in Qwt 0.4.x: 
00104   // it crashes if switched to X/Y logarithmic mode, when one or more points have
00105   // non-positive X/Y coordinate
00106   double               getMinX() const;
00107   double               getMaxX() const;
00108   double               getMinY() const;
00109   double               getMaxY() const;
00110 
00111   static bool          closeColors( const QColor&, const QColor&, int distance = -1 );
00112 
00113 protected:
00114   bool                 myAutoAssign;
00115   QString              myHorTitle;
00116   QString              myVerTitle;
00117   QString              myHorUnits;
00118   QString              myVerUnits;
00119   QString              myName;
00120   QwtPlot::Axis        myXAxis;
00121   QwtPlot::Axis        myYAxis;
00122 
00123   pointList            myPoints;
00124 };
00125 
00126 typedef QList<Plot2d_Object*> objectList;
00127 
00128 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS