QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_figure.h
1#ifndef QWT_FIGURE_H
2#define QWT_FIGURE_H
3// stl
4#include <memory>
5
6// Qt
7#include <QFrame>
8class QResizeEvent;
9class QPaintEvent;
10
11// qwt
12#include "qwt_global.h"
13#include "qwt_axis.h"
14class QwtPlot;
15
46class QWT_EXPORT QwtFigure : public QFrame
47{
48 Q_OBJECT
49 QWT_DECLARE_PRIVATE(QwtFigure)
50public:
51 QwtFigure(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
52 ~QwtFigure() override;
53
54 // Add a widget with normalized coordinates
55 void addWidget(QWidget* widget, qreal left, qreal top, qreal width, qreal height);
56 void addWidget(QWidget* widget,
57 int rowCnt,
58 int colCnt,
59 int row,
60 int col,
61 int rowSpan = 1,
62 int colSpan = 1,
63 qreal wspace = 0.0,
64 qreal hspace = 0.0);
65
66 // Add a plot with normalized coordinates
67 void addAxes(QwtPlot* plot, const QRectF& rect);
68
69 // Add a plot with normalized coordinates using separate parameters
70 void addAxes(QwtPlot* plot, qreal left, qreal top, qreal width, qreal height);
71
72 // Add a plot by grid layout
73 void addGridAxes(QwtPlot* plot,
74 int rowCnt,
75 int colCnt,
76 int row,
77 int col,
78 int rowSpan = 1,
79 int colSpan = 1,
80 qreal wspace = 0.0,
81 qreal hspace = 0.0);
82
83 // Change the normalized position of an added widget
84 void setWidgetNormPos(QWidget* widget, const QRectF& rect);
85
86 // Get all axes (plots) in the figure (not including parasite axes)
87 QList< QwtPlot* > allAxes(bool byZOrder = false) const;
88
89 // Check if the figure has any axes
90 bool hasAxes() const;
91
92 // Check if the figure has a specific plot
93 bool hasAxes(QwtPlot* plot) const;
94
95 // Remove a specific axes (plot) from the figure
96 void removeAxes(QwtPlot* plot);
97
98 // Take a specific axes (plot) from the figure without deleting it
99 bool takeAxes(QwtPlot* plot);
100
101 // Clear all axes from the figure
102 void clear();
103
104 // Get the size of the figure in inches
105 QSize getSizeInches() const;
106
107 // Set the size of the figure in inches
108 void setSizeInches(float width, float height);
109 void setSizeInches(const QSizeF& size);
110
111 // Set the face color of the figure
112 void setFaceColor(const QColor& color);
113 QColor faceColor() const;
114
115 // Set the face brush of the figure
116 void setFaceBrush(const QBrush& brush);
117 QBrush faceBrush() const;
118
119 // Set the edge color of the figure
120 void setEdgeColor(const QColor& color);
121 QColor edgeColor() const;
122
123 // Set the edge line width of the figure
124 void setEdgeLineWidth(int width);
125 int edgeLineWidth() const;
126
127 // Create parasite axes for a host plot
128 QwtPlot* createParasiteAxes(QwtPlot* hostPlot, QwtAxis::Position enableAxis);
129
130 // Get all parasite axes for a host plot
131 QList< QwtPlot* > getParasiteAxes(QwtPlot* hostPlot) const;
132
133 // Save the figure to a QPixmap with specified DPI
134 QPixmap saveFig(int dpi = -1) const;
135
136 // Save the figure to a QPixmap with specified size in inches
137 QPixmap saveFig(QSizeF& inchesSize) const;
138
139 // Save the figure to a file with specified DPI
140 bool saveFig(const QString& filename, int dpi = -1) const;
141
142 // Set the current axes (plot)
143 void setCurrentAxes(QwtPlot* plot);
144 void sca(QwtPlot* plot);
145
146 // Get the current axes (plot)
147 QwtPlot* currentAxes() const;
148 QwtPlot* gca() const;
149
150 // Get the normalized rectangle for an axes
151 QRectF axesNormRect(QwtPlot* plot) const;
152
153 // Get the normalized rectangle for a child widget
154 QRectF widgetNormRect(QWidget* w) const;
155
156 // Get the plot at a given position (returns host plot if parasite exists)
157 QwtPlot* plotUnderPos(const QPoint& pos) const;
158
159 // Calculate normalized coordinates from actual geometry
160 QRectF calcNormRect(const QRect& geoRect) const;
161
162 // Calculate actual rectangle from normalized coordinates
163 QRect calcActualRect(const QRectF& normRect);
164
165 // Update all plots
166 void replotAll();
167
168 // Add axis alignment configuration
169 void addAxisAlignment(const QList< QwtPlot* >& plots, int axisId);
170
171 // Remove specified axis alignment configuration
172 bool removeAxisAlignment(const QList< QwtPlot* >& plots, int axisId);
173
174 // Clear all axis alignment configurations
175 void clearAxisAlignment();
176
177 // Apply all axis alignment configurations
178 void applyAllAxisAlignments(bool replot = true);
179
180 // Apply all alignment configurations for a specific axis ID
181 void applyAlignmentsForAxis(int axisId);
182
183 // Get the count of axis alignment configurations
184 int axisAligmentCount() const;
185
186 // Get axis alignment information at specified index
187 QPair< QList< QwtPlot* >, int > axisAligmentInfo(int index) const;
188
189public:
190 // Align axes of multiple QwtPlot objects
191 static void alignAxes(QList< QwtPlot* > plots, int axisId, bool update = true);
192Q_SIGNALS:
198 void axesAdded(QwtPlot* newAxes);
199
205 void axesRemoved(QwtPlot* removedAxes);
206
211
218
219protected:
220 void paintEvent(QPaintEvent* event) override;
221 void resizeEvent(QResizeEvent* event) override;
222};
223
224#endif // QWT_FIGURE_H
Definition qwt_raster_data.h:38
A figure container for organizing Qwt plots with flexible layout options
Definition qwt_figure.h:47
void figureCleared()
Signal emitted when the figure is cleared
void axesAdded(QwtPlot *newAxes)
Signal emitted when axes are added to the figure
void currentAxesChanged(QwtPlot *current)
Signal emitted when the current active axes changes
void axesRemoved(QwtPlot *removedAxes)
Signal emitted when axes are removed from the figure
A 2-D plotting widget
Definition qwt_plot.h:99
Position
Axis position
Definition qwt_axis.h:43