##// END OF EJS Templates
Fix warning about uninitialized variable...
Miikka Heikkinen -
r2580:a20cc56483ba
parent child
Show More
@@ -1,91 +1,91
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "polardomain_p.h"
21 #include "polardomain_p.h"
22 #include "qabstractaxis_p.h"
22 #include "qabstractaxis_p.h"
23 #include <qmath.h>
23 #include <qmath.h>
24
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
26
27 PolarDomain::PolarDomain(QObject *parent)
27 PolarDomain::PolarDomain(QObject *parent)
28 : AbstractDomain(parent)
28 : AbstractDomain(parent)
29 {
29 {
30 }
30 }
31
31
32 PolarDomain::~PolarDomain()
32 PolarDomain::~PolarDomain()
33 {
33 {
34 }
34 }
35
35
36 void PolarDomain::setSize(const QSizeF &size)
36 void PolarDomain::setSize(const QSizeF &size)
37 {
37 {
38 Q_ASSERT(size.width() == size.height());
38 Q_ASSERT(size.width() == size.height());
39 m_radius = size.height() / 2;
39 m_radius = size.height() / 2.0;
40 m_center = QPointF(m_radius, m_radius);
40 m_center = QPointF(m_radius, m_radius);
41 AbstractDomain::setSize(size);
41 AbstractDomain::setSize(size);
42 }
42 }
43
43
44 QPointF PolarDomain::calculateGeometryPoint(const QPointF &point, bool &ok) const
44 QPointF PolarDomain::calculateGeometryPoint(const QPointF &point, bool &ok) const
45 {
45 {
46 qreal r;
46 qreal r = 0.0;
47 qreal a = toAngularCoordinate(point.x(), ok);
47 qreal a = toAngularCoordinate(point.x(), ok);
48 if (ok)
48 if (ok)
49 r = toRadialCoordinate(point.y(), ok);
49 r = toRadialCoordinate(point.y(), ok);
50 if (ok) {
50 if (ok) {
51 return m_center + polarCoordinateToPoint(a, r);
51 return m_center + polarCoordinateToPoint(a, r);
52 } else {
52 } else {
53 qWarning() << "Logarithm of negative value is undefined. Empty layout returned.";
53 qWarning() << "Logarithm of negative value is undefined. Empty layout returned.";
54 return QPointF();
54 return QPointF();
55 }
55 }
56 }
56 }
57
57
58 QVector<QPointF> PolarDomain::calculateGeometryPoints(const QList<QPointF> &vector) const
58 QVector<QPointF> PolarDomain::calculateGeometryPoints(const QList<QPointF> &vector) const
59 {
59 {
60 QVector<QPointF> result;
60 QVector<QPointF> result;
61 result.resize(vector.count());
61 result.resize(vector.count());
62 bool ok;
62 bool ok;
63 qreal r;
63 qreal r = 0.0;
64 qreal a;
64 qreal a = 0.0;
65
65
66 for (int i = 0; i < vector.count(); ++i) {
66 for (int i = 0; i < vector.count(); ++i) {
67 a = toAngularCoordinate(vector[i].x(), ok);
67 a = toAngularCoordinate(vector[i].x(), ok);
68 if (ok)
68 if (ok)
69 r = toRadialCoordinate(vector[i].y(), ok);
69 r = toRadialCoordinate(vector[i].y(), ok);
70 if (ok) {
70 if (ok) {
71 result[i] = m_center + polarCoordinateToPoint(a, r);
71 result[i] = m_center + polarCoordinateToPoint(a, r);
72 } else {
72 } else {
73 qWarning() << "Logarithm of negative value is undefined. Empty layout returned.";
73 qWarning() << "Logarithm of negative value is undefined. Empty layout returned.";
74 return QVector<QPointF>();
74 return QVector<QPointF>();
75 }
75 }
76 }
76 }
77
77
78 return result;
78 return result;
79 }
79 }
80
80
81 QPointF PolarDomain::polarCoordinateToPoint(qreal angularCoordinate, qreal radialCoordinate) const
81 QPointF PolarDomain::polarCoordinateToPoint(qreal angularCoordinate, qreal radialCoordinate) const
82 {
82 {
83 qreal dx = qSin(angularCoordinate * (M_PI / 180)) * radialCoordinate;
83 qreal dx = qSin(angularCoordinate * (M_PI / 180)) * radialCoordinate;
84 qreal dy = qCos(angularCoordinate * (M_PI / 180)) * radialCoordinate;
84 qreal dy = qCos(angularCoordinate * (M_PI / 180)) * radialCoordinate;
85
85
86 return QPointF(dx, -dy);
86 return QPointF(dx, -dy);
87 }
87 }
88
88
89 #include "moc_polardomain_p.cpp"
89 #include "moc_polardomain_p.cpp"
90
90
91 QTCOMMERCIALCHART_END_NAMESPACE
91 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now