Version: 6.3.1

src/Plot2d/Plot2d_PlotItems.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_HistogramItem.h
00023 //  Author : Natalia ERMOLAEVA, Open CASCADE S.A.S. (natalia.donis@opencascade.com)
00024 
00025 #ifndef PLOT2D_PLOTITEMS_H
00026 #define PLOT2D_PLOTITEMS_H
00027 
00028 #include "Plot2d.h"
00029 
00030 #include <qwt_legend_item.h>
00031 #include <qwt_plot_item.h>
00032 #include <qwt_plot_curve.h>
00033 #include <qwt_interval_data.h>
00034 #include <qwt_plot.h>
00035 
00036 class PLOT2D_EXPORT Plot2d_QwtLegendItem : public QwtLegendItem
00037 {
00038 public:
00039   enum YAxisIdentifierMode { IM_None = 0, IM_Left, IM_Right };
00040 
00041 public:
00042   Plot2d_QwtLegendItem( QWidget* = 0 );
00043   virtual ~Plot2d_QwtLegendItem();
00044 
00045 public:
00046   void             setYAxisIdentifierMode( const int );
00047 
00048 protected:
00049   virtual void     drawIdentifier( QPainter*, const QRect& ) const;
00050 
00051 private:
00052   int              myYAxisIdentifierMode;
00053   QPixmap          myYAxisLeftIcon;
00054   QPixmap          myYAxisRightIcon;
00055   int              mySpacingCollapsed;
00056   int              mySpacingExpanded;
00057 };
00058 
00059 class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve
00060 {
00061 public:
00062   Plot2d_QwtPlotCurve( const QString&, QwtPlot::Axis = QwtPlot::yLeft );
00063   virtual ~Plot2d_QwtPlotCurve();
00064 
00065 public:
00066   virtual void     setYAxisIdentifierEnabled( const bool );
00067 
00068 protected:
00069   virtual void     updateLegend( QwtLegend* ) const;
00070   virtual QWidget* legendItem() const;
00071 
00072 private:
00073   QwtPlot::Axis    myYAxis;
00074   bool             myYAxisIdentifierEnabled;
00075 };
00076 
00077 class PLOT2D_EXPORT Plot2d_HistogramQwtItem: public QwtPlotItem
00078 {
00079 public:
00080   enum HistogramAttribute 
00081   {
00082     Auto = 0,
00083     Xfy  = 1
00084   };
00085 
00086   explicit Plot2d_HistogramQwtItem( const QString& = QString() );
00087   explicit Plot2d_HistogramQwtItem( const QwtText& );
00088   virtual ~Plot2d_HistogramQwtItem();
00089 
00090   void                   setData( const QwtIntervalData& );
00091   const QwtIntervalData& data() const;
00092 
00093   void                   setColor( const QColor& );
00094   QColor                 color() const;
00095 
00096   virtual QwtDoubleRect  boundingRect() const;
00097   virtual int            rtti() const;
00098   virtual void           draw( QPainter*, const QwtScaleMap&, 
00099                       const QwtScaleMap&, const QRect& ) const;
00100 
00101   void                   setBaseline( double );
00102   double                 baseline() const;
00103 
00104   void                   setHistogramAttribute( HistogramAttribute, bool = true );
00105   bool                   testHistogramAttribute( HistogramAttribute ) const;
00106 
00107 protected:
00108   virtual void           drawBar( QPainter*, Qt::Orientation, const QRect& ) const;
00109 
00110 private:
00111   void                   init();
00112 
00113 private:
00114   int                    myAttributes;
00115   QwtIntervalData        myData;
00116   QColor                 myColor;
00117   double                 myReference;
00118 };
00119 
00120 class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem
00121 {
00122 public:
00123   explicit Plot2d_HistogramItem( const QString& = QString() );
00124   explicit Plot2d_HistogramItem( const QwtText& );
00125   virtual ~Plot2d_HistogramItem();
00126 
00127   QList<QRect>           getBars() const;
00128 
00129   virtual void           updateLegend( QwtLegend* ) const;
00130   virtual void           draw( QPainter*, const QwtScaleMap&, 
00131                       const QwtScaleMap&, const QRect& ) const;
00132 
00133   void                   setCrossItems( bool theCross );
00134   bool                   isCrossItems() const;
00135 
00136 protected:
00137   void                   drawRectAndLowers( QPainter*, Qt::Orientation,
00138                              const QRect& ) const;
00139   int                    getCrossedTop( const QRect& ) const;
00140 
00141 protected:
00142   QList<QRect>           myBarItems;
00143   bool                   myCrossed;
00144 };
00145 
00146 #endif // PLOT2D_PLOTITEMS_H
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