📄 qwt_plot.h
字号:
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/#ifndef QWT_PLOT_H#define QWT_PLOT_H#include <qframe.h>#if 0#include <qbrush.h>#include <qfont.h>#include <qcolor.h>#endif#include "qwt_global.h"#include "qwt_array.h"#include "qwt_grid.h"#include "qwt_autoscl.h"#include "qwt_scldraw.h"#include "qwt_symbol.h"#include "qwt_curve.h"#include "qwt_marker.h"#include "qwt_legend.h"#include "qwt_plot_printfilter.h"#include "qwt_plot_classes.h"#include "qwt_plot_dict.h"class QLabel;class QwtPlotLayout;class QwtScale;class QwtPlotItem;class QwtPlotCanvas;class QwtPlotPrintFilter;/*! \brief A 2-D plotting widget QwtPlot is a widget for plotting two-dimensional graphs. An unlimited number of data pairs can be displayed as curves in different styles and colors. A plot can have up to four axes, with each curve attached to an x- and a y axis. The scales at the axes are dimensioned automatically using an algorithm which can be configured separately for each axis. Linear and logarithmic scaling is supported. Markers of different styles can be added to the plot. Curves and markers are identified by unique keys which are generated automatically when a curve or a marker is inserted. These keys are used to access the properties of the corresponding curves and markers. A QwtPlot widget can have up to four axes which are indexed by the constants QwtPlot::yLeft, QwtPlot::yRight, QwtPlot::xTop, and QwtPlot::xBottom. Curves, markers, and the grid must be attached to an x axis and a y axis (Default: yLeft and xBottom). \par Example The following example shows (schematically) the most simple way to use QwtPlot. By default, only the left and bottom axes are visible and their scales are computed automatically. \verbatim#include "../include/qwt_plot.h>QwtPlot *myPlot;long curve1, curve2; // keysdouble x[100], y1[100], y2[100]; // x and y valuesmyPlot = new QwtPlot("Two Graphs", parent, name);// add curvescurve1 = myPlot->insertCurve("Graph 1");curve2 = myPlot->insertCurve("Graph 2");getSomeValues(x, y1, y2);// copy the data into the curvesmyPlot->setCurveData(curve1, x, y1, 100);myPlot->setCurveData(curve2, x, y2, 100);// finally, refresh the plotmyPlot->replot();\endverbatim*/class QWT_EXPORT QwtPlot: public QFrame{ friend class QwtPlotItem; friend class QwtPlotCanvas; friend class QwtPlotPrintFilter; Q_OBJECT Q_ENUMS( Axis ) Q_PROPERTY( QColor canvasBackground READ canvasBackground WRITE setCanvasBackground ) Q_PROPERTY( int canvasLineWidth READ canvasLineWidth WRITE setCanvasLineWidth ) Q_PROPERTY( bool xBottomAxis READ xBottomAxisEnabled WRITE enableXBottomAxis ) Q_PROPERTY( bool xTopAxis READ xTopAxisEnabled WRITE enableXTopAxis ) Q_PROPERTY( bool yLeftAxis READ yLeftAxisEnabled WRITE enableYLeftAxis ) Q_PROPERTY( bool yRightAxis READ yRightAxisEnabled WRITE enableYRightAxis ) Q_PROPERTY( QString title READ title WRITE setTitle ) Q_PROPERTY( QFont titleFont READ titleFont WRITE setTitleFont )public: //! Axis index enum Axis { yLeft, yRight, xBottom, xTop, axisCnt }; QwtPlot(QWidget *p = 0, const char *name = 0); QwtPlot(const QString &title, QWidget *p = 0, const char *name = 0); virtual ~QwtPlot(); void enableXBottomAxis(bool b) {enableAxis(xBottom,b);} bool xBottomAxisEnabled() const {return axisEnabled(xBottom);}; void enableXTopAxis(bool b) {enableAxis(xTop,b);} bool xTopAxisEnabled() const {return axisEnabled(xTop);}; void enableYRightAxis(bool b) {enableAxis(yRight,b);} bool yRightAxisEnabled() const {return axisEnabled(yRight);}; void enableYLeftAxis(bool b) {enableAxis(yLeft,b);} bool yLeftAxisEnabled() const {return axisEnabled(yLeft);}; void setAutoReplot(bool tf = TRUE); bool autoReplot() const; void print(QPaintDevice &p, const QwtPlotPrintFilter & = QwtPlotPrintFilter()) const; virtual void print(QPainter *, const QRect &rect, const QwtPlotPrintFilter & = QwtPlotPrintFilter()) const; void clear();#ifndef QWT_NO_COMPAT // Outline void enableOutline(bool tf); bool outlineEnabled() const; void setOutlineStyle(Qwt::Shape os); Qwt::Shape outlineStyle() const; void setOutlinePen(const QPen &pn); const QPen& outlinePen() const;#endif // Layout QwtPlotLayout *plotLayout(); const QwtPlotLayout *plotLayout() const; void setMargin(int margin); int margin() const; // Title void setTitle(const QString &t); QString title() const; void setTitleFont (const QFont &f); QFont titleFont() const; QLabel *titleLabel(); const QLabel *titleLabel() const; // Canvas QwtPlotCanvas *canvas(); const QwtPlotCanvas *canvas() const; void setCanvasBackground (const QColor &c); const QColor& canvasBackground() const; void setCanvasLineWidth(int w); int canvasLineWidth() const; QwtPlotCurveIterator curveIterator() const; QwtPlotMarkerIterator markerIterator() const; QwtDiMap canvasMap(int axis) const; double invTransform(int axis, int pos) const; int transform(int axis, double value) const; // Curves long insertCurve(QwtPlotCurve *); long insertCurve(const QString &title, int xAxis = xBottom, int yAxis = yLeft); QwtPlotCurve *curve(long key); const QwtPlotCurve *curve(long key) const; bool removeCurve(long key); void removeCurves(); QwtArray<long> curveKeys() const; long closestCurve(int xpos, int ypos, int &dist) const; long closestCurve(int xpos, int ypos, int &dist, double &xval, double &yval, int &index) const; bool setCurveBaseline(long key, double ref); double curveBaseline(long key) const; bool setCurveRawData(long key, const double *x, const double *y, int size); bool setCurveData(long key, const double *x, const double *y, int size); bool setCurveData(long key, const QwtArray<double> &x, const QwtArray<double> &y); bool setCurveData(long key, const QwtArray<QwtDoublePoint> &data); bool setCurveData(long key, const QwtData &data); bool setCurveOptions(long key, int t); int curveOptions(long key) const; bool setCurvePen(long key, const QPen &pen); QPen curvePen(long key) const; bool setCurveBrush(long key, const QBrush &brush); QBrush curveBrush(long key) const; bool setCurveSplineSize(long key, int s); int curveSplineSize(long key) const; bool setCurveStyle(long key, int s, int options = 0); int curveStyle(long key) const; bool setCurveSymbol(long key, const QwtSymbol &s); QwtSymbol curveSymbol(long key) const; bool setCurveTitle(long key, const QString &s); QString curveTitle(long key) const; bool setCurveXAxis(long key, int axis); int curveXAxis(long key) const; bool setCurveYAxis(long key, int axis); int curveYAxis(long key) const; void drawCurve(long key, int from = 0, int to = -1); // Grid void enableGridX(bool tf = TRUE); void enableGridXMin(bool tf = TRUE); void enableGridY(bool tf = TRUE); void enableGridYMin(bool tf = TRUE); void setGridXAxis(int axis); int gridXAxis() const; void setGridYAxis(int axis); int gridYAxis() const;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -