QWT API (中文) 7.0.1
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 "qwt_global.h"
32#include "qwt_math.h"
33
34#include <qpoint.h>
35#include <qmetatype.h>
36#include <qmath.h>
37
51class QWT_EXPORT QwtPointPolar
52{
53 public:
55 QwtPointPolar( double azimuth, double radius );
56 QwtPointPolar( const QPointF& );
57
58 void setPoint( const QPointF& );
59 QPointF toPoint() const;
60
61 bool isValid() const;
62 bool isNull() const;
63
64 double radius() const;
65 double azimuth() const;
66
67 double& rRadius();
68 double& rAzimuth();
69
70 void setRadius( double );
71 void setAzimuth( double );
72
73 bool operator==( const QwtPointPolar& ) const;
74 bool operator!=( const QwtPointPolar& ) const;
75
76 QwtPointPolar normalized() const;
77
78 private:
79 double m_azimuth;
80 double m_radius;
81};
82
83Q_DECLARE_TYPEINFO( QwtPointPolar, Q_MOVABLE_TYPE );
84Q_DECLARE_METATYPE( QwtPointPolar );
85
86#ifndef QT_NO_DEBUG_STREAM
87QWT_EXPORT QDebug operator<<( QDebug, const QwtPointPolar& );
88#endif
89
101 : m_azimuth( 0.0 )
102 , m_radius( 0.0 )
103{
104}
105
118inline QwtPointPolar::QwtPointPolar( double azimuth, double radius )
119 : m_azimuth( azimuth )
120 , m_radius( radius )
121{
122}
123
125inline bool QwtPointPolar::isValid() const
126{
127 return m_radius >= 0.0;
128}
129
131inline bool QwtPointPolar::isNull() const
132{
133 return m_radius == 0.0;
134}
135
137inline double QwtPointPolar::radius() const
138{
139 return m_radius;
140}
141
143inline double QwtPointPolar::azimuth() const
144{
145 return m_azimuth;
146}
147
150{
151 return m_radius;
152}
153
156{
157 return m_azimuth;
158}
159
161inline void QwtPointPolar::setRadius( double radius )
162{
163 m_radius = radius;
164}
165
167inline void QwtPointPolar::setAzimuth( double azimuth )
168{
169 m_azimuth = azimuth;
170}
171
172inline QPoint qwtPolar2Pos( const QPoint& pole,
173 double radius, double angle )
174{
175 const double x = pole.x() + radius * std::cos( angle );
176 const double y = pole.y() - radius * std::sin( angle );
177
178 return QPoint( qRound( x ), qRound( y ) );
179}
180
181inline QPoint qwtDegree2Pos( const QPoint& pole,
182 double radius, double angle )
183{
184 return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI );
185}
186
187inline QPointF qwtPolar2Pos( const QPointF& pole,
188 double radius, double angle )
189{
190 const double x = pole.x() + radius * std::cos( angle );
191 const double y = pole.y() - radius * std::sin( angle );
192
193 return QPointF( x, y);
194}
195
196inline QPointF qwtDegree2Pos( const QPointF& pole,
197 double radius, double angle )
198{
199 return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI );
200}
201
202inline QPointF qwtFastPolar2Pos( const QPointF& pole,
203 double radius, double angle )
204{
205 const double x = pole.x() + radius * qFastCos( angle );
206 const double y = pole.y() - radius * qFastSin( angle );
207
208 return QPointF( x, y);
209}
210
211inline QPointF qwtFastDegree2Pos( const QPointF& pole,
212 double radius, double angle )
213{
214 return qwtFastPolar2Pos( pole, radius, angle / 180.0 * M_PI );
215}
216
217inline QwtPointPolar qwtFastPos2Polar( const QPointF& pos )
218{
219 return QwtPointPolar( qwtFastAtan2( pos.y(), pos.x() ),
220 qSqrt( qwtSqr( pos.x() ) + qwtSqr( pos.y() ) ) );
221}
222
223#endif
极坐标点
Definition qwt_point_polar.h:52
double radius() const
返回半径
Definition qwt_point_polar.h:137
void setRadius(double)
将半径设置为 radius
Definition qwt_point_polar.h:161
void setAzimuth(double)
将方位角设置为 azimuth
Definition qwt_point_polar.h:167
QwtPointPolar()
默认构造函数 - 构造一个空点,半径和方位角都设置为 0.0
Definition qwt_point_polar.h:100
bool isValid() const
如果 radius() >= 0.0 则返回 true
Definition qwt_point_polar.h:125
double azimuth() const
返回方位角
Definition qwt_point_polar.h:143
bool isNull() const
如果 radius() == 0.0 则返回 true
Definition qwt_point_polar.h:131
double & rRadius()
返回半径的引用
Definition qwt_point_polar.h:149
double & rAzimuth()
返回方位角的引用
Definition qwt_point_polar.h:155