From 1a7a17f8e2cd9ff07852a402b74b47257192da74 2013-09-19 06:53:38 From: Titta Heikkala Date: 2013-09-19 06:53:38 Subject: [PATCH] Fix Chart build on Solaris The sine and the square root methods in demos and examples have been replaced with the ones provided by Qt. This ensures that the code compiles also on Solaris. Task-number: QTRD-2262 Change-Id: I776341bac0e623f803b4cad771a02cefc6db1b15 Reviewed-by: Miikka Heikkinen Reviewed-by: Milla Pohjanheimo --- diff --git a/demos/chartinteractions/chart.cpp b/demos/chartinteractions/chart.cpp index a193abb..5a52a23 100644 --- a/demos/chartinteractions/chart.cpp +++ b/demos/chartinteractions/chart.cpp @@ -21,7 +21,7 @@ #include "chart.h" #include #include -#include +#include Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags, QLineSeries *series) : QChart(QChart::ChartTypeCartesian, parent, wFlags), m_series(series) @@ -48,7 +48,7 @@ void Chart::clickPoint(const QPointF &point) qreal Chart::distance(const QPointF &p1, const QPointF &p2) { - return sqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + return qSqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + (p1.y() - p2.y()) * (p1.y() - p2.y())); } diff --git a/demos/qmloscilloscope/datasource.cpp b/demos/qmloscilloscope/datasource.cpp index 457d796..063fb39 100644 --- a/demos/qmloscilloscope/datasource.cpp +++ b/demos/qmloscilloscope/datasource.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include QTCOMMERCIALCHART_USE_NAMESPACE @@ -69,7 +69,7 @@ void DataSource::generateData(int type, int rowCount, int colCount) switch (type) { case 0: // data with sin + random component - y = sin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; + y = qSin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; x = j; break; case 1: diff --git a/demos/quick2oscilloscope/datasource.cpp b/demos/quick2oscilloscope/datasource.cpp index b74562c..e48f5ec 100644 --- a/demos/quick2oscilloscope/datasource.cpp +++ b/demos/quick2oscilloscope/datasource.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include QTCOMMERCIALCHART_USE_NAMESPACE @@ -70,7 +70,7 @@ void DataSource::generateData(int type, int rowCount, int colCount) switch (type) { case 0: // data with sin + random component - y = sin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; + y = qSin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; x = j; break; case 1: diff --git a/examples/scatterinteractions/chartview.cpp b/examples/scatterinteractions/chartview.cpp index 0d53175..777930f 100644 --- a/examples/scatterinteractions/chartview.cpp +++ b/examples/scatterinteractions/chartview.cpp @@ -19,7 +19,7 @@ ****************************************************************************/ #include "chartview.h" -#include +#include #include QTCOMMERCIALCHART_USE_NAMESPACE @@ -63,8 +63,10 @@ void ChartView::handleClickedPoint(const QPointF &point) QPointF closest(INT_MAX, INT_MAX); qreal distance(INT_MAX); foreach (QPointF currentPoint, m_scatter->points()) { - qreal currentDistance = sqrt((currentPoint.x() - clickedPoint.x()) * (currentPoint.x() - clickedPoint.x()) - + (currentPoint.y() - clickedPoint.y()) * (currentPoint.y() - clickedPoint.y())); + qreal currentDistance = qSqrt((currentPoint.x() - clickedPoint.x()) + * (currentPoint.x() - clickedPoint.x()) + + (currentPoint.y() - clickedPoint.y()) + * (currentPoint.y() - clickedPoint.y())); if (currentDistance < distance) { distance = currentDistance; closest = currentPoint;