Back to index

salome-gui  6.5.0
Plot2d_Object.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 
00035 class PLOT2D_EXPORT Plot2d_Object
00036 {
00037 public:
00038   Plot2d_Object();
00039   Plot2d_Object( const Plot2d_Object& );
00040 
00041   virtual ~Plot2d_Object();
00042   Plot2d_Object& operator= ( const Plot2d_Object& );
00043 
00044   virtual int          rtti() = 0;
00045   virtual QwtPlotItem* createPlotItem() = 0;
00046   virtual void         autoFill( const QwtPlot* );
00047   virtual void         updatePlotItem( QwtPlotItem* );
00048 
00049   virtual QString      getTableTitle() const;
00050   
00051   void                 setHorTitle( const QString& );
00052   QString              getHorTitle() const;
00053   void                 setVerTitle( const QString& );
00054   QString              getVerTitle() const;
00055 
00056   void                 setHorUnits( const QString& );
00057   QString              getHorUnits() const;
00058   void                 setVerUnits( const QString& );
00059   QString              getVerUnits() const;
00060 
00061   void                 setName( const QString& );
00062   QString              getName() const;
00063 
00064   void                 setScale( double );
00065   double               getScale() const;
00066 
00067   void                 addPoint( double, double, const QString& = QString() );
00068   void                 addPoint( const Plot2d_Point& );
00069   void                 insertPoint( int, double, double, const QString& = QString() );
00070   void                 insertPoint( int, const Plot2d_Point& );
00071   void                 deletePoint( int );
00072   void                 clearAllPoints();
00073   pointList            getPointList() const;
00074   void                 setPointList( const pointList& points );
00075   Plot2d_Point&        getPoint(int index);
00076 
00077   void                 setData( const double*, const double*, 
00078                             long, const QStringList& = QStringList() );
00079   double*              horData() const;
00080   double*              verData() const;
00081   long                 getData( double**, double** ) const;
00082 
00083   void                 setText( const int, const QString& );
00084   QString              text( const int ) const;
00085 
00086   int                  nbPoints() const;
00087   bool                 isEmpty() const;
00088 
00089   void                 setAutoAssign( bool );
00090   bool                 isAutoAssign() const;
00091 
00092   void                 setXAxis( QwtPlot::Axis );
00093   QwtPlot::Axis        getXAxis() const;
00094   void                 setYAxis( QwtPlot::Axis );
00095   QwtPlot::Axis        getYAxis() const;
00096 
00097   // Protection against QwtObject::drawLines() bug in Qwt 0.4.x: 
00098   // it crashes if switched to X/Y logarithmic mode, when one or more points have
00099   // non-positive X/Y coordinate
00100   virtual double          getMinX() const;
00101   virtual double          getMaxX() const;
00102   virtual double          getMinY() const;
00103   virtual double          getMaxY() const;
00104   
00105   void                 setSelected(const bool);
00106   bool                 isSelected() const;
00107   
00108   static void initColors();
00109   
00110   static void   setSelectionColor(const QColor& c);
00111   static QColor selectionColor();
00112 
00113   static void   setHighlightedLegendTextColor(const QColor& c);
00114   static QColor highlightedLegendTextColor();
00115 
00116 protected:
00117   bool                 myAutoAssign;
00118   QString              myHorTitle;
00119   QString              myVerTitle;
00120   QString              myHorUnits;
00121   QString              myVerUnits;
00122   QString              myName;
00123   QwtPlot::Axis        myXAxis;
00124   QwtPlot::Axis        myYAxis;
00125 
00126   double               myScale;
00127 
00128   pointList            myPoints;
00129   bool                 myIsSelected;
00130 
00131  private:
00132   static QColor mySelectionColor;            
00133   static QColor myHighlightedLegendTextColor;  
00134 };
00135 
00136 typedef QList<Plot2d_Object*> objectList;
00137 
00138 #endif