void NavigationWidget::leaveEvent(QEvent *e) { QWidget::leaveEvent(e); QPropertyAnimation * ani = new QPropertyAnimation(this, "zoomLevel"); ani->setDuration(300); ani->setEndValue(zoomLevel()); ani->setEndValue(1); ani->start(QPropertyAnimation::DeleteWhenStopped); }
void ItemView::zoomOut(const QPoint & center) { // NOTE The code in this function is nearly the same as that in zoomIn. // Any updates to this code should also be done to zoomIn // Previous position of center in widget coordinates QPoint previous = center * zoomLevel() - QPoint(cvbEditor()->contentsX(), cvbEditor()->contentsY()); // Don't repaint the view until we've also shifted it cvbEditor()->viewport()->setUpdatesEnabled(false); zoomOut(); // Adjust the contents' position to ensure that "previous" remains fixed QPoint offset = center * zoomLevel() - previous; cvbEditor()->setContentsPos(offset.x(), offset.y()); cvbEditor()->viewport()->setUpdatesEnabled(true); cvbEditor()->viewport()->update(); }
/*! \internal Sets the gesture areas maximum zoom level. If the camera capabilities has been set this method honors the boundaries set by it. */ void QDeclarativeGeoMap::setMaximumZoomLevel(qreal maximumZoomLevel) { if (gestureArea_ && maximumZoomLevel >= 0) { if (mappingManagerInitialized_ && maximumZoomLevel > mappingManager_->cameraCapabilities().maximumZoomLevel()) { maximumZoomLevel = mappingManager_->cameraCapabilities().maximumZoomLevel(); } gestureArea_->setMaximumZoomLevel(maximumZoomLevel); setZoomLevel(qBound<qreal>(minimumZoomLevel(), zoomLevel(), maximumZoomLevel)); } }
void NavigationWidget::enterEvent(QEvent *e) { QWidget::enterEvent(e); QPropertyAnimation * ani = new QPropertyAnimation(this, "zoomLevel"); ani->setDuration(300); ani->setStartValue(zoomLevel()); ani->setEndValue(1.2); ani->start(QPropertyAnimation::DeleteWhenStopped); emit mouseEntered(); }
void ItemView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; e->accept(); //HACK: Pass this of as a single press event if widget underneath QCanvasItem * atTop = p_itemDocument->itemAtTop(e->pos() / zoomLevel()); if (dynamic_cast<Widget*>(atTop)) contentsMousePressEvent(e); else p_itemDocument->m_cmManager->mouseDoubleClickEvent(EventInfo(this, e)); }
void CartesianWidget::zoomOut() { if (zoom() < ZOOM_MAXIMUM) { setScale(scaleX() - SCALE_STP, scaleY() - SCALE_STP); if (scaleX() < SCALE_MIN) { setScale(SCALE_MAX, SCALE_MAX); setZoomLevel(zoomLevel()+1); } } update(); }
void CartesianWidget::zoomIn() { if (zoom() > ZOOM_MINIMUM) { setScale(scaleX() + SCALE_STP, scaleY() + SCALE_STP); if (scaleX() > SCALE_MAX) { setScale(SCALE_MIN, SCALE_MIN); setZoomLevel(zoomLevel()-1); } } update(); }
/*! \internal Sets the gesture areas maximum zoom level. If the camera capabilities has been set this method honors the boundaries set by it. */ void QDeclarativeGeoMap::setMaximumZoomLevel(qreal maximumZoomLevel) { if (m_gestureArea && maximumZoomLevel >= 0) { qreal oldMaximumZoomLevel = this->maximumZoomLevel(); if (m_mappingManagerInitialized && maximumZoomLevel > m_mappingManager->cameraCapabilities().maximumZoomLevel()) { maximumZoomLevel = m_mappingManager->cameraCapabilities().maximumZoomLevel(); } m_gestureArea->setMaximumZoomLevel(maximumZoomLevel); setZoomLevel(qBound<qreal>(minimumZoomLevel(), zoomLevel(), maximumZoomLevel)); if (oldMaximumZoomLevel != maximumZoomLevel) emit maximumZoomLevelChanged(); } }
void CartesianWidget::setXRange(double a, double b) { setCenter((a+b)/2.0, centerY()); if (xmax()-xmin() > (b-a)) { while ( xmax()-xmin() > (b-a) ) { setZoomLevel(zoomLevel()-1); } if ( xmax()-xmin() < (b-a) ) { setZoomLevel(zoomLevel()+1); } } else { while ( xmax()-xmin() < (b-a) ) { setZoomLevel(zoomLevel()+1); } } update(); }
void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item) { if (!m_initialized) { auto qquickMapbox = static_cast<QQuickMapboxGL*>(item); QObject::connect(m_map.data(), &QMapboxGL::needsRendering, qquickMapbox, &QQuickMapboxGL::update); QObject::connect(this, &QQuickMapboxGLRenderer::centerChanged, qquickMapbox, &QQuickMapboxGL::setCenter); m_initialized = true; } auto quickMap = static_cast<QQuickMapboxGL*>(item); auto syncStatus = quickMap->swapSyncState(); if (syncStatus & QQuickMapboxGL::CenterNeedsSync || syncStatus & QQuickMapboxGL::ZoomNeedsSync) { const auto& center = quickMap->center(); m_map->setCoordinateZoom({ center.latitude(), center.longitude() }, quickMap->zoomLevel()); } if (syncStatus & QQuickMapboxGL::StyleNeedsSync) { m_map->setStyleURL(quickMap->style()); } if (syncStatus & QQuickMapboxGL::PanNeedsSync) { m_map->moveBy(quickMap->swapPan()); emit centerChanged(QGeoCoordinate(m_map->latitude(), m_map->longitude())); } if (syncStatus & QQuickMapboxGL::BearingNeedsSync) { m_map->setBearing(quickMap->bearing()); } if (syncStatus & QQuickMapboxGL::PitchNeedsSync) { m_map->setPitch(quickMap->pitch()); } if (syncStatus & QQuickMapboxGL::ColorNeedsSync && m_map->isFullyLoaded()) { m_map->setPaintProperty("background", "background-color", quickMap->color()); } }
void EditorWidget::zoomLevelChanged() { // Let people know that the zoom level has changed emit zoomLevelChanged(zoomLevel()); }
QPoint ItemView::mousePosToCanvasPos(const QPoint & contentsClick) const { QPoint offsetPos = contentsClick + QPoint(cvbEditor()->contentsX(), cvbEditor()->contentsY()); return (offsetPos / zoomLevel()) + p_itemDocument->canvas()->rect().topLeft(); }