|
QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
|
A figure container for organizing Qwt plots with flexible layout options 更多...
#include <qwt_figure.h>
类 | |
| class | PrivateData |
信号 | |
| void | axesAdded (QwtPlot *newAxes) |
| Signal emitted when axes are added to the figure | |
| void | axesRemoved (QwtPlot *removedAxes) |
| Signal emitted when axes are removed from the figure | |
| void | figureCleared () |
| Signal emitted when the figure is cleared | |
| void | currentAxesChanged (QwtPlot *current) |
| Signal emitted when the current active axes changes | |
Public 成员函数 | |
| QwtFigure (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
| Constructor | |
| void | addWidget (QWidget *widget, qreal left, qreal top, qreal width, qreal height) |
| Add a widget with normalized coordinates | |
| void | addWidget (QWidget *widget, int rowCnt, int colCnt, int row, int col, int rowSpan=1, int colSpan=1, qreal wspace=0.0, qreal hspace=0.0) |
| Add a widget by grid layout | |
| void | addAxes (QwtPlot *plot, const QRectF &rect) |
| Add a plot with normalized coordinates | |
| void | addAxes (QwtPlot *plot, qreal left, qreal top, qreal width, qreal height) |
| Add a plot with normalized coordinates using separate parameters | |
| void | addGridAxes (QwtPlot *plot, int rowCnt, int colCnt, int row, int col, int rowSpan=1, int colSpan=1, qreal wspace=0.0, qreal hspace=0.0) |
| Add a plot by grid layout | |
| void | setWidgetNormPos (QWidget *widget, const QRectF &rect) |
| Change the normalized position of an already added widget. If the widget hasn't been added yet, this function has no effect. | |
| QList< QwtPlot * > | allAxes (bool byZOrder=false) const |
| Get all axes (plots) in the figure (not including parasite axes) | |
| bool | hasAxes () const |
| Check if the figure has any axes | |
| bool | hasAxes (QwtPlot *plot) const |
| Check if the figure contains a specific plot | |
| void | removeAxes (QwtPlot *plot) |
| Remove a specific axes (plot) from the figure | |
| bool | takeAxes (QwtPlot *plot) |
| Take a specific axes (plot) from the figure without deleting it | |
| void | clear () |
| Clear all axes from the figure | |
| QSize | getSizeInches () const |
| Get the size of the figure in inches | |
| void | setSizeInches (float width, float height) |
| Set the size of the figure in inches | |
| void | setSizeInches (const QSizeF &size) |
| Set the size of the figure in inches | |
| void | setFaceColor (const QColor &color) |
| Set the face color of the figure | |
| QColor | faceColor () const |
| Get the face color of the figure | |
| void | setFaceBrush (const QBrush &brush) |
| Set the face brush of the figure | |
| QBrush | faceBrush () const |
| Get the face brush of the figure | |
| void | setEdgeColor (const QColor &color) |
| Set the edge color of the figure | |
| QColor | edgeColor () const |
| Get the edge color of the figure | |
| void | setEdgeLineWidth (int width) |
| Set the edge line width of the figure | |
| int | edgeLineWidth () const |
| Get the edge line width of the figure | |
| QwtPlot * | createParasiteAxes (QwtPlot *hostPlot, QwtAxis::Position enableAxis) |
| Create parasite axes for a host plot | |
| QList< QwtPlot * > | getParasiteAxes (QwtPlot *hostPlot) const |
| Get all parasite axes for a host plot | |
| QPixmap | saveFig (int dpi=-1) const |
| Save the figure to a QPixmap with specified DPI | |
| QPixmap | saveFig (QSizeF &inchesSize) const |
| Save the figure to a QPixmap with specified size in inches | |
| bool | saveFig (const QString &filename, int dpi=-1) const |
| Save the figure to a file with specified DPI | |
| void | setCurrentAxes (QwtPlot *plot) |
| Set the current axes (plot) | |
| void | sca (QwtPlot *plot) |
| Set the current axes (plot) | |
| QwtPlot * | currentAxes () const |
| Get the current axes (plot) | |
| QwtPlot * | gca () const |
| Get the current axes (plot) | |
| QRectF | axesNormRect (QwtPlot *plot) const |
| Get the normalized rectangle for a axes | |
| QRectF | widgetNormRect (QWidget *w) const |
| Get the normalized rectangle for a widget | |
| QwtPlot * | plotUnderPos (const QPoint &pos) const |
| Get the plot under a position | |
| QRectF | calcNormRect (const QRect &geoRect) const |
| Calculate normalized coordinates from actual window coordinates | |
| QRect | calcActualRect (const QRectF &normRect) |
| Calculate actual rectangle from normalized coordinates | |
| void | replotAll () |
| Update all plots in the figure | |
| void | addAxisAlignment (const QList< QwtPlot * > &plots, int axisId) |
| Add axis alignment configuration | |
| bool | removeAxisAlignment (const QList< QwtPlot * > &plots, int axisId) |
| Remove specified axis alignment configuration | |
| void | clearAxisAlignment () |
| Clear all axis alignment configurations | |
| void | applyAllAxisAlignments (bool replot=true) |
| Apply all axis alignment configurations | |
| void | applyAlignmentsForAxis (int axisId) |
| Apply alignment configurations for a specific axis | |
| int | axisAligmentCount () const |
| Get the number of axis alignment configurations | |
| QPair< QList< QwtPlot * >, int > | axisAligmentInfo (int index) const |
| Get axis alignment information by index | |
静态 Public 成员函数 | |
| static void | alignAxes (QList< QwtPlot * > plots, int axisId, bool update=true) |
| Align axes of multiple plots | |
Protected 成员函数 | |
| void | paintEvent (QPaintEvent *event) override |
| void | resizeEvent (QResizeEvent *event) override |
A figure container for organizing Qwt plots with flexible layout options
This class provides a figure-like container similar to matplotlib's Figure class, supporting both normalized coordinate positioning and grid layouts for Qwt plots. It uses Qt's standard top-left coordinate system for intuitive positioning.
| QwtFigure::QwtFigure | ( | QWidget * | parent = nullptr, |
| Qt::WindowFlags | f = Qt::WindowFlags() |
||
| ) |
Constructor
| parent | Parent widget |
| f | Window flags |
| void QwtFigure::addAxes | ( | QwtPlot * | plot, |
| const QRectF & | rect | ||
| ) |
Add a plot with normalized coordinates
This method adds a QwtPlot to the figure using normalized coordinates in the range [0,1]. The coordinates are specified as [left, bottom, width, height].
| plot | QwtPlot to add |
| rect | Normalized coordinates [left, bottom, width, height] in range [0,1] |
| void QwtFigure::addAxes | ( | QwtPlot * | plot, |
| qreal | left, | ||
| qreal | top, | ||
| qreal | width, | ||
| qreal | height | ||
| ) |
Add a plot with normalized coordinates using separate parameters
| plot | QwtPlot to add |
| left | Normalized coordinates left in range [0,1] |
| top | Normalized coordinates top in range [0,1] |
| width | Normalized coordinates width in range [0,1] |
| height | Normalized coordinates height in range [0,1] |
Add axis alignment configuration
This method adds an alignment configuration for the specified plots and axis.
| plots | List of plots to align |
| axisId | Axis ID to align (QwtAxis::XTop/XBottom/YLeft/YRight) |
| void QwtFigure::addGridAxes | ( | QwtPlot * | plot, |
| int | rowCnt, | ||
| int | colCnt, | ||
| int | row, | ||
| int | col, | ||
| int | rowSpan = 1, |
||
| int | colSpan = 1, |
||
| qreal | wspace = 0.0, |
||
| qreal | hspace = 0.0 |
||
| ) |
Add a plot by grid layout
This method adds a QwtPlot to the grid layout at the specified position with optional row and column spans.
| plot | QwtPlot to add |
| rowCnt | Number of rows in the grid |
| colCnt | Number of columns in the grid |
| row | Grid row position (0-based) |
| col | Grid column position (0-based) |
| rowSpan | Number of rows to span (default: 1) |
| colSpan | Number of columns to span (default: 1) |
| wspace | Horizontal space between subplots [0,1] |
| hspace | Vertical space between subplots [0,1] |
| void QwtFigure::addWidget | ( | QWidget * | widget, |
| int | rowCnt, | ||
| int | colCnt, | ||
| int | row, | ||
| int | col, | ||
| int | rowSpan = 1, |
||
| int | colSpan = 1, |
||
| qreal | wspace = 0.0, |
||
| qreal | hspace = 0.0 |
||
| ) |
Add a widget by grid layout
This method adds a widget to the grid layout at the specified position with optional row and column spans.
| widget | Widget to add |
| rowCnt | Number of rows in the grid |
| colCnt | Number of columns in the grid |
| row | Grid row position (0-based) |
| col | Grid column position (0-based) |
| rowSpan | Number of rows to span (default: 1) |
| colSpan | Number of columns to span (default: 1) |
| wspace | Horizontal space between subplots [0,1] |
| hspace | Vertical space between subplots [0,1] |
| void QwtFigure::addWidget | ( | QWidget * | widget, |
| qreal | left, | ||
| qreal | top, | ||
| qreal | width, | ||
| qreal | height | ||
| ) |
Add a widget with normalized coordinates
| widget | QWidget to add |
| left | Normalized coordinates left in range [0,1] |
| top | Normalized coordinates top in range [0,1] |
| width | Normalized coordinates width in range [0,1] |
| height | Normalized coordinates height in range [0,1] |
Align axes of multiple plots
This function unifies the minimumExtent and minBorderDist of the specified axis to ensure visual alignment of axes.
| plots | List of QwtPlot to align (must be non-empty) |
| axisId | Axis ID to align (QwtAxis::XTop/XBottom/YLeft/YRight) |
| replot | If true, update layout and replot after alignment |
Get all axes (plots) in the figure (not including parasite axes)
This method returns a list of all QwtPlot objects added to the figure.
| byZOrder | If true, sort by z-order from top to bottom |
| void QwtFigure::applyAlignmentsForAxis | ( | int | axisId | ) |
Apply alignment configurations for a specific axis
This method applies all alignment configurations for the specified axis ID.
| axisId | Axis ID to apply alignments for |
| void QwtFigure::applyAllAxisAlignments | ( | bool | replot = true | ) |
Apply all axis alignment configurations
This method applies all recorded alignment configurations to the plots.
| replot | If true, replot all affected plots after alignment |
|
signal |
Signal emitted when axes are added to the figure
| newAxes | Pointer to the newly added QwtPlot |
| QRectF QwtFigure::axesNormRect | ( | QwtPlot * | plot | ) | const |
Get the normalized rectangle for a axes
This method returns the normalized coordinates [0,1] for the specified axes in the figure. If the axes is not found in the figure, an invalid QRectF is returned.
| widget | Widget to query |
|
signal |
Signal emitted when axes are removed from the figure
| removedAxes | Pointer to the removed QwtPlot |
| int QwtFigure::axisAligmentCount | ( | ) | const |
Get the number of axis alignment configurations
This method returns the count of alignment configurations added via addAxisAlignment.
Get axis alignment information by index
This method returns the alignment configuration at the specified index.
| index | Index of the alignment configuration to retrieve |
| QRect QwtFigure::calcActualRect | ( | const QRectF & | normRect | ) |
Calculate actual rectangle from normalized coordinates
This method converts normalized coordinates to actual window coordinates.
| normRect | Normalized coordinates QRectF |
| QRectF QwtFigure::calcNormRect | ( | const QRect & | geoRect | ) | const |
Calculate normalized coordinates from actual window coordinates
This method converts actual window coordinates (geometry) to normalized coordinates.
| geoRect | Actual window coordinates (geometry) |
| void QwtFigure::clear | ( | ) |
Clear all axes from the figure
This method removes all QwtPlot objects from the figure and deletes them.
| void QwtFigure::clearAxisAlignment | ( | ) |
Clear all axis alignment configurations
This method removes all alignment configurations from the figure.
| QwtPlot * QwtFigure::createParasiteAxes | ( | QwtPlot * | hostPlot, |
| QwtAxis::Position | enableAxis | ||
| ) |
Create parasite axes for a host plot
This method creates a parasite axes that shares the same plotting area as the host plot but with independent axis scaling and labeling. The parasite axes will be positioned exactly on top of the host plot and will automatically synchronize its geometry.
| hostPlot | Pointer to the host QwtPlot |
| enableAxis | The axis position to enable on the parasite axes |
| nullptr | if hostPlot is invalid or not in the figure |
| QwtPlot * QwtFigure::currentAxes | ( | ) | const |
|
signal |
Signal emitted when the current active axes changes
| current | Pointer to the current QwtPlot, nullptr if no valid axes |
| QColor QwtFigure::edgeColor | ( | ) | const |
Get the edge color of the figure
This method returns the border color of the figure.
| int QwtFigure::edgeLineWidth | ( | ) | const |
Get the edge line width of the figure
This method returns the border line width of the figure.
| QBrush QwtFigure::faceBrush | ( | ) | const |
Get the face brush of the figure
This method returns the background brush of the figure.
| QColor QwtFigure::faceColor | ( | ) | const |
Get the face color of the figure
This method returns the background color of the figure.
| QwtPlot * QwtFigure::gca | ( | ) | const |
Get the current axes (plot)
This is a convenience method that calls currentAxes.
| QSize QwtFigure::getSizeInches | ( | ) | const |
Get the size of the figure in inches
This method calculates the physical size of the figure in inches based on the current pixel size and screen DPI.
| bool QwtFigure::hasAxes | ( | ) | const |
Check if the figure has any axes
This method returns true if the figure contains at least one QwtPlot.
| bool QwtFigure::hasAxes | ( | QwtPlot * | plot | ) | const |
| QwtPlot * QwtFigure::plotUnderPos | ( | const QPoint & | pos | ) | const |
| void QwtFigure::removeAxes | ( | QwtPlot * | plot | ) |
Remove specified axis alignment configuration
This method removes the alignment configuration for the specified plots and axis.
| plots | List of plots to remove from alignment |
| axisId | Axis ID to remove from alignment |
| void QwtFigure::replotAll | ( | ) |
Update all plots in the figure
This method calls replot on all plots in the figure.
| bool QwtFigure::saveFig | ( | const QString & | filename, |
| int | dpi = -1 |
||
| ) | const |
Save the figure to a file with specified DPI
This method saves the figure to an image file with the specified DPI.
| filename | Name of the file to save |
| dpi | Dots per inch for the saved image (-1 to use screen DPI) |
| QPixmap QwtFigure::saveFig | ( | int | dpi = -1 | ) | const |
Save the figure to a QPixmap with specified DPI
This method renders the figure to a QPixmap with the specified DPI. If DPI is -1, the current screen DPI is used.
| dpi | Dots per inch for the saved image (-1 to use screen DPI) |
| QPixmap QwtFigure::saveFig | ( | QSizeF & | inchesSize | ) | const |
Save the figure to a QPixmap with specified size in inches
This method renders the figure to a QPixmap with the specified physical size in inches. The current DPI setting of the figure is used to calculate the pixel size.
| inchesSize | Physical size in inches |
| void QwtFigure::sca | ( | QwtPlot * | plot | ) |
Set the current axes (plot)
This is a convenience method that calls setCurrentAxes.
| plot | QwtPlot to set as current |
| void QwtFigure::setCurrentAxes | ( | QwtPlot * | plot | ) |
| void QwtFigure::setEdgeColor | ( | const QColor & | color | ) |
Set the edge color of the figure
This method sets the border color of the figure.
| color | Border color |
| void QwtFigure::setEdgeLineWidth | ( | int | width | ) |
Set the edge line width of the figure
This method sets the border line width of the figure.
| width | Border line width in pixels |
| void QwtFigure::setFaceBrush | ( | const QBrush & | brush | ) |
Set the face brush of the figure
This method sets the background brush of the figure, allowing for more complex backgrounds (gradients, textures, etc.).
| brush | Background brush |
| void QwtFigure::setFaceColor | ( | const QColor & | color | ) |
Set the face color of the figure
This method sets the background color of the figure.
| color | Background color |
| void QwtFigure::setSizeInches | ( | const QSizeF & | size | ) |
Set the size of the figure in inches
This method sets the size of the figure in inches, converting to pixels based on the screen DPI.
| size | Size in inches |
| void QwtFigure::setSizeInches | ( | float | width, |
| float | height | ||
| ) |
Set the size of the figure in inches
This method sets the size of the figure in inches, converting to pixels based on the screen DPI.
| width | Width in inches |
| height | Height in inches |
| void QwtFigure::setWidgetNormPos | ( | QWidget * | widget, |
| const QRectF & | rect | ||
| ) |
Change the normalized position of an already added widget. If the widget hasn't been added yet, this function has no effect.
| widget | |
| rect |
| bool QwtFigure::takeAxes | ( | QwtPlot * | plot | ) |
Take a specific axes (plot) from the figure without deleting it
| plot | Pointer to the QwtPlot to take |
| QRectF QwtFigure::widgetNormRect | ( | QWidget * | w | ) | const |
Get the normalized rectangle for a widget
This method returns the normalized coordinates [0,1] for the specified axes in the figure. If the widget is not found in the figure, an invalid QRectF is returned.
| widget | Widget to query |