MCPcopy Create free account
hub / github.com/IENT/YUView / setMoveOffset

Method setMoveOffset

YUViewLib/src/ui/views/PlotViewWidget.cpp:257–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257void 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
289QPoint PlotViewWidget::getMoveOffsetCoordinateSystemOrigin(const QPointF) const
290{

Callers 2

setZoomFactorMethod · 0.95

Calls 2

getVisibleRangeMethod · 0.95
clipFunction · 0.85

Tested by

no test coverage detected