@@ -23,7 +23,6 | |||
|
23 | 23 | #include "qchart_p.h" |
|
24 | 24 | #include <QGraphicsScene> |
|
25 | 25 | #include <QRubberBand> |
|
26 | #include <qmath.h> | |
|
27 | 26 | |
|
28 | 27 | /*! |
|
29 | 28 | \enum QChartView::RubberBand |
@@ -258,18 +257,22 void QChartViewPrivate::setChart(QChart *chart) | |||
|
258 | 257 | resize(); |
|
259 | 258 | } |
|
260 | 259 | |
|
261 | const qreal rad2deg(57.2957795); | |
|
262 | ||
|
263 | 260 | void QChartViewPrivate::resize() |
|
264 | 261 | { |
|
265 |
// F |
|
|
266 | // more than 45 degrees from the horizontal so it fits better into the view. | |
|
267 |
qreal |
|
|
262 | // Fit the chart into view if it has been rotated | |
|
263 | qreal sinA = qAbs(q_ptr->transform().m21()); | |
|
264 | qreal cosA = qAbs(q_ptr->transform().m11()); | |
|
268 | 265 | QSize chartSize = q_ptr->size(); |
|
269 | 266 | |
|
270 | if (angle > 45.0 && angle < 135.0) { | |
|
267 | if (sinA == 1.0) { | |
|
271 | 268 | chartSize.setHeight(q_ptr->size().width()); |
|
272 | 269 | chartSize.setWidth(q_ptr->size().height()); |
|
270 | } else if (sinA != 0.0) { | |
|
271 | // Non-90 degree rotation, find largest square chart that can fit into the view. | |
|
272 | qreal minDimension = qMin(q_ptr->size().width(), q_ptr->size().height()); | |
|
273 | qreal h = (minDimension - (minDimension / ((sinA / cosA) + 1.0))) / sinA; | |
|
274 | chartSize.setHeight(h); | |
|
275 | chartSize.setWidth(h); | |
|
273 | 276 | } |
|
274 | 277 | |
|
275 | 278 | m_chart->resize(chartSize); |
General Comments 0
You need to be logged in to leave comments.
Login now