| 255 | } |
| 256 | |
| 257 | void PlotViewWidget::setMoveOffset(QPointF offset) |
| 258 | { |
| 259 | if (!this->model) |
| 260 | { |
| 261 | MoveAndZoomableView::setMoveOffset(offset); |
| 262 | return; |
| 263 | } |
| 264 | |
| 265 | auto visibleRange = this->getVisibleRange(Axis::X); |
| 266 | if (!visibleRange) |
| 267 | { |
| 268 | MoveAndZoomableView::setMoveOffset(offset); |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | const auto clipLeft = (-(visibleRange->min) * this->zoomToPixelsPerValueX * this->zoomFactor); |
| 273 | const auto axisLengthX = |
| 274 | this->propertiesAxis[0].line.p2().x() - this->propertiesAxis[0].line.p1().x(); |
| 275 | const auto axisLengthInValues = axisLengthX / this->zoomToPixelsPerValueX / this->zoomFactor; |
| 276 | const auto clipRight = |
| 277 | (-(visibleRange->max - axisLengthInValues) * this->zoomToPixelsPerValueX * this->zoomFactor); |
| 278 | |
| 279 | QPointF offsetClipped; |
| 280 | if (axisLengthInValues > (visibleRange->max - visibleRange->min)) |
| 281 | offsetClipped = QPointF(functions::clip(offset.x(), clipLeft, clipRight), 0); |
| 282 | else |
| 283 | offsetClipped = QPointF(functions::clip(offset.x(), clipRight, clipLeft), 0); |
| 284 | |
| 285 | DEBUG_PLOT("PlotViewWidget::setMoveOffset offset " << offset << " clipped " << offsetClipped); |
| 286 | MoveAndZoomableView::setMoveOffset(offsetClipped); |
| 287 | } |
| 288 | |
| 289 | QPoint PlotViewWidget::getMoveOffsetCoordinateSystemOrigin(const QPointF) const |
| 290 | { |
no test coverage detected