QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_point_polar.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
28#ifndef QWT_POINT_POLAR_H
29#define QWT_POINT_POLAR_H
30
31#include "qwtcore_global.h"
32#include "qwt_math.h"
33
34#include <qpoint.h>
35#include <qmetatype.h>
36#include <qmath.h>
37
44class QWTCORE_EXPORT QwtPointPolar
45{
46public:
48 QwtPointPolar(double azimuth, double radius);
49 QwtPointPolar(const QPointF&);
50
51 void setPoint(const QPointF&);
52 QPointF toPoint() const;
53
54 bool isValid() const noexcept;
55 bool isNull() const noexcept;
56
57 double radius() const noexcept;
58 double azimuth() const noexcept;
59
60 double& rRadius() noexcept;
61 double& rAzimuth() noexcept;
62
63 void setRadius(double) noexcept;
64 void setAzimuth(double) noexcept;
65
66 bool operator==(const QwtPointPolar&) const;
67 bool operator!=(const QwtPointPolar&) const;
68
69 QwtPointPolar normalized() const;
70
71private:
72 double m_azimuth { 0.0 };
73 double m_radius { 0.0 };
74};
75
76Q_DECLARE_TYPEINFO(QwtPointPolar, Q_MOVABLE_TYPE);
77Q_DECLARE_METATYPE(QwtPointPolar);
78
79#ifndef QT_NO_DEBUG_STREAM
80QWTCORE_EXPORT QDebug operator<<(QDebug, const QwtPointPolar&);
81#endif
82
87inline QwtPointPolar::QwtPointPolar() : m_azimuth(0.0), m_radius(0.0)
88{
89}
90
96inline QwtPointPolar::QwtPointPolar(double azimuth, double radius) : m_azimuth(azimuth), m_radius(radius)
97{
98}
99
101inline bool QwtPointPolar::isValid() const noexcept
102{
103 return m_radius >= 0.0;
104}
105
107inline bool QwtPointPolar::isNull() const noexcept
108{
109 return m_radius == 0.0;
110}
111
113inline double QwtPointPolar::radius() const noexcept
114{
115 return m_radius;
116}
117
119inline double QwtPointPolar::azimuth() const noexcept
120{
121 return m_azimuth;
122}
123
125inline double& QwtPointPolar::rRadius() noexcept
126{
127 return m_radius;
128}
129
131inline double& QwtPointPolar::rAzimuth() noexcept
132{
133 return m_azimuth;
134}
135
137inline void QwtPointPolar::setRadius(double radius) noexcept
138{
139 m_radius = radius;
140}
141
143inline void QwtPointPolar::setAzimuth(double azimuth) noexcept
144{
145 m_azimuth = azimuth;
146}
147
148inline QPoint qwtPolar2Pos(const QPoint& pole, double radius, double angle)
149{
150 const double x = pole.x() + radius * std::cos(angle);
151 const double y = pole.y() - radius * std::sin(angle);
152
153 return QPoint(qRound(x), qRound(y));
154}
155
156inline QPoint qwtDegree2Pos(const QPoint& pole, double radius, double angle)
157{
158 return qwtPolar2Pos(pole, radius, angle / 180.0 * M_PI);
159}
160
161inline QPointF qwtPolar2Pos(const QPointF& pole, double radius, double angle)
162{
163 const double x = pole.x() + radius * std::cos(angle);
164 const double y = pole.y() - radius * std::sin(angle);
165
166 return QPointF(x, y);
167}
168
169inline QPointF qwtDegree2Pos(const QPointF& pole, double radius, double angle)
170{
171 return qwtPolar2Pos(pole, radius, angle / 180.0 * M_PI);
172}
173
174inline QPointF qwtFastPolar2Pos(const QPointF& pole, double radius, double angle)
175{
176 const double x = pole.x() + radius * qFastCos(angle);
177 const double y = pole.y() - radius * qFastSin(angle);
178
179 return QPointF(x, y);
180}
181
182inline QPointF qwtFastDegree2Pos(const QPointF& pole, double radius, double angle)
183{
184 return qwtFastPolar2Pos(pole, radius, angle / 180.0 * M_PI);
185}
186
187inline QwtPointPolar qwtFastPos2Polar(const QPointF& pos)
188{
189 return QwtPointPolar(qwtFastAtan2(pos.y(), pos.x()), qSqrt(qwtSqr(pos.x()) + qwtSqr(pos.y())));
190}
191
192#endif
A point in polar coordinates
Definition qwt_point_polar.h:45
QwtPointPolar()
Default constructor - constructs a null point with radius and azimuth set to 0.0
Definition qwt_point_polar.h:87
bool isNull() const noexcept
Return true if radius() == 0.0
Definition qwt_point_polar.h:107
double & rAzimuth() noexcept
Return a reference to the azimuth
Definition qwt_point_polar.h:131
double & rRadius() noexcept
Return a reference to the radius
Definition qwt_point_polar.h:125
void setRadius(double) noexcept
Set the radius to radius
Definition qwt_point_polar.h:137
double azimuth() const noexcept
Return the azimuth
Definition qwt_point_polar.h:119
void setAzimuth(double) noexcept
Set the azimuth to azimuth
Definition qwt_point_polar.h:143
double radius() const noexcept
Return the radius
Definition qwt_point_polar.h:113
bool isValid() const noexcept
Return true if radius() >= 0.0
Definition qwt_point_polar.h:101