[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Thu Jan 7 23:04:36 CET 2010
SVN commit 1071370 by nienhueser:
Introduce a focus point (move-invariant point when zooming) in ViewportParams, used by the default input handler and the crosshair plugin to indicate a non screen-centric zoom action to the user.
CCBUG: 177591
M +3 -0 lib/MarbleWidgetInputHandler.cpp
M +34 -1 lib/ViewportParams.cpp
M +29 -0 lib/ViewportParams.h
M +9 -3 plugins/render/crosshairs/CrosshairsPlugin.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1071369:1071370
@@ -221,6 +221,8 @@
{
d->m_widget->updateChangedMap();
}
+
+ d->m_widget->map()->viewParams()->viewport()->resetFocusPoint();
}
void MarbleWidgetInputHandler::installPluginEventFilter( RenderPlugin *renderPlugin )
@@ -618,6 +620,7 @@
qreal lat = destLat - (mouseLat - centerLat);
marbleWidget->centerOn( RAD2DEG * lon, RAD2DEG * lat );
}
+ marbleWidget->map()->viewParams()->viewport()->setFocusPoint(GeoDataCoordinates(destLon, destLat));
marbleWidget->setUpdatesEnabled( true );
MarbleWidgetInputHandler::d->m_mouseWheelTimer->start( 400 );
--- trunk/KDE/kdeedu/marble/src/lib/ViewportParams.cpp #1071369:1071370
@@ -54,6 +54,10 @@
static SphericalProjection s_sphericalProjection;
static EquirectProjection s_equirectProjection;
static MercatorProjection s_mercatorProjection;
+
+ GeoDataCoordinates m_focusPoint;
+ bool m_hasFocusPoint;
+
};
ViewportParamsPrivate::ViewportParamsPrivate()
@@ -66,7 +70,8 @@
m_dirtyBox( true ),
m_viewLatLonAltBox(),
m_dirtyRegion( true ),
- m_activeRegion()
+ m_activeRegion(),
+ m_hasFocusPoint(false)
{
}
@@ -386,5 +391,33 @@
return d->m_activeRegion;
}
+GeoDataCoordinates ViewportParams::focusPoint() const
+{
+ if (d->m_hasFocusPoint) {
+ return d->m_focusPoint;
+ }
+ else {
+ qreal lon, lat;
+ centerCoordinates(lon, lat);
+ return GeoDataCoordinates(lon, lat, 0.0, GeoDataCoordinates::Radian);
+ }
}
+
+void ViewportParams::setFocusPoint(const GeoDataCoordinates &focusPoint)
+{
+ d->m_focusPoint = focusPoint;
+ d->m_hasFocusPoint = true;
+}
+
+void ViewportParams::resetFocusPoint()
+{
+ d->m_hasFocusPoint = false;
+}
+
+bool ViewportParams::focusPointIsCenter() const
+{
+ return !d->m_hasFocusPoint;
+}
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/ViewportParams.h #1071369:1071370
@@ -103,6 +103,35 @@
QRegion activeRegion() const;
+ /**
+ * @return The current point of focus, e.g. the point that is not moved
+ * when changing the zoom level. If not set, it defaults to the
+ * center point.
+ * @see centerCoordinates setFocusPoint resetFocusPoint focusPointIsCenter
+ */
+ GeoDataCoordinates focusPoint() const;
+
+ /**
+ * @brief Change the point of focus, overridding any previously set focus point.
+ * @param focusPoint New focus point
+ * @see focusPoint resetFocusPoint focusPointIsCenter
+ */
+ void setFocusPoint(const GeoDataCoordinates &focusPoint);
+
+ /**
+ * @brief Invalidate any focus point set with @ref setFocusPoint.
+ * @see focusPoint setFocusPoint focusPointIsCenter
+ */
+ void resetFocusPoint();
+
+ /**
+ * @brief Determine whether the focus point is different from the center point
+ * @return False iff an explicit focus point was set with @ref setFocusPoint
+ * and @ref resetFocusPoint has not been called afterwards
+ * @see focusPoint setFocusPoint resetFocusPoint
+ */
+ bool focusPointIsCenter() const;
+
private:
Q_DISABLE_COPY( ViewportParams )
ViewportParamsPrivate * const d;
--- trunk/KDE/kdeedu/marble/src/plugins/render/crosshairs/CrosshairsPlugin.cpp #1071369:1071370
@@ -10,6 +10,7 @@
#include "CrosshairsPlugin.h"
+#include "AbstractProjection.h"
#include "MarbleDebug.h"
#include "GeoPainter.h"
@@ -74,12 +75,17 @@
Q_UNUSED( layer )
if ( renderPos == "ALWAYS_ON_TOP" ) {
- int centerx = viewport->width() / 2;
- int centery = viewport->height() / 2;
+ qreal centerx = viewport->width() / 2;
+ qreal centery = viewport->height() / 2;
int boxwidth = 6;
int boxheight = 2;
int boxoffset = 4;
+ GeoDataCoordinates focusPoint = viewport->focusPoint();
+ if (!viewport->focusPointIsCenter()) {
+ viewport->currentProjection()->screenCoordinates(focusPoint, viewport, centerx, centery);
+ }
+
painter->save();
painter->setRenderHint( QPainter::Antialiasing, false );
@@ -90,7 +96,7 @@
painter->drawRect( centerx - 1, centery - boxoffset - boxwidth, boxheight, boxwidth );
painter->drawRect( centerx - 1, centery + boxoffset, boxheight, boxwidth );
-
+
/*
painter->drawLine( centerx - halfsize, centery,
centerx + halfsize, centery );
More information about the Marble-commits
mailing list