QtiPlot 0.9.7.3

Grid.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : Grid.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2007 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : 2D Grid class
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef GRID_H
00030 #define GRID_H
00031 
00032 #include <qwt_plot.h>
00033 #include <qwt_plot_grid.h>
00034 #include <qwt_plot_marker.h>
00035 
00036 class Grid : public QwtPlotGrid
00037 {
00038 public:
00039     Grid();
00040 
00041     bool xZeroLineEnabled(){return (mrkX != NULL)?true:false;};
00042     void enableZeroLineX(bool enable = true);
00043     bool yZeroLineEnabled(){return (mrkY != NULL)?true:false;};
00044     void enableZeroLineY(bool enable = true);
00045 
00046     void setMajPenX(const QPen &p){ setMajPen(p);};
00047     const QPen& majPenX() const {return majPen();};
00048 
00049     void setMinPenX(const QPen &p){ setMinPen(p);};
00050     const QPen& minPenX() const {return minPen();};
00051 
00052     void setMajPenY(const QPen &p){ if (d_maj_pen_y != p) d_maj_pen_y = p;};
00053     const QPen& majPenY() const {return d_maj_pen_y;};
00054 
00055     void setMinPenY(const QPen &p){ if (d_min_pen_y != p) d_min_pen_y = p;};
00056     const QPen& minPenY() const {return d_min_pen_y;};
00057 
00058     void load(const QStringList& );
00059     void copy(Grid *);
00060     QString saveToString();
00061 
00062     QwtPlotMarker *xZeroLineMarker(){return mrkX;};
00063     QwtPlotMarker *yZeroLineMarker(){return mrkY;};
00064 
00065     const QPen& xZeroLinePen();
00066     void setXZeroLinePen(const QPen &p);
00067     const QPen& yZeroLinePen();
00068     void setYZeroLinePen(const QPen &p);
00069 
00070 private:
00071     void draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &rect) const;
00072     void drawLines(QPainter *painter, const QRect &rect, Qt::Orientation orientation, const QwtScaleMap &map,
00073         const QwtValueList &values) const;
00074 
00075     QPen d_maj_pen_y;
00076     QPen d_min_pen_y;
00077 
00078     QwtPlotMarker *mrkX, *mrkY;//x=0 et y=0 line markers
00079 };
00080 
00081 #endif