Back to index

salome-gui  6.5.0
Plot2d.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 
00023 // File   : Plot2d.h
00024 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00025 //
00026 #ifndef PLOT2D_H
00027 #define PLOT2D_H
00028 
00029 #ifdef WIN32
00030 #  if defined PLOT2D_EXPORTS || defined Plot2d_EXPORTS
00031 #    define PLOT2D_EXPORT __declspec(dllexport)
00032 #  else
00033 #    define PLOT2D_EXPORT __declspec(dllimport)
00034 #  endif
00035 #else
00036 #  define PLOT2D_EXPORT
00037 #endif
00038 
00039 #include <qwt_symbol.h>
00040 #include <Qt>
00041 
00042 class QPainter;
00043 class QwtPlot;
00044 
00045 // Properties on the deviation marker.
00046 #define PLOT2D_DEVIATION_COLOR "DEVIATION_COLOR"
00047 #define PLOT2D_DEVIATION_LW "DEVIATION_LW"
00048 #define PLOT2D_DEVIATION_TS "DEVIATION_TS"
00049 
00050 struct PLOT2D_EXPORT Plot2d_Point
00051 {
00052   double x;
00053   double y;
00054   double* deviationPtr;
00055   QString text;
00056   Plot2d_Point();
00057   Plot2d_Point( double theX, double theY, const QString& theText = QString() );
00058   ~Plot2d_Point();
00059   bool deviation(double& min, double& max) const;
00060   bool hasDeviation() const;
00061   void setDeviation(double min, double max);
00062   void clearDeviation();
00063   bool minDeviation(double& min) const;
00064   bool maxDeviation(double& max) const;
00065 };
00066 
00067 typedef QList<Plot2d_Point> pointList;
00068 
00069 
00070 namespace Plot2d
00071 {
00072   typedef enum { None, 
00073                  Circle,  
00074                  Rectangle,
00075                  Diamond,
00076                  DTriangle,
00077                  UTriangle,
00078                  LTriangle,
00079                  RTriangle,
00080                  Cross,
00081                  XCross
00082   } MarkerType;
00083 
00084   typedef enum {
00085     NoPen,
00086     Solid, 
00087     Dash, 
00088     Dot, 
00089     DashDot, 
00090     DashDotDot
00091   } LineType;
00092 
00093   QwtSymbol::Style         plot2qwtMarker( MarkerType );
00094   MarkerType qwt2plotMarker( QwtSymbol::Style );
00095 
00096   Qt::PenStyle             plot2qwtLine( LineType );
00097   LineType                 qwt2plotLine( Qt::PenStyle );
00098 
00099   void                     drawLine( QPainter*, const QPoint&, const QPoint&, 
00100                                      Qt::PenStyle = Qt::SolidLine, 
00101                                      const QColor& = Qt::black, int = 0 );
00102   void                     drawLine( QPainter*, const QPoint&, const QPoint&, 
00103                                      LineType = Solid, 
00104                                      const QColor& = Qt::black, int = 0 );
00105   void                     drawLine( QPainter*, int, int, int, int,
00106                                      Qt::PenStyle = Qt::SolidLine, 
00107                                      const QColor& = Qt::black, int = 0 );
00108   void                     drawLine( QPainter*, int, int, int, int,
00109                                      LineType = Solid, 
00110                                      const QColor& = Qt::black, int = 0 );
00111 
00112   void                     drawMarker( QPainter*, const QPoint&, const QRect&,
00113                                        QwtSymbol::Style = QwtSymbol::Ellipse,
00114                                        const QColor& = Qt::black );
00115   void                     drawMarker( QPainter*, const QPoint&, const QRect&,
00116                                        MarkerType = Circle,
00117                                        const QColor& = Qt::black );
00118   void                     drawMarker( QPainter*, int, int, int, int,
00119                                        QwtSymbol::Style = QwtSymbol::Ellipse,
00120                                        const QColor& = Qt::black );
00121   void                     drawMarker( QPainter*, int, int, int, int,
00122                                        MarkerType = Circle,
00123                                        const QColor& = Qt::black );
00124   
00125   QPixmap                  markerIcon( const QSize&, const QColor&, 
00126                                   Plot2d::MarkerType );
00127 
00128   QPixmap                  lineIcon( const QSize&,  const QColor&, 
00129                                  Plot2d::LineType );
00130 
00131   void                     getNextMarker( const int rtti, const QwtPlot*, QwtSymbol::Style&,
00132                                      QColor&, Qt::PenStyle& );
00133   
00134   bool                     existMarker( const int rtti , const QwtPlot*, const QwtSymbol::Style,
00135                                    const QColor&, const Qt::PenStyle );
00136 
00137 
00138   bool                     closeColors( const QColor&, 
00139                                    const QColor&, 
00140                                    int distance = -1 );
00141 
00142 }
00143 
00144 #if defined WIN32
00145 #  pragma warning ( disable: 4251 )
00146 #endif
00147 
00148 #endif // PLOT2D_H