00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef PLOT_H
00019 #define PLOT_H
00020
00021 #include <qobject.h>
00022
00023 #include "odinqt.h"
00024
00025
00026 class QwtPlot;
00027 class QwtPlotCurve;
00028 class QwtPlotMarker;
00029 class QwtPlotGrid;
00030 class QRect;
00031 class QwtWheel;
00032 class QwtScaleDraw;
00033
00034 class GuiPlotPicker;
00035
00036
00037
00038 #if QT_VERSION >= 0x040000
00039 class QRectF;
00040 typedef QRectF QwtDoubleRect;
00041 #else
00042 class QwtDoubleRect;
00043 #endif
00044
00045
00046
00048
00052 class GuiPlot : public QObject {
00053 Q_OBJECT
00054
00055 public:
00056 GuiPlot(QWidget *parent, bool fixed_size=false, int width=_ARRAY_WIDGET_WIDTH_-20, int height=_ARRAY_WIDGET_HEIGHT_-20);
00057 ~GuiPlot();
00058
00059 void set_x_axis_label(const char *xAxisLabel, bool omit=false);
00060 void set_y_axis_label(const char *yAxisLabelLeft, const char *yAxisLabelRight=0);
00061
00062 long insert_curve(bool use_right_y_axis=false, bool draw_spikes=false, bool baseline=false);
00063
00064 long insert_marker(const char* label, double x, bool outline=false, bool horizontal=false, bool animate=false);
00065
00066 void remove_marker(long id);
00067
00068 void set_marker_pos(long id, double x);
00069
00070
00071 void set_curve_data(long curveid, const double* x, const double* y, int n, bool symbol=false);
00072
00073 void replot();
00074
00075 void autoscale();
00076
00077 void autoscale_y(double& maxBound);
00078
00079 void rescale_y(double maxBound);
00080
00081 void clear();
00082
00083 void remove_markers();
00084
00085 double get_x(int x_pixel) const;
00086 double get_y(int y_pixel, bool right_axes=false) const;
00087
00088 long closest_curve(int x, int y, int& dist) const;
00089
00090 void highlight_curve(long id, bool flag);
00091
00092 void set_x_axis_scale(double lbound, double ubound);
00093 void set_y_axis_scale(double lbound, double ubound, bool right_axes=false);
00094
00095 void set_curve_pen(long id, const char* color, int width=1);
00096
00097 void set_rect_outline_style();
00098 void set_line_outline_style(bool horizontal);
00099
00100 void enable_axes(bool flag);
00101 void enable_grid(bool flag);
00102
00103 void print(QPainter* painter, const QRect& rect) const;
00104
00105
00106 QWidget* get_widget();
00107
00108 signals:
00109 void plotMousePressed(const QMouseEvent&);
00110 void plotMouseReleased(const QMouseEvent&);
00111 void plotMouseMoved(const QMouseEvent&);
00112
00113 private slots:
00114 void emit_plotMousePressed(const QMouseEvent& qme);
00115 void emit_plotMouseReleased(const QMouseEvent& qme);
00116 void emit_plotMouseMoved(const QMouseEvent& qme);
00117
00118
00119 private:
00120 friend class GuiPlotPicker;
00121
00122 void set_axis_label(int axisId, const char* label, bool omit, int alignment);
00123
00124 QwtPlot* qwtplotter;
00125
00126 GuiPlotPicker* picker;
00127
00128
00129
00130 QwtPlotCurve* get_curve(long id);
00131 QwtPlotMarker* get_marker(long id);
00132
00133
00134
00135 STD_map<long,QwtPlotCurve*> curve_map;
00136 STD_map<long,QwtPlotMarker*> marker_map;
00137
00138 QwtPlotGrid* plotgrid;
00139
00140 int canvas_framewidth;
00141
00142 long baseline_id_cache;
00143 };
00144
00146
00147
00151 class GuiWheel : public QObject {
00152 Q_OBJECT
00153
00154 public:
00155 GuiWheel(QWidget *parent);
00156 ~GuiWheel();
00157
00158 void set_range(double min, double max);
00159
00160 void set_value(double newval);
00161
00162 QWidget* get_widget();
00163
00164 signals:
00165 void valueChanged(double);
00166
00167 private slots:
00168 void emit_valueChanged(double newval);
00169
00170 private:
00171 QwtWheel* wheel;
00172
00173 };
00174
00175
00176 #endif