1 /*************************************************************************** 2 File : Grid.h 3 Project : QtiPlot 4 -------------------------------------------------------------------- 5 Copyright : (C) 2007 by Ion Vasilief 6 Email (use @ for *) : ion_vasilief*yahoo.fr 7 Description : 2D Grid class 8 9 ***************************************************************************/ 10 11 /*************************************************************************** 12 * * 13 * This program is free software; you can redistribute it and/or modify * 14 * it under the terms of the GNU General Public License as published by * 15 * the Free Software Foundation; either version 2 of the License, or * 16 * (at your option) any later version. * 17 * * 18 * This program is distributed in the hope that it will be useful, * 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 * GNU General Public License for more details. * 22 * * 23 * You should have received a copy of the GNU General Public License * 24 * along with this program; if not, write to the Free Software * 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 26 * Boston, MA 02110-1301 USA * 27 * * 28 ***************************************************************************/ 29 #ifndef GRID_H 30 #define GRID_H 31 32 #include <qwt_plot.h> 33 #include <qwt_plot_grid.h> 34 #include <qwt_plot_marker.h> 35 36 class Grid : public QwtPlotGrid 37 { 38 public: 39 Grid(); 40 xZeroLineEnabled()41 bool xZeroLineEnabled(){return (mrkX != NULL)?true:false;}; 42 void enableZeroLineX(bool enable = true); yZeroLineEnabled()43 bool yZeroLineEnabled(){return (mrkY != NULL)?true:false;}; 44 void enableZeroLineY(bool enable = true); 45 setMajPenX(const QPen & p)46 void setMajPenX(const QPen &p){ setMajPen(p);}; majPenX()47 const QPen& majPenX() const {return majPen();}; 48 setMinPenX(const QPen & p)49 void setMinPenX(const QPen &p){ setMinPen(p);}; minPenX()50 const QPen& minPenX() const {return minPen();}; 51 setMajPenY(const QPen & p)52 void setMajPenY(const QPen &p){ if (d_maj_pen_y != p) d_maj_pen_y = p;}; majPenY()53 const QPen& majPenY() const {return d_maj_pen_y;}; 54 setMinPenY(const QPen & p)55 void setMinPenY(const QPen &p){ if (d_min_pen_y != p) d_min_pen_y = p;}; minPenY()56 const QPen& minPenY() const {return d_min_pen_y;}; 57 58 void load(const QStringList& ); 59 void copy(Grid *); 60 QString saveToString(); 61 xZeroLineMarker()62 QwtPlotMarker *xZeroLineMarker(){return mrkX;}; yZeroLineMarker()63 QwtPlotMarker *yZeroLineMarker(){return mrkY;}; 64 65 const QPen& xZeroLinePen(); 66 void setXZeroLinePen(const QPen &p); 67 const QPen& yZeroLinePen(); 68 void setYZeroLinePen(const QPen &p); 69 70 private: 71 void draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &rect) const; 72 void drawLines(QPainter *painter, const QRect &rect, Qt::Orientation orientation, const QwtScaleMap &map, 73 const QwtValueList &values) const; 74 75 QPen d_maj_pen_y; 76 QPen d_min_pen_y; 77 78 QwtPlotMarker *mrkX, *mrkY;//x=0 et y=0 line markers 79 }; 80 81 #endif 82