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 #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