! \internal Takes raw data points in plot coordinates as \a data, and returns a vector containing pixel coordinate points which are suitable for drawing the line style \ref lsStepRight. The source of \a data is usually \ref getOptimizedLineData, and this method is called in \a getLines if the line style is set accordingly. \see dataToLines, dataToStepLeftLines, dataToStepCenterLines
| 20654 | \see dataToLines, dataToStepLeftLines, dataToStepCenterLines, dataToImpulseLines, getLines, drawLinePlot |
| 20655 | */ |
| 20656 | QVector<QPointF> QCPGraph::dataToStepRightLines(const QVector<QCPGraphData> &data) const |
| 20657 | { |
| 20658 | QVector<QPointF> result; |
| 20659 | QCPAxis *keyAxis = mKeyAxis.data(); |
| 20660 | QCPAxis *valueAxis = mValueAxis.data(); |
| 20661 | if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; } |
| 20662 | |
| 20663 | result.resize(data.size()*2); |
| 20664 | |
| 20665 | // calculate steps from data and transform to pixel coordinates: |
| 20666 | if (keyAxis->orientation() == Qt::Vertical) |
| 20667 | { |
| 20668 | double lastKey = keyAxis->coordToPixel(data.first().key); |
| 20669 | for (int i=0; i<data.size(); ++i) |
| 20670 | { |
| 20671 | const double value = valueAxis->coordToPixel(data.at(i).value); |
| 20672 | result[i*2+0].setX(value); |
| 20673 | result[i*2+0].setY(lastKey); |
| 20674 | lastKey = keyAxis->coordToPixel(data.at(i).key); |
| 20675 | result[i*2+1].setX(value); |
| 20676 | result[i*2+1].setY(lastKey); |
| 20677 | } |
| 20678 | } else // key axis is horizontal |
| 20679 | { |
| 20680 | double lastKey = keyAxis->coordToPixel(data.first().key); |
| 20681 | for (int i=0; i<data.size(); ++i) |
| 20682 | { |
| 20683 | const double value = valueAxis->coordToPixel(data.at(i).value); |
| 20684 | result[i*2+0].setX(lastKey); |
| 20685 | result[i*2+0].setY(value); |
| 20686 | lastKey = keyAxis->coordToPixel(data.at(i).key); |
| 20687 | result[i*2+1].setX(lastKey); |
| 20688 | result[i*2+1].setY(value); |
| 20689 | } |
| 20690 | } |
| 20691 | return result; |
| 20692 | } |
| 20693 | |
| 20694 | /*! \internal |
| 20695 |
nothing calls this directly
no test coverage detected