[Marble-commits] KDE/kdeedu/marble/src/lib
Bastian Holst
bastianholst at gmx.de
Sun Jul 11 14:47:08 CEST 2010
SVN commit 1148651 by bholst:
Marking Marble's northPoleY() as deprecated and added replacement method.
M +14 -4 MarbleMap.cpp
M +17 -2 MarbleMap.h
M +11 -1 MarbleWidget.cpp
M +15 -2 MarbleWidget.h
M +2 -4 MarbleWidgetInputHandler.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1148650:1148651
@@ -858,13 +858,23 @@
int MarbleMap::northPoleY()
{
- Quaternion northPole = GeoDataCoordinates( 0.0, M_PI * 0.5 ).quaternion();
- Quaternion invPlanetAxis = d->m_viewParams.planetAxis().inverse();
+ return northPolePosition().y();
+}
- northPole.rotateAroundAxis( invPlanetAxis );
- return (int)( d->m_viewParams.radius() * northPole.v[Q_Y] );
+QPoint MarbleMap::northPolePosition()
+{
+ qreal x, y;
+ screenCoordinates( 0.0, 90.0, x, y );
+ return QPoint( (int) x, (int) y );
}
+QPoint MarbleMap::southPolePosition()
+{
+ qreal x, y;
+ screenCoordinates( 0.0, -90.0, x, y );
+ return QPoint( (int) x, (int) y );
+}
+
bool MarbleMap::screenCoordinates( qreal lon, qreal lat,
qreal& x, qreal& y )
{
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1148650:1148651
@@ -202,11 +202,26 @@
/**
* @brief Get the Y coordinate of the North Pole.
- * @return the pixel address of the geographical north pole.
+ * @return the pixel address of the geographical north pole relative to the center of the widget.
+ * This method is deprecated because it returns an unintuitive result.
+ * Use @see northPolePosition()
+ * or @see southPolePosition()
*/
- int northPoleY();
+ MARBLE_DEPRECATED(int northPoleY());
/**
+ * @brief Get the pixel position of the North Pole.
+ * @return The pixel position of the geographical north pole.
+ */
+ QPoint northPolePosition();
+
+ /**
+ * @brief Get the pixel position of the South Pole.
+ * @return The pixel position of the geographical south pole.
+ */
+ QPoint southPolePosition();
+
+ /**
* @brief Get the earth coordinates corresponding to a pixel in the map.
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1148650:1148651
@@ -738,9 +738,19 @@
int MarbleWidget::northPoleY()
{
- return d->m_map->northPoleY();
+ return northPolePosition().y();
}
+QPoint MarbleWidget::northPolePosition()
+{
+ return d->m_map->northPolePosition();
+}
+
+QPoint MarbleWidget::southPolePosition()
+{
+ return d->m_map->southPolePosition();
+}
+
bool MarbleWidget::screenCoordinates( qreal lon, qreal lat,
qreal& x, qreal& y )
{
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1148650:1148651
@@ -263,11 +263,24 @@
/**
* @brief Get the Y coordinate of the North Pole.
- * @return the pixel address of the geographical north pole.
+ * @return the pixel address of the geographical north pole relative to the center of the widget.
+ * This method is deprecated because it returns an unintuitive result.
*/
- int northPoleY();
+ MARBLE_DEPRECATED(int northPoleY());
/**
+ * @brief Get the pixel position of the North Pole.
+ * @return The pixel position of the geographical north pole.
+ */
+ QPoint northPolePosition();
+
+ /**
+ * @brief Get the pixel position of the South Pole.
+ * @return The pixel position of the geographical south pole.
+ */
+ QPoint southPolePosition();
+
+ /**
* @brief Get the earth coordinates corresponding to a pixel in the widget.
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1148650:1148651
@@ -521,14 +521,12 @@
if ( MarbleWidgetInputHandler::d->m_widget->projection() == Spherical ) {
if ( d->m_leftPressedLat >= 0 ) {
// The visible pole is the north pole
- if ( event->y() < ( - MarbleWidgetInputHandler::d->m_widget->northPoleY()
- + MarbleWidgetInputHandler::d->m_widget->height() / 2 ) )
+ if ( event->y() < MarbleWidgetInputHandler::d->m_widget->northPolePosition().y() )
d->m_leftPressedDirection = -1;
}
else {
// The visible pole is the south pole
- if ( event->y() > ( + MarbleWidgetInputHandler::d->m_widget->northPoleY()
- + MarbleWidgetInputHandler::d->m_widget->height() / 2 ) )
+ if ( event->y() > MarbleWidgetInputHandler::d->m_widget->southPolePosition().y() )
d->m_leftPressedDirection = -1;
}
}
More information about the Marble-commits
mailing list