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 
00035 #include <qwt_plot.h>
00036 #include <qwt_plot_curve.h>
00037 #include <qwt_plot_grid.h>
00038 #include <qwt_plot_marker.h>
00039 
00040 class Grid;
00041 
00043 class Plot: public QwtPlot
00044 {
00045     Q_OBJECT
00046 
00047 public:
00048     Plot(QWidget *parent = 0, const char *name = 0);
00049 
00050     enum LabelFormat{Automatic, Decimal, Scientific, Superscripts};
00051 
00052     QwtPlotGrid *grid(){return (QwtPlotGrid *)d_grid;};
00053     QList<int> curveKeys(){return d_curves.keys();};
00054     QList<QwtPlotItem *> curvesList(){return d_curves.values();};
00055     
00056     int insertCurve(QwtPlotItem *c);
00057     void removeCurve(int index);
00058 
00059     int closestCurve(int xpos, int ypos, int &dist, int &point);
00060     QwtPlotCurve* curve(int index);
00061     QwtPlotItem* plotItem(int index){return d_curves.value(index);};
00062     QMap<int, QwtPlotItem*> curves(){return d_curves;};
00063 
00064     QwtPlotMarker* marker(int index){return d_markers.value(index);};
00065     QList<int> markerKeys(){return d_markers.keys();};
00066     int insertMarker(QwtPlotMarker *m);
00067     void removeMarker(int index);
00068 
00069     QList<int> getMajorTicksType();
00070     void setMajorTicksType(int axis, int type);
00071 
00072     QList<int> getMinorTicksType();
00073     void setMinorTicksType(int axis, int type);
00074 
00075     int minorTickLength() const;
00076     int majorTickLength() const;
00077     void setTickLength (int minLength, int majLength);
00078 
00079     int axesLinewidth() const;
00080     void setAxesLinewidth(int width);
00081 
00082     void setAxisLabelFormat(int axis, char f, int prec);
00083     void axisLabelFormat(int axis, char &f, int &prec) const;
00084 
00085     int axisLabelFormat(int axis);
00086     int axisLabelPrecision(int axis);
00087 
00088     void printFrame(QPainter *painter, const QRect &rect) const;
00089 
00090     QColor frameColor();
00091     const QColor & paletteBackgroundColor() const;
00092 
00093     void print(QPainter *, const QRect &rect, const QwtPlotPrintFilter & = QwtPlotPrintFilter());
00094     void updateLayout();
00095 
00096 protected:
00097     void printCanvas(QPainter *painter, const QRect &canvasRect,
00098              const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const;
00099 
00100     virtual void drawItems (QPainter *painter, const QRect &rect,
00101             const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const;
00102 
00103     void drawInwardTicks(QPainter *painter, const QRect &rect,
00104                             const QwtScaleMap&map, int axis, bool min, bool maj) const;
00105     Grid *d_grid;
00106     QMap<int, QwtPlotItem*> d_curves;
00107     QMap<int, QwtPlotMarker*> d_markers;
00108 
00109     int minTickLength, majTickLength;
00110     int marker_key;
00111     int curve_key;
00112 };
00113 
00114 class Grid : public QwtPlotGrid
00115 {
00116 public:
00117     Grid(){};
00118 
00119 void draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &rect) const;
00120 void drawLines(QPainter *painter, const QRect &rect, Qt::Orientation orientation, const QwtScaleMap &map,
00121     const QwtValueList &values) const;
00122 };
00123 
00124 #endif

Generated on Mon Oct 15 06:11:42 2007 for QtiPlot by  doxygen 1.5.3