00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#ifndef QWT_PLOT_H
00013
#define QWT_PLOT_H
00014
00015
#include <qframe.h>
00016
#include "qwt_global.h"
00017
#include "qwt_array.h"
00018
#include "qwt_grid.h"
00019
#include "qwt_autoscl.h"
00020
#include "qwt_scldraw.h"
00021
#include "qwt_symbol.h"
00022
#include "qwt_curve.h"
00023
#include "qwt_marker.h"
00024
#include "qwt_legend.h"
00025
#include "qwt_plot_printfilter.h"
00026
#include "qwt_plot_classes.h"
00027
#include "qwt_plot_dict.h"
00028
00029
class QLabel;
00030
class QwtPlotLayout;
00031
class QwtScale;
00032
class QwtPlotItem;
00033
class QwtPlotCanvas;
00034
class QwtPlotPrintFilter;
00035
00085 class QWT_EXPORT QwtPlot:
public QFrame
00086 {
00087
friend class QwtPlotItem;
00088
friend class QwtPlotCanvas;
00089
friend class QwtPlotPrintFilter;
00090
00091 Q_OBJECT
00092
00093 Q_ENUMS( Axis Position )
00094
00095
00096 Q_PROPERTY(
bool autoReplot READ autoReplot WRITE setAutoReplot )
00097
00098
00099 Q_PROPERTY( QColor canvasBackground READ canvasBackground
00100 WRITE setCanvasBackground )
00101 Q_PROPERTY(
int canvasLineWidth READ canvasLineWidth
00102 WRITE setCanvasLineWidth )
00103
00104
00105 Q_PROPERTY(
bool xBottomAxis READ xBottomAxisEnabled
00106 WRITE enableXBottomAxis )
00107 Q_PROPERTY(
bool xTopAxis READ xTopAxisEnabled WRITE enableXTopAxis )
00108 Q_PROPERTY(
bool yLeftAxis READ yLeftAxisEnabled WRITE enableYLeftAxis )
00109 Q_PROPERTY(
bool yRightAxis READ yRightAxisEnabled WRITE enableYRightAxis )
00110
00111
00112 Q_PROPERTY( QString title READ title WRITE setTitle )
00113 Q_PROPERTY( QFont titleFont READ titleFont WRITE setTitleFont )
00114
00115
00116 Q_PROPERTY(
bool xGrid READ gridXEnabled WRITE enableGridX )
00117 Q_PROPERTY(
bool xMinGrid READ gridXMinEnabled WRITE enableGridX )
00118 Q_PROPERTY(
bool yGrid READ gridYEnabled WRITE enableGridY )
00119 Q_PROPERTY(
bool yMinGrid READ gridYMinEnabled WRITE enableGridY )
00120
00121
00122 Q_PROPERTY(
bool autoLegend READ autoLegend WRITE setAutoLegend )
00123 Q_PROPERTY( QFont legendFont READ legendFont WRITE setLegendFont )
00124 Q_PROPERTY( Position legendPosition READ legendPosition
00125 WRITE setLegendPosition)
00126
00127
public:
00129 enum Axis { yLeft, yRight, xBottom, xTop, axisCnt };
00131
00132
00133
00134
00135
00136 enum Position {
00137 Left = Qwt::Left,
00138 Right = Qwt::Right,
00139 Bottom = Qwt::Bottom,
00140 Top = Qwt::Top
00141 };
00142
00143 QwtPlot(QWidget *p = 0,
const char *name = 0);
00144 QwtPlot(
const QString &title, QWidget *p = 0,
const char *name = 0);
00145
virtual ~QwtPlot();
00146
00148 void enableXBottomAxis(
bool b) {enableAxis(xBottom,b);}
00150 bool xBottomAxisEnabled()
const {
return axisEnabled(xBottom);};
00152 void enableXTopAxis(
bool b) {enableAxis(xTop,b);}
00154 bool xTopAxisEnabled()
const {
return axisEnabled(xTop);};
00156 void enableYRightAxis(
bool b) {enableAxis(yRight,b);}
00158 bool yRightAxisEnabled()
const {
return axisEnabled(yRight);};
00160 void enableYLeftAxis(
bool b) {enableAxis(yLeft,b);}
00162 bool yLeftAxisEnabled()
const {
return axisEnabled(yLeft);};
00163
00164
void setAutoReplot(
bool tf = TRUE);
00165
bool autoReplot() const;
00166
00167
void print(QPaintDevice &p,
00168 const
QwtPlotPrintFilter & =
QwtPlotPrintFilter()) const;
00169 virtual
void print(QPainter *, const QRect &rect,
00170 const
QwtPlotPrintFilter & =
QwtPlotPrintFilter()) const;
00171
00172
00173 #ifndef QWT_NO_COMPAT
00174
00175
00176
void enableOutline(
bool tf);
00177
bool outlineEnabled() const;
00178
void setOutlineStyle(Qwt::Shape os);
00179 Qwt::Shape outlineStyle() const;
00180
void setOutlinePen(const QPen &pn);
00181 const QPen& outlinePen() const;
00182 #endif
00183
00184
00185
00186
QwtPlotLayout *plotLayout();
00187 const
QwtPlotLayout *plotLayout() const;
00188
00189
void setMargin(
int margin);
00190
int margin() const;
00191
00192
00193
00194
void setTitle(const QString &t);
00195 QString title() const;
00196
void setTitleFont (const QFont &f);
00197 QFont titleFont() const;
00198
00199 QLabel *titleLabel();
00200 const QLabel *titleLabel() const;
00201
00202
00203
00204
QwtPlotCanvas *canvas();
00205 const
QwtPlotCanvas *canvas() const;
00206
00207
void setCanvasBackground (const QColor &c);
00208 const QColor& canvasBackground() const;
00209
00210
void setCanvasLineWidth(
int w);
00211
int canvasLineWidth() const;
00212
00213 QwtPlotCurveIterator curveIterator() const;
00214 QwtPlotMarkerIterator markerIterator() const;
00215
00216
QwtDiMap canvasMap(
int axis) const;
00217
00218
double invTransform(
int axis,
int pos) const;
00219
int transform(
int axis,
double value) const;
00220
00221
00222
00223
long insertCurve(
QwtPlotCurve *);
00224
long insertCurve(const QString &title,
00225
int xAxis = xBottom,
int yAxis = yLeft);
00226
00227 QwtPlotCurve *curve(
long key);
00228 const QwtPlotCurve *curve(
long key) const;
00229
00230 QwtArray<
long> curveKeys() const;
00231
00232
long closestCurve(
int xpos,
int ypos,
int &dist) const;
00233
long closestCurve(
int xpos,
int ypos,
int &dist,
00234
double &xval,
double &yval,
int &index) const;
00235
00236
bool setCurveBaseline(
long key,
double ref);
00237
double curveBaseline(
long key) const;
00238
00239
bool setCurveRawData(
long key, const
double *x, const
double *y,
int size);
00240
bool setCurveData(
long key, const
double *x, const
double *y,
int size);
00241
bool setCurveData(
long key,
00242 const QwtArray<
double> &x, const QwtArray<
double> &y);
00243
bool setCurveData(
long key, const QwtArray<
QwtDoublePoint> &data);
00244
bool setCurveData(
long key, const
QwtData &data);
00245
00246
bool setCurveOptions(
long key,
int t);
00247
int curveOptions(
long key) const;
00248
00249
bool setCurvePen(
long key, const QPen &pen);
00250 QPen curvePen(
long key) const;
00251
00252
bool setCurveBrush(
long key, const QBrush &brush);
00253 QBrush curveBrush(
long key) const;
00254
00255
bool setCurveSplineSize(
long key,
int s);
00256
int curveSplineSize(
long key) const;
00257
00258
bool setCurveStyle(
long key,
int s,
int options = 0);
00259
int curveStyle(
long key) const;
00260
00261
bool setCurveSymbol(
long key, const
QwtSymbol &s);
00262
QwtSymbol curveSymbol(
long key) const;
00263
00264
bool setCurveTitle(
long key, const QString &s);
00265 QString curveTitle(
long key) const;
00266
00267
bool setCurveXAxis(
long key,
int axis);
00268
int curveXAxis(
long key) const;
00269
bool setCurveYAxis(
long key,
int axis);
00270
int curveYAxis(
long key) const;
00271
00272
void drawCurve(
long key,
int from = 0,
int to = -1);
00273
00274
00275
00276
void enableGridX(
bool tf = TRUE);
00277
void enableGridXMin(
bool tf = TRUE);
00278
void enableGridY(
bool tf = TRUE);
00279
void enableGridYMin(
bool tf = TRUE);
00280
00281
bool gridXEnabled() const;
00282
bool gridXMinEnabled() const;
00283
bool gridYEnabled() const;
00284
bool gridYMinEnabled() const;
00285
00286
void setGridXAxis(
int axis);
00287
int gridXAxis() const;
00288
void setGridYAxis(
int axis);
00289
int gridYAxis() const;
00290
00291
void setGridPen(const QPen &p);
00292
void setGridMajPen(const QPen &p);
00293 const QPen& gridMajPen() const;
00294
void setGridMinPen(const QPen &p);
00295 const QPen& gridMinPen() const;
00296
00297
QwtPlotGrid &grid();
00298 const
QwtPlotGrid &grid() const;
00299
00300
00301
00302
void setAxisAutoScale(
int axis);
00303
bool axisAutoScale(
int axis) const;
00304
00305
void enableAxis(
int axis,
bool tf = TRUE);
00306
bool axisEnabled(
int axis) const;
00307
00308
void changeAxisOptions(
int axis,
int opt,
bool value);
00309
void setAxisOptions(
int axis,
int opt);
00310
int axisOptions(
int axis) const;
00311
00312
void setAxisFont(
int axis, const QFont &f);
00313 QFont axisFont(
int axis) const;
00314
00315
void setAxisMargins(
int axis,
double mlo,
double mhi);
00316
bool axisMargins(
int axis,
double &mlo,
double &mhi) const;
00317
00318
void setAxisScale(
int axis,
double min,
double max,
double step = 0);
00319
void setAxisScaleDraw(
int axis,
QwtScaleDraw *);
00320 const
QwtScaleDiv *axisScale(
int axis) const;
00321 const QwtScaleDraw *axisScaleDraw(
int axis) const;
00322 const
QwtScale *axis(
int axis) const;
00323
00324
void setAxisLabelFormat(
int axis,
char f,
int prec,
int fieldwidth = 0);
00325
void axisLabelFormat(
int axis,
char &f,
int &prec,
int &fieldwidth) const;
00326
00327
void setAxisLabelAlignment(
int axis,
int alignment);
00328
void setAxisLabelRotation(
int axis,
double rotation);
00329
00330
void setAxisTitle(
int axis, const QString &t);
00331 QString axisTitle(
int axis) const;
00332
void setAxisTitleFont(
int axis, const QFont &f);
00333 QFont axisTitleFont(
int axis) const;
00334
void setAxisTitleAlignment(
int axis,
int align);
00335
int axisTitleAlignment(
int axis) const;
00336
00337
void setAxisMaxMinor(
int axis,
int maxMinor);
00338
int axisMaxMajor(
int axis) const;
00339
void setAxisMaxMajor(
int axis,
int maxMajor);
00340
int axisMaxMinor(
int axis) const;
00341
00342
void setAxisReference(
int axis,
double value);
00343
double axisReference(
int axis) const;
00344
00345
00346
00347
long insertMarker(
QwtPlotMarker *);
00348
long insertMarker(const QString &label = QString::null,
00349
int xAxis = xBottom,
int yAxis = yLeft);
00350
long insertLineMarker(const QString &label,
int axis);
00351
00352 QwtPlotMarker *marker(
long key);
00353 const QwtPlotMarker *marker(
long key) const;
00354
00355
long closestMarker(
int xpos,
int ypos,
int &dist) const;
00356 QwtArray<
long> markerKeys() const;
00357
00358
bool setMarkerXAxis(
long key,
int axis);
00359
int markerXAxis(
long key) const;
00360
bool setMarkerYAxis(
long key,
int axis);
00361
int markerYAxis(
long key) const;
00362
00363
bool setMarkerPos(
long key,
double xval,
double yVal);
00364
bool setMarkerXPos(
long key,
double val);
00365
bool setMarkerYPos(
long key,
double val);
00366
void markerPos(
long key,
double &mx,
double &my) const;
00367
00368
bool setMarkerFont(
long key, const QFont &f);
00369 QFont markerFont(
long key) const;
00370
bool setMarkerPen(
long key, const QPen &p);
00371
00372
bool setMarkerLabel(
long key, const QString &text,
00373 const QFont &font = QFont(), const QColor &color = QColor(),
00374 const QPen &pen = QPen(Qt::NoPen),
00375 const QBrush &brush = QBrush(Qt::NoBrush));
00376
00377
bool setMarkerLabelText(
long key, const QString &text);
00378 const QString markerLabel(
long key) const;
00379
bool setMarkerLabelAlign(
long key,
int align);
00380
int markerLabelAlign(
long key) const;
00381
bool setMarkerLabelPen(
long key, const QPen &p);
00382 QPen markerLabelPen(
long key) const;
00383
00384
bool setMarkerLinePen(
long key, const QPen &p);
00385 QPen markerLinePen(
long key) const;
00386
bool setMarkerLineStyle(
long key,
QwtMarker::LineStyle st);
00387
QwtMarker::LineStyle markerLineStyle(
long key) const;
00388
00389
bool setMarkerSymbol(
long key, const
QwtSymbol &s);
00390
QwtSymbol markerSymbol(
long key) const;
00391
00392
00393
00394
void setAutoLegend(
bool enabled);
00395
bool autoLegend() const;
00396
00397
void enableLegend(
bool tf,
long curveKey = -1);
00398
bool legendEnabled(
long curveKey) const;
00399
00400
void setLegendPosition(Position pos,
double ratio);
00401
00402
void setLegendPosition(Position pos);
00403 Position legendPosition() const;
00404
00405 #ifndef QWT_NO_COMPAT
00406
void setLegendPos(
int pos,
double ratio = 0.0);
00407
int legendPos() const;
00408 #endif
00409
00410
void setLegendFont(const QFont &f);
00411 const QFont legendFont() const;
00412
00413
void setLegendFrameStyle(
int st);
00414
int legendFrameStyle() const;
00415
00416
QwtLegend *legend();
00417 const
QwtLegend *legend() const;
00418
00419
void setLegendDisplayPolicy(
00420
QwtLegend::LegendDisplayPolicy,
int mode = -1);
00421
00422
00423 virtual QSize sizeHint() const;
00424 virtual QSize minimumSizeHint() const;
00425
00426 virtual
bool event(QEvent *);
00427
00428 public slots:
00429
void clear();
00430
00431
bool removeCurve(
long key);
00432
void removeCurves();
00433
00434
bool removeMarker(
long key);
00435
void removeMarkers();
00436
00437 virtual
void replot();
00438
00439 protected slots:
00440 virtual
void lgdClicked();
00441
00442 #ifndef QWT_NO_COMPAT
00443 signals:
00456
void plotMousePressed(const QMouseEvent &e);
00457
00471
void plotMouseReleased(const QMouseEvent &e);
00472
00485
void plotMouseMoved(const QMouseEvent &e);
00486 #else
00487 private:
00488
00489
void plotMousePressed(const QMouseEvent &);
00490
void plotMouseReleased(const QMouseEvent &);
00491
void plotMouseMoved(const QMouseEvent &);
00492 #endif
00493
00494 signals:
00507
void legendClicked(
long key);
00508
00509 protected:
00510
void autoRefresh();
00511 static
bool axisValid(
int axis);
00512
00513 virtual
void drawCanvas(QPainter *);
00514 virtual
void drawCanvasItems(QPainter *, const QRect &,
00515 const QwtArray<
QwtDiMap> &, const
QwtPlotPrintFilter &) const;
00516 virtual
void drawContents( QPainter* p );
00517
00518 virtual
void updateTabOrder();
00519
00520
void updateAxes();
00521
void updateLayout();
00522
00523 virtual
void resizeEvent(QResizeEvent *e);
00524
00525 virtual
void insertLegendItem(
long curveKey);
00526 virtual
void updateLegendItem(
long curveKey);
00527 virtual
void printLegendItem(QPainter *,
00528 const QWidget *, const QRect &) const;
00529
00530
void updateLegendItem(const QwtPlotCurve *,
QwtLegendItem *);
00531
00532 virtual
void printTitle(QPainter *, const QRect &) const;
00533 virtual
void printScale(QPainter *,
int axis,
int startDist,
int endDist,
00534
int baseDist, const QRect &) const;
00535 virtual
void printCanvas(QPainter *, const QRect &,
00536 const QwtArray<QwtDiMap> &, const
QwtPlotPrintFilter &) const;
00537 virtual
void printLegend(QPainter *, const QRect &) const;
00538
00539 private:
00540
void initAxes();
00541
long newCurveKey();
00542
long newMarkerKey();
00543
void initPlot(const QString &title = QString::null);
00544
00545 QLabel *d_lblTitle;
00546
QwtPlotCanvas *d_canvas;
00547
QwtLegend *d_legend;
00548
QwtPlotLayout *d_layout;
00549
00550
bool d_axisEnabled[axisCnt];
00551
QwtScale *d_scale[axisCnt];
00552
QwtAutoScale d_as[axisCnt];
00553
00554 QwtCurveDict *d_curves;
00555 QwtMarkerDict *d_markers;
00556
QwtPlotGrid *d_grid;
00557
00558
bool d_autoReplot;
00559
bool d_autoLegend;
00560
00561 };
00562
00563 #endif
00564
00565
00566
00567
00568
00569