QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_arrowmarker.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_PLOT_ARROWMARKER_H
28#define QWT_PLOT_ARROWMARKER_H
29
30#include "qwt_global.h"
31#include "qwt_plot_item.h"
32
33class QString;
34class QRectF;
35class QwtText;
36class QPainterPath;
37class QPen;
38class QBrush;
39
58class QWT_EXPORT QwtPlotArrowMarker : public QwtPlotItem
59{
60public:
67 {
72 NoEndpoint = 0,
73
79
85
91
97
103
108 CustomPath
109 };
110
117 {
126
133 StartLengthAngle
134 };
135
136 // Constructor
137 explicit QwtPlotArrowMarker();
138
139 // Constructor with title
140 explicit QwtPlotArrowMarker(const QString& title);
141
142 // Constructor with QwtText title
143 explicit QwtPlotArrowMarker(const QwtText& title);
144
145 // Destructor
146 ~QwtPlotArrowMarker() override;
147
148 // Get the runtime type information
149 virtual int rtti() const override;
150
151 // Position and geometry methods
152
153 // Get the start point
154 QPointF startPoint() const;
155
156 // Get the end point
157 QPointF endPoint() const;
158
159 // Set the start point
160 void setStartPoint(const QPointF& point);
161
162 // Set the end point
163 void setEndPoint(const QPointF& point);
164
165 // Set both start and end points
166 void setPoints(const QPointF& start, const QPointF& end);
167
168 // Get the arrow length in pixels
169 double length() const;
170
171 // Set the arrow length in pixels
172 void setLength(double length);
173
174 // Get the rotation angle in degrees
175 double angle() const;
176
177 // Set the rotation angle in degrees
178 void setAngle(double angle);
179
180 // Get the positioning mode
181 PositionMode positionMode() const;
182
183 // Set the positioning mode
184 void setPositionMode(PositionMode mode);
185
186 // Style and appearance methods
187
188 // Get the arrow line pen
189 const QPen& linePen() const;
190
191 // Set the arrow line pen
192 void setLinePen(const QPen& pen);
193
194 // Convenience method to set line color and width
195 void setLinePen(const QColor& color, qreal width = 1.0, Qt::PenStyle style = Qt::SolidLine);
196
197 // Get the head style
198 EndpointStyle headStyle() const;
199
200 // Set the head style
201 void setHeadStyle(EndpointStyle style);
202
203 // Get the tail style
204 EndpointStyle tailStyle() const;
205
206 // Set the tail style
207 void setTailStyle(EndpointStyle style);
208
209 // Get the head size in pixels
210 QSizeF headSize() const;
211
212 // Set the head size in pixels
213 void setHeadSize(const QSizeF& size);
214
215 // Convenience method to set head size with equal width and height
216 void setHeadSize(qreal size);
217
218 // Get the tail size in pixels
219 QSizeF tailSize() const;
220
221 // Set the tail size in pixels
222 void setTailSize(const QSizeF& size);
223
224 // Convenience method to set tail size with equal width and height
225 void setTailSize(qreal size);
226
227 // Get the head brush
228 const QBrush& headBrush() const;
229
230 // Set the head brush
231 void setHeadBrush(const QBrush& brush);
232
233 // Get the tail brush
234 const QBrush& tailBrush() const;
235
236 // Set the tail brush
237 void setTailBrush(const QBrush& brush);
238
239 // Get the head pen
240 const QPen& headPen() const;
241
242 // Set the head pen
243 void setHeadPen(const QPen& pen);
244
245 // Get the tail pen
246 const QPen& tailPen() const;
247
248 // Set the tail pen
249 void setTailPen(const QPen& pen);
250
251 // Set a custom path for head endpoint
252 void setHeadCustomPath(const QPainterPath& path);
253
254 // Get the custom head path
255 QPainterPath headCustomPath() const;
256
257 // Set a custom path for tail endpoint
258 void setTailCustomPath(const QPainterPath& path);
259
260 // Get the custom tail path
261 QPainterPath tailCustomPath() const;
262
263 // Drawing methods
264
265 // Draw the arrow marker
266 virtual void
267 draw(QPainter* painter, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect) const override;
268
269 // Get the bounding rectangle
270 virtual QRectF boundingRect() const override;
271
272 // Get the legend icon
273 virtual QwtGraphic legendIcon(int index, const QSizeF& size) const override;
274
275protected:
277 virtual void drawArrowLine(QPainter* painter, const QPointF& canvasStart, const QPointF& canvasEnd) const;
279 virtual void drawCachedEndpoint(QPainter* painter,
280 const QPointF& position,
281 const QPainterPath& cachedPath,
282 const QSizeF& size,
283 const QPen& pen,
284 const QBrush& brush,
285 double rotation = 0.0) const;
286
288 virtual QPointF toCanvasPoint(const QPointF& plotPoint, const QwtScaleMap& xMap, const QwtScaleMap& yMap) const;
289
291 virtual QPointF calculateEndPoint() const;
292
293private:
294 // Disable copy constructor and assignment operator
296 QwtPlotArrowMarker& operator=(const QwtPlotArrowMarker&);
297
298 QWT_DECLARE_PRIVATE(QwtPlotArrowMarker)
299};
300
301#endif // QWT_PLOT_ARROWMARKER_H
A paint device for scalable graphics
Definition qwt_graphic.h:85
A class for drawing arrow markers on plots
Definition qwt_plot_arrowmarker.h:59
EndpointStyle
Arrow endpoint style types
Definition qwt_plot_arrowmarker.h:67
@ Diamond
Diamond endpoint
Definition qwt_plot_arrowmarker.h:96
@ Square
Square endpoint
Definition qwt_plot_arrowmarker.h:90
@ ArrowHead
Arrow head style
Definition qwt_plot_arrowmarker.h:78
@ Triangle
Triangle endpoint
Definition qwt_plot_arrowmarker.h:102
@ Circle
Circle endpoint
Definition qwt_plot_arrowmarker.h:84
PositionMode
Arrow positioning mode
Definition qwt_plot_arrowmarker.h:117
@ ExplicitPoints
Use explicit start and end points
Definition qwt_plot_arrowmarker.h:125
Base class for items on the plot canvas
Definition qwt_plot_item.h:85
virtual void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const =0
Draw the item
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Return a legend icon
Definition qwt_plot_item.cpp:420
virtual int rtti() const
Runtime type information
Definition qwt_plot_item.cpp:155
virtual QRectF boundingRect() const
Get the bounding rectangle
Definition qwt_plot_item.cpp:593
A scale map
Definition qwt_scale_map.h:44
A class representing a text
Definition qwt_text.h:70