! \internal This method retrieves an optimized set of data points via \ref getOptimizedScatterData and then converts them to pixel coordinates. The resulting points are returned in \a scatters, and can be passed to \ref drawScatterPlot. \a dataRange specifies the beginning and ending data indices that will be taken into account for conversion. In this function, the specified range may
| 21287 | getDataSegments. |
| 21288 | */ |
| 21289 | void QCPGraph::getScatters(QVector<QPointF> *scatters, const QCPDataRange &dataRange) const |
| 21290 | { |
| 21291 | if (!scatters) return; |
| 21292 | QCPAxis *keyAxis = mKeyAxis.data(); |
| 21293 | QCPAxis *valueAxis = mValueAxis.data(); |
| 21294 | if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; scatters->clear(); return; } |
| 21295 | |
| 21296 | QCPGraphDataContainer::const_iterator begin, end; |
| 21297 | getVisibleDataBounds(begin, end, dataRange); |
| 21298 | if (begin == end) |
| 21299 | { |
| 21300 | scatters->clear(); |
| 21301 | return; |
| 21302 | } |
| 21303 | |
| 21304 | QVector<QCPGraphData> data; |
| 21305 | getOptimizedScatterData(&data, begin, end); |
| 21306 | |
| 21307 | if (mKeyAxis->rangeReversed() != (mKeyAxis->orientation() == Qt::Vertical)) // make sure key pixels are sorted ascending in data (significantly simplifies following processing) |
| 21308 | std::reverse(data.begin(), data.end()); |
| 21309 | |
| 21310 | scatters->resize(data.size()); |
| 21311 | if (keyAxis->orientation() == Qt::Vertical) |
| 21312 | { |
| 21313 | for (int i=0; i<data.size(); ++i) |
| 21314 | { |
| 21315 | if (!qIsNaN(data.at(i).value)) |
| 21316 | { |
| 21317 | (*scatters)[i].setX(valueAxis->coordToPixel(data.at(i).value)); |
| 21318 | (*scatters)[i].setY(keyAxis->coordToPixel(data.at(i).key)); |
| 21319 | } |
| 21320 | } |
| 21321 | } else |
| 21322 | { |
| 21323 | for (int i=0; i<data.size(); ++i) |
| 21324 | { |
| 21325 | if (!qIsNaN(data.at(i).value)) |
| 21326 | { |
| 21327 | (*scatters)[i].setX(keyAxis->coordToPixel(data.at(i).key)); |
| 21328 | (*scatters)[i].setY(valueAxis->coordToPixel(data.at(i).value)); |
| 21329 | } |
| 21330 | } |
| 21331 | } |
| 21332 | } |
| 21333 | |
| 21334 | /*! \internal |
| 21335 |
nothing calls this directly
no test coverage detected