Plot.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : Plot.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
00007     Description          : Plot window 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 PLOT_H
00030 #define PLOT_H
00031 
00032 #include <QObject>
00033 #include <QMap>
00034 #include <QLocale>
00035 
00036 #include <qwt_plot.h>
00037 #include <qwt_plot_curve.h>
00038 #include <qwt_plot_grid.h>
00039 #include <qwt_plot_marker.h>
00040 
00041 class Grid;
00042 
00044 class Plot: public QwtPlot
00045 {
00046     Q_OBJECT
00047 
00048 public:
00049     Plot(QWidget *parent = 0, const char *name = 0);
00050 
00051     enum LabelFormat{Automatic, Decimal, Scientific, Superscripts};
00052 
00053     Grid *grid(){return (Grid *)d_grid;};
00054     QList<int> curveKeys(){return d_curves.keys();};
00055     QList<QwtPlotItem *> curvesList(){return d_curves.values();};
00056 
00057     int insertCurve(QwtPlotItem *c);
00058     void removeCurve(int index);
00059 
00060     int closestCurve(int xpos, int ypos, int &dist, int &point);
00061     QwtPlotCurve* curve(int index);
00062     QwtPlotItem* plotItem(int index){return d_curves.value(index);};
00063     QMap<int, QwtPlotItem*> curves(){return d_curves;};
00064 
00065     QwtPlotMarker* marker(int index){return d_markers.value(index);};
00066     QList<int> markerKeys(){return d_markers.keys();};
00067     int insertMarker(QwtPlotMarker *m);
00068     void removeMarker(int index);
00069 
00070     QList<int> getMajorTicksType();
00071     void setMajorTicksType(int axis, int type);
00072 
00073     QList<int> getMinorTicksType();
00074     void setMinorTicksType(int axis, int type);
00075 
00076     int minorTickLength() const;
00077     int majorTickLength() const;
00078     void setTickLength (int minLength, int majLength);
00079 
00080     int axesLinewidth() const;
00081     void setAxesLinewidth(int width);
00082 
00083     void setAxisLabelFormat(int axis, char f, int prec);
00084     void axisLabelFormat(int axis, char &f, int &prec) const;
00085 
00086     int axisLabelFormat(int axis);
00087     int axisLabelPrecision(int axis);
00088 
00089     void printFrame(QPainter *painter, const QRect &rect) const;
00090 
00091     QColor frameColor();
00092     const QColor & paletteBackgroundColor() const;
00093 
00094     void print(QPainter *, const QRect &rect, const QwtPlotPrintFilter & = QwtPlotPrintFilter());
00095     void updateLayout();
00096 
00097     QLocale locale(){return d_locale;};
00098     void setLocale(const QLocale & l){d_locale = l;};
00099 
00100     void setSVGMode(bool on = true){d_SVG_mode = on;};
00101 
00102     void updateCurveLabels();
00103 
00104 protected:
00105     void showEvent (QShowEvent * event);
00106     void printCanvas(QPainter *painter, const QRect &canvasRect,
00107              const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const;
00108 
00109     virtual void drawItems (QPainter *painter, const QRect &rect,
00110             const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const;
00111 
00112     void drawInwardTicks(QPainter *painter, const QRect &rect,
00113                             const QwtScaleMap&map, int axis, bool min, bool maj) const;
00114     Grid *d_grid;
00115     QMap<int, QwtPlotItem*> d_curves;
00116     QMap<int, QwtPlotMarker*> d_markers;
00117 
00118     int minTickLength, majTickLength;
00119     int marker_key;
00120     int curve_key;
00121     QLocale d_locale;
00122 
00124     bool d_SVG_mode;
00125 };
00126 #endif

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4