[Marble-commits] KDE/kdeedu/marble/src
Andrew Manson
g.real.ate at gmail.com
Mon Jul 27 19:50:21 CEST 2009
SVN commit 1003119 by mansona:
Implement the zoom half of the "Fly to opened file" feature. Needs to fix
bug 201681 before the centerOn half can be added.
M +17 -0 lib/MarbleWidget.cpp
M +10 -0 lib/MarbleWidget.h
M +2 -2 lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp
M +1 -0 plugins/render/osmannotate/OsmAnnotatePlugin.cpp
M +5 -0 plugins/render/osmannotate/osm/OsmBoundsGraphicsItem.cpp
M +1 -0 plugins/render/osmannotate/osm/OsmBoundsGraphicsItem.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1003118:1003119
@@ -582,6 +582,23 @@
repaint();
}
+void MarbleWidget::centerOn( const GeoDataLatLonBox &box, bool animated )
+{
+ //FIXME: actually centerOn the middle of the bounding box once BUG:201681 is fixed
+ qDebug() << Q_FUNC_INFO;
+ qDebug() << "Centering on: " << box.center().toString();
+
+ ViewportParams* viewparams = d->m_map->viewParams()->viewport();
+ int bigestScreenSize = viewparams->height() > viewparams->width() ?
+ viewparams->height() : viewparams->width();
+
+ qreal bigestBoundingSize = box.height() > box.width() ? box.height() : box.width();
+
+ int zoomRadius = ( 0.25 * M_PI ) * ( bigestScreenSize / bigestBoundingSize );
+
+ setRadius( zoomRadius );
+}
+
void MarbleWidget::updateAnimation( qreal updateValue )
{
GeoDataCoordinates position = d->m_physics->suggestedPosition();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1003118:1003119
@@ -55,6 +55,7 @@
class SunLocator;
class GpxFileModel;
class FileViewModel;
+class GeoDataLatLonBox;
class GeoPainter;
class RenderPlugin;
class AbstractFloatItem;
@@ -631,6 +632,15 @@
void centerOn( const GeoDataCoordinates &point, bool animated = false );
/**
+ * @brief Center the view on a bounding box so that it completley fills the viewport
+ * This method not only centers on the center of the GeoDataLatLon box but it also
+ * adjusts the zoom of the marble widget so that the LatLon box provided fills
+ * the viewport
+ * @param box The GeoDataLatLonBox to zoom and move the MarbleWidget to.
+ */
+ void centerOn( const GeoDataLatLonBox& box, bool animated = false );
+
+ /**
* @brief Set the latitude for the center point
* @param lat the new value for the latitude
*/
--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp #1003118:1003119
@@ -22,12 +22,12 @@
void GeoPointGraphicsItem::setPoint( const GeoDataPoint& point )
{
- m_point = GeoDataPoint( point );
+ m_point = point;
}
GeoDataPoint GeoPointGraphicsItem::point()
{
- return GeoDataPoint(m_point);
+ return m_point;
}
void GeoPointGraphicsItem::paint( GeoPainter* painter, ViewportParams* viewport,
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #1003118:1003119
@@ -212,6 +212,7 @@
// m_marbleWidget->centerOn( item->coordinate(), false );
//get the zoom level
// difficult?
+ m_marbleWidget->centerOn( item->latLonBox() );
}
}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmBoundsGraphicsItem.cpp #1003118:1003119
@@ -46,4 +46,9 @@
}
+GeoDataLatLonBox OsmBoundsGraphicsItem::latLonBox()
+{
+ return GeoDataLatLonBox( m_lineString.latLonAltBox() );
}
+
+}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmBoundsGraphicsItem.h #1003118:1003119
@@ -33,6 +33,7 @@
virtual void paint( GeoPainter* painter, ViewportParams *viewport,
const QString &renderPos, GeoSceneLayer *layer );
+ virtual GeoDataLatLonBox latLonBox();
private:
/**
* This class is using a GeoDataLineString as its data representation so
More information about the Marble-commits
mailing list