void PlotZoomer::zoomSync(const QRectF &rect) { if (!_ignoreSync) { // if (QwtPlotZoomer *zoomer = qobject_cast<QwtPlotZoomer *>(sender())) // { // setZoomStack(zoomer->zoomStack(), zoomer->zoomRectIndex()); // } // else // { // zoom(rect); // } // Adjust the zoom rect according to the zoom mode. QRectF adjustedRect = rect; switch (_zoomMode) { default: case ZoomBoth: break; case ZoomX: adjustedRect.setY(zoomRect().y()); adjustedRect.setHeight(zoomRect().height()); break; case ZoomY: adjustedRect.setX(zoomRect().x()); adjustedRect.setWidth(zoomRect().width()); break; } zoom(adjustedRect); } }
/*! \brief Assign a zoom stack In combination with other types of navigation it might be useful to modify to manipulate the complete zoom stack. \param zoomStack New zoom stack \param zoomRectIndex Index of the current position of zoom stack. In case of -1 the current position is at the top of the stack. \note The zoomed signal might be emitted. \sa zoomStack(), zoomRectIndex() */ void QwtPlotZoomer::setZoomStack( const QStack<QRectF> &zoomStack, int zoomRectIndex ) { if ( zoomStack.isEmpty() ) return; if ( d_data->maxStackDepth >= 0 && zoomStack.count() > d_data->maxStackDepth ) { return; } if ( zoomRectIndex < 0 || zoomRectIndex > zoomStack.count() ) zoomRectIndex = zoomStack.count() - 1; const bool doRescale = zoomStack[zoomRectIndex] != zoomRect(); d_data->zoomStack = zoomStack; d_data->zoomRectIndex = uint( zoomRectIndex ); if ( doRescale ) { rescale(); Q_EMIT zoomed( zoomRect() ); } }
void ScrollZoomer::scrollBarMoved(Qt::Orientation o, double min, double) { if (o == Qt::Horizontal) move(QPoint(min, zoomRect().top())); // move(min, zoomRect().top()); else move(QPoint(zoomRect().left(), min)); // move(zoomRect().left(), min); emit zoomed(zoomRect()); }
void ScrollZoomer::scrollBarMoved( Qt::Orientation o, double min, double max ) { Q_UNUSED( max ); if ( o == Qt::Horizontal ) moveTo( QPointF( min, zoomRect().top() ) ); else moveTo( QPointF( zoomRect().left(), min ) ); Q_EMIT zoomed( zoomRect() ); }
bool ScrollZoomer::needScrollBar(Qt::Orientation o) const { #if QT_VERSION < 0x040000 QScrollView::ScrollBarMode mode; #else Qt::ScrollBarPolicy mode; #endif double zoomMin, zoomMax, baseMin, baseMax; if (o == Qt::Horizontal) { mode = d_hScrollData->mode; baseMin = zoomBase().left(); baseMax = zoomBase().right(); zoomMin = zoomRect().left(); zoomMax = zoomRect().right(); } else { mode = d_vScrollData->mode; baseMin = zoomBase().top(); baseMax = zoomBase().bottom(); zoomMin = zoomRect().top(); zoomMax = zoomRect().bottom(); } bool needed = false; switch (mode) { #if QT_VERSION < 0x040000 case QScrollView::AlwaysOn: #else case Qt::ScrollBarAlwaysOn: #endif needed = true; break; #if QT_VERSION < 0x040000 case QScrollView::AlwaysOff: #else case Qt::ScrollBarAlwaysOff: #endif needed = false; break; default: { if (baseMin < zoomMin || baseMax > zoomMax) needed = true; break; } } return needed; }
/*! Move the the current zoom rectangle. \param x X value \param y Y value \sa QwtDoubleRect::move \note The changed rectangle is limited by the zoom base */ void QwtPlotZoomer::move(double x, double y) { x = qwtMax(x, zoomBase().left()); x = qwtMin(x, zoomBase().right() - zoomRect().width()); y = qwtMax(y, zoomBase().top()); y = qwtMin(y, zoomBase().bottom() - zoomRect().height()); if ( x != zoomRect().left() || y != zoomRect().top() ) { d_data->zoomStack[d_data->zoomRectIndex].moveTo(x, y); rescale(); } }
status_t TWindowMenuItem::Invoke(BMessage* /*message*/) { if (!fDragging) { if (fID >= 0) { int32 action = (modifiers() & B_CONTROL_KEY) != 0 ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT; bool doZoom = false; BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f); BMenuItem* item; if (!fExpanded) item = Menu()->Superitem(); else item = this; if (item->Menu()->Window() != NULL) { zoomRect = item->Menu()->ConvertToScreen(item->Frame()); doZoom = (fMini && action == B_BRING_TO_FRONT) || (!fMini && action == B_MINIMIZE_WINDOW); } do_window_action(fID, action, zoomRect, doZoom); } } return B_OK; }
bool PlotZoomer::end(bool ok) { // Code here is taken from QwtPlotZoomer. The only modification is around the _zoomMode handling. ok = QwtPlotPicker::end(ok); if (!ok) { return false; } QwtPlot *plot = QwtPlotZoomer::plot(); if (!plot) { return false; } const QPolygon &pa = selection(); if (pa.count() < 2) { return false; } QRect rect = QRect(pa[0], pa[int(pa.count() - 1)]); rect = rect.normalized(); QRectF currentZoomRect = zoomRect(); QRectF zoomRect = invTransform(rect).normalized(); switch (_zoomMode) { default: case ZoomBoth: // nothing. break; case ZoomX: // Maintain current zoom y and height. zoomRect.setY(currentZoomRect.y()); zoomRect.setHeight(currentZoomRect.height()); break; case ZoomY: // Maintain current zoom x and width. zoomRect.setX(currentZoomRect.x()); zoomRect.setWidth(currentZoomRect.width()); break; } const QSizeF minSize = minZoomSize(); if (minSize.isValid()) { const QPointF center = zoomRect.center(); zoomRect.setSize(zoomRect.size().expandedTo(minZoomSize())); zoomRect.moveCenter(center); } zoom(zoomRect); return true; }
void ClosableImage::paintEvent(QPaintEvent *event) { QPainter p(this); if (m_loading) { QLabel::paintEvent(event); return; } if (!m_pixmap.isNull()) { int h = height()*(width()-2*m_mySize)/width(); p.drawPixmap(m_mySize, (height()-h)/2, m_pixmap.scaledToWidth((width()-2*m_mySize) * Helper::instance()->devicePixelRatio(this))); return; } QImage img; int origWidth; int origHeight; if (!m_image.isNull()) { img = QImage::fromData(m_image); origWidth = img.width(); origHeight = img.height(); img = img.scaledToWidth((width()-9)*Helper::instance()->devicePixelRatio(this), Qt::SmoothTransformation); } else if (!m_imagePath.isEmpty()) { img = ImageCache::instance()->image(m_imagePath, (width()-9)*Helper::instance()->devicePixelRatio(this), 0, origWidth, origHeight); } else { int x = (width() - (m_defaultPixmap.width() / Helper::instance()->devicePixelRatio(m_defaultPixmap))) / 2; int y = (height() - (m_defaultPixmap.height() / Helper::instance()->devicePixelRatio(m_defaultPixmap))) / 2; p.drawPixmap(x, y, m_defaultPixmap); if (m_showCapture) p.drawPixmap(captureRect(), m_capture); drawTitle(p); return; } Helper::instance()->setDevicePixelRatio(img, Helper::instance()->devicePixelRatio(this)); QRect r = rect(); p.drawImage(0, 7, img); QImage closeImg = QImage(":/img/closeImage.png").scaled(QSize(20, 20) * Helper::instance()->devicePixelRatio(this), Qt::KeepAspectRatio, Qt::SmoothTransformation); Helper::instance()->setDevicePixelRatio(closeImg, Helper::instance()->devicePixelRatio(this)); p.drawImage(r.width()-21, 0, closeImg); if (m_showZoomAndResolution) { QString res = QString("%1x%2").arg(origWidth).arg(origHeight); QFontMetrics fm(m_font); int resWidth = fm.width(res); p.setFont(m_font); p.setPen(QColor(102, 102, 102)); p.drawText(width()-resWidth-9, height()-20, resWidth, 20, Qt::AlignRight | Qt::AlignBottom, res); p.drawPixmap(zoomRect(), m_zoomIn); drawTitle(p); } if (m_showCapture) { p.drawPixmap(captureRect(), m_capture); drawTitle(p); } }
void ScrollZoomer::scrollBarMoved( Qt::Orientation o, double min, double max ) { Q_UNUSED( max ); #if QWT_VERSION < 0x060000 if ( o == Qt::Horizontal ) move(min, zoomRect().top()); else move(zoomRect().left(), min); #else if ( o == Qt::Horizontal ) moveTo( QPointF( min, zoomRect().top() ) ); else moveTo( QPointF( zoomRect().left(), min ) ); #endif Q_EMIT zoomed( zoomRect() ); }
bool ScrollZoomer::needScrollBar( Qt::Orientation orientation ) const { Qt::ScrollBarPolicy mode; double zoomMin, zoomMax, baseMin, baseMax; if ( orientation == Qt::Horizontal ) { mode = d_hScrollData->mode; baseMin = zoomBase().left(); baseMax = zoomBase().right(); zoomMin = zoomRect().left(); zoomMax = zoomRect().right(); } else { mode = d_vScrollData->mode; baseMin = zoomBase().top(); baseMax = zoomBase().bottom(); zoomMin = zoomRect().top(); zoomMax = zoomRect().bottom(); } bool needed = false; switch( mode ) { case Qt::ScrollBarAlwaysOn: needed = true; break; case Qt::ScrollBarAlwaysOff: needed = false; break; default: { if ( baseMin < zoomMin || baseMax > zoomMax ) needed = true; break; } } return needed; }
status_t TShowHideMenuItem::Invoke(BMessage *) { bool doZoom = false; BRect zoomRect(0, 0, 0, 0); BMenuItem *item = Menu()->Superitem(); if (item->Menu()->Window() != NULL) { zoomRect = item->Menu()->ConvertToScreen(item->Frame()); doZoom = true; } return TeamShowHideCommon(static_cast<int32>(fAction), fTeams, zoomRect, doZoom); }
/*! \brief Zoom in or out Activate a rectangle on the zoom stack with an offset relative to the current position. Negative values of offest will zoom out, positive zoom in. A value of 0 zooms out to the zoom base. \param offset Offset relative to the current position of the zoom stack. \note The zoomed signal is emitted. \sa zoomRectIndex() */ void QwtPlotZoomer::zoom(int offset) { if ( offset == 0 ) d_data->zoomRectIndex = 0; else { int newIndex = d_data->zoomRectIndex + offset; newIndex = qwtMax(0, newIndex); newIndex = qwtMin(int(d_data->zoomStack.count()) - 1, newIndex); d_data->zoomRectIndex = uint(newIndex); } rescale(); emit zoomed(zoomRect()); }
void PlotZoomer::zoomToFit(bool replot) { if (zoomRectIndex() <= 0) { // Force zoom signal for synchronisation. zoom(0); emit zoomed(zoomRect()); } else { zoom(0); } if (QwtPlot *plotter = plot()) { plotter->setAxisAutoScale(AxisX); plotter->setAxisAutoScale(AxisY); plotter->updateAxes(); } setZoomBase(replot); }
/*! \brief Zoom in or out Activate a rectangle on the zoom stack with an offset relative to the current position. Negative values of offset will zoom out, positive zoom in. A value of 0 zooms out to the zoom base. \param offset Offset relative to the current position of the zoom stack. \note The zoomed signal is emitted. \sa zoomRectIndex() */ void QwtPlotZoomer::zoom( int offset ) { int newIndex; if ( offset == 0 ) { newIndex = 0; } else { newIndex = d_data->zoomRectIndex + offset; newIndex = qBound( 0, newIndex, d_data->zoomStack.count() - 1 ); } if ( newIndex != static_cast<int>( d_data->zoomRectIndex ) ) { d_data->zoomRectIndex = newIndex; rescale(); Q_EMIT zoomed( zoomRect() ); } }
void ClosableImage::mousePressEvent(QMouseEvent *ev) { if (ev->button() != Qt::LeftButton) return; QRect closeRect(width()-25, 0, 24, 24); QRect zoomRect(0, height()-16, 16, 16); if (closeRect.contains(ev->pos()) && m_pixmap.isNull()) { m_pixmap = QPixmap::grabWidget(this); QPropertyAnimation *anim = new QPropertyAnimation(this); anim->setEasingCurve(QEasingCurve::InQuad); anim->setTargetObject(this); anim->setStartValue(0); anim->setEndValue(width()/2); anim->setPropertyName("mySize"); anim->setDuration(400); anim->start(QPropertyAnimation::DeleteWhenStopped); connect(anim, SIGNAL(finished()), this, SIGNAL(sigClose())); } else if (m_showZoomAndResolution && zoomRect.contains(ev->pos()) && m_pixmap.isNull()) { emit sigZoom(m_image); } }
/*! Move the the current zoom rectangle. \param x X value \param y Y value \sa QwtDoubleRect::move \note The changed rectangle is limited by the zoom base */ void QwtPlotZoomer::move(double x, double y) { if ( x < zoomBase().left() ) x = zoomBase().left(); if ( x > zoomBase().right() - zoomRect().width() ) x = zoomBase().right() - zoomRect().width(); if ( y < zoomBase().top() ) y = zoomBase().top(); if ( y > zoomBase().bottom() - zoomRect().height() ) y = zoomBase().bottom() - zoomRect().height(); if ( x != zoomRect().left() || y != zoomRect().top() ) { d_data->zoomStack[d_data->zoomRectIndex].moveTo(x, y); rescale(); } }
/*! Move the the current zoom rectangle. \param pos New position \sa QRectF::moveTo() \note The changed rectangle is limited by the zoom base */ void QwtPlotZoomer::moveTo( const QPointF &pos ) { double x = pos.x(); double y = pos.y(); if ( x < zoomBase().left() ) x = zoomBase().left(); if ( x > zoomBase().right() - zoomRect().width() ) x = zoomBase().right() - zoomRect().width(); if ( y < zoomBase().top() ) y = zoomBase().top(); if ( y > zoomBase().bottom() - zoomRect().height() ) y = zoomBase().bottom() - zoomRect().height(); if ( x != zoomRect().left() || y != zoomRect().top() ) { d_data->zoomStack[d_data->zoomRectIndex].moveTo( x, y ); rescale(); } }
ContentWindowPtr State::restoreContent_( QXmlQuery& query, ContentPtr content, const int index ) const { double x, y, w, h, centerX, centerY, zoom; x = y = w = h = centerX = centerY = zoom = -1.; char string[1024]; sprintf(string, "string(//state/ContentWindow[%i]/x)", index); query.setQuery(string); QString qstring; if(query.evaluateTo(&qstring)) { x = qstring.toDouble(); } sprintf(string, "string(//state/ContentWindow[%i]/y)", index); query.setQuery(string); if(query.evaluateTo(&qstring)) { y = qstring.toDouble(); } sprintf(string, "string(//state/ContentWindow[%i]/w)", index); query.setQuery(string); if(query.evaluateTo(&qstring)) { w = qstring.toDouble(); } sprintf(string, "string(//state/ContentWindow[%i]/h)", index); query.setQuery(string); if(query.evaluateTo(&qstring)) { h = qstring.toDouble(); } sprintf(string, "string(//state/ContentWindow[%i]/centerX)", index); query.setQuery(string); if(query.evaluateTo(&qstring)) { centerX = qstring.toDouble(); } sprintf(string, "string(//state/ContentWindow[%i]/centerY)", index); query.setQuery(string); if(query.evaluateTo(&qstring)) { centerY = qstring.toDouble(); } sprintf(string, "string(//state/ContentWindow[%i]/zoom)", index); query.setQuery(string); if(query.evaluateTo(&qstring)) { zoom = qstring.toDouble(); } ContentWindowPtr contentWindow( new ContentWindow( content )); QRectF windowCoordinates( contentWindow->getCoordinates( )); if( x != -1. || y != -1. ) windowCoordinates.moveTopLeft( QPointF( x, y )); if( w != -1. || h != -1. ) windowCoordinates.setSize( QSizeF( w, h )); contentWindow->setCoordinates( windowCoordinates ); QRectF zoomRect( contentWindow->getZoomRect( )); if( zoom != -1. ) zoomRect.setSize( QSizeF( 1.0/zoom, 1.0/zoom )); if( centerX != -1. || centerY != -1. ) zoomRect.moveCenter( QPointF( centerX, centerY )); contentWindow->setZoomRect( zoomRect ); return contentWindow; }
void ClosableImage::mouseMoveEvent(QMouseEvent *ev) { if (!m_loading) { if ((!m_image.isNull() || !m_imagePath.isEmpty()) && closeRect().contains(ev->pos())) { setCursor(Qt::PointingHandCursor); setToolTip(tr("Delete Image")); return; } if ((!m_image.isNull() || !m_imagePath.isEmpty()) && m_showZoomAndResolution && zoomRect().contains(ev->pos())) { setCursor(Qt::PointingHandCursor); setToolTip(tr("Zoom Image")); return; } if (m_clickable && imgRect().contains(ev->pos())) { setCursor(Qt::PointingHandCursor); setToolTip(tr("Select another image")); return; } } setCursor(Qt::ArrowCursor); setToolTip(""); }
void ClosableImage::mousePressEvent(QMouseEvent *ev) { if (m_loading || ev->button() != Qt::LeftButton || !m_pixmap.isNull()) return; if ((!m_image.isNull() || !m_imagePath.isEmpty()) && closeRect().contains(ev->pos())) { if (!confirmDeleteImage()) return; m_pixmap = QPixmap::grabWidget(this); Helper::instance()->setDevicePixelRatio(m_pixmap, Helper::instance()->devicePixelRatio(this)); m_anim = new QPropertyAnimation(this); m_anim->setEasingCurve(QEasingCurve::InQuad); m_anim->setTargetObject(this); m_anim->setStartValue(0); m_anim->setEndValue(width()/2); m_anim->setPropertyName("mySize"); m_anim->setDuration(400); m_anim->start(QPropertyAnimation::DeleteWhenStopped); connect(m_anim, SIGNAL(finished()), this, SIGNAL(sigClose())); connect(m_anim, SIGNAL(finished()), this, SLOT(closed()), Qt::QueuedConnection); } else if ((!m_image.isNull() || !m_imagePath.isEmpty()) && m_showZoomAndResolution && zoomRect().contains(ev->pos())) { if (!m_image.isNull()) { ImagePreviewDialog::instance()->setImage(QPixmap::fromImage(QImage::fromData(m_image))); ImagePreviewDialog::instance()->exec(); } else if (!m_imagePath.isEmpty()) { ImagePreviewDialog::instance()->setImage(QPixmap::fromImage(QImage(m_imagePath))); ImagePreviewDialog::instance()->exec(); } } else if (m_clickable && imgRect().contains(ev->pos())) { emit clicked(); } }
void ScrollZoomer::updateScrollBars() { if ( !canvas() ) return; const int xAxis = QwtPlotZoomer::xAxis().pos; const int yAxis = QwtPlotZoomer::yAxis().pos; int xScrollBarAxis = xAxis; if ( hScrollBarPosition() == OppositeToScale ) xScrollBarAxis = oppositeAxis( xScrollBarAxis ); int yScrollBarAxis = yAxis; if ( vScrollBarPosition() == OppositeToScale ) yScrollBarAxis = oppositeAxis( yScrollBarAxis ); QwtPlotLayout *layout = plot()->plotLayout(); bool showHScrollBar = needScrollBar( Qt::Horizontal ); if ( showHScrollBar ) { ScrollBar *sb = scrollBar( Qt::Horizontal ); sb->setPalette( plot()->palette() ); sb->setInverted( !plot()->axisScaleDiv( xAxis ).isIncreasing() ); sb->setBase( zoomBase().left(), zoomBase().right() ); sb->moveSlider( zoomRect().left(), zoomRect().right() ); if ( !sb->isVisibleTo( canvas() ) ) { sb->show(); layout->setCanvasMargin( layout->canvasMargin( xScrollBarAxis ) + sb->extent(), xScrollBarAxis ); } } else { if ( horizontalScrollBar() ) { horizontalScrollBar()->hide(); layout->setCanvasMargin( layout->canvasMargin( xScrollBarAxis ) - horizontalScrollBar()->extent(), xScrollBarAxis ); } } bool showVScrollBar = needScrollBar( Qt::Vertical ); if ( showVScrollBar ) { ScrollBar *sb = scrollBar( Qt::Vertical ); sb->setPalette( plot()->palette() ); sb->setInverted( !plot()->axisScaleDiv( yAxis ).isIncreasing() ); sb->setBase( zoomBase().top(), zoomBase().bottom() ); sb->moveSlider( zoomRect().top(), zoomRect().bottom() ); if ( !sb->isVisibleTo( canvas() ) ) { sb->show(); layout->setCanvasMargin( layout->canvasMargin( yScrollBarAxis ) + sb->extent(), yScrollBarAxis ); } } else { if ( verticalScrollBar() ) { verticalScrollBar()->hide(); layout->setCanvasMargin( layout->canvasMargin( yScrollBarAxis ) - verticalScrollBar()->extent(), yScrollBarAxis ); } } if ( showHScrollBar && showVScrollBar ) { if ( d_cornerWidget == NULL ) { d_cornerWidget = new QWidget( canvas() ); d_cornerWidget->setAutoFillBackground( true ); d_cornerWidget->setPalette( plot()->palette() ); } d_cornerWidget->show(); } else { if ( d_cornerWidget ) d_cornerWidget->hide(); } layoutScrollBars( canvas()->contentsRect() ); plot()->updateLayout(); }
LogPlotZoomer::LogPlotZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) #else LogPlotZoomer::LogPlotZoomer(QwtPlotCanvas *canvas): QwtPlotZoomer(canvas) #endif {} #if QWT_VERSION > 0x060000 QwtText LogPlotZoomer::trackerTextF(const QwtDoublePoint &pos) const #else QwtText LogPlotZoomer::trackerText(const QwtDoublePoint &pos) const #endif { switch (rubberBand()) { case HLineRubberBand: return QString().sprintf("%.4g", pos.y()); case VLineRubberBand: return QString().sprintf("%.4g", pos.x()); default: return QString().sprintf("%.4g, %.4g", pos.x(), pos.y()); } return QwtText(); // make some dumb compilers happy } /*void QwtPlotZoomer::move(double x, double y) { x = qwtMax(x, zoomBase().left()); x = qwtMin(x, zoomBase().right() - zoomRect().width()); y = qwtMax(y, zoomBase().top()); y = qwtMin(y, zoomBase().bottom() - zoomRect().height()); if (x != zoomRect().left() || y != zoomRect().top()) { d_data->zoomStack[d_data->zoomRectIndex].moveTo(x, y); rescale(); } }*/ #if QWT_VERSION > 0x060000 void LogPlotZoomer::moveTo(const QPointF & pos) { double x = pos.x(); double y = pos.y(); #else void LogPlotZoomer::move(double x, double y) { #endif //QwtPlotZoomer::move(x,y); x = qwtMax(x, (double)zoomBase().left()); x = qwtMin(x, (double)(zoomBase().right() - zoomRect().width())); y = qwtMax(y, (double)zoomBase().top()); y = qwtMin(y, (double)(zoomBase().bottom() - zoomRect().height())); if (x != zoomRect().left() || y != zoomRect().top()) { //zoomStack()[zoomRectIndex()].moveTo(x, y); QwtDoubleRect & rect = const_cast<QwtDoubleRect &>(zoomStack()[zoomRectIndex()]); //handle x axis const int xAxis = QwtPlotZoomer::xAxis(); const QwtScaleEngine *sex = plot()->axisScaleEngine(xAxis); #if QWT_VERSION > 0x060000 if (dynamic_cast<const QwtLogScaleEngine*>(sex)) #else if (dynamic_cast<const QwtLog10ScaleEngine*>(sex)) #endif { //logarithmic double factor = rect.right() / rect.left(); rect.setRight(x * factor); rect.setLeft(x); } else { rect.moveLeft(x); } const int yAxis = QwtPlotZoomer::yAxis(); const QwtScaleEngine *sey = plot()->axisScaleEngine(yAxis); #if QWT_VERSION > 0x060000 if (dynamic_cast<const QwtLogScaleEngine*>(sey)) #else if (dynamic_cast<const QwtLog10ScaleEngine*>(sey)) #endif { //logarithmic double factor = rect.bottom() / rect.top(); rect.setBottom(y * factor); rect.setTop(y); } else { rect.moveTop(y); } //zoomStack()[zoomRectIndex()].moveTo(x, y); rescale(); } }
void ScrollZoomer::moveToHPosition(double x, bool center) { if (center) x -= zoomRect().width() / 2; scrollBarMoved(Qt::Horizontal, x, 0); }