00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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