[Marble-commits] KDE/kdeedu/marble
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Thu Aug 19 22:57:33 CEST 2010
SVN commit 1165652 by beschow:
remove MarbleMap::viewParams(), introduce MarbleMap::viewport() instead
Removing access to ViewParams from MarbleMap prevents changing view parameters without MarbleMap's knowledge.
This will allow MarbleMap to set its dirty-flag itself and not rely on the caller to do it => makes using MarbleMap simpler for the caller.
discussed with tackat
M +6 -0 docs/release_notes/APIChanges-0.11.txt
M +17 -6 src/lib/MarbleMap.cpp
M +5 -2 src/lib/MarbleMap.h
M +18 -18 src/lib/MarbleWidget.cpp
M +5 -5 src/lib/MarbleWidgetInputHandler.cpp
M +1 -1 src/lib/routing/AdjustNavigation.cpp
M +1 -1 src/marble_part.cpp
M +5 -5 src/plasmoid/worldclock.cpp
--- trunk/KDE/kdeedu/marble/docs/release_notes/APIChanges-0.11.txt #1165651:1165652
@@ -3,3 +3,9 @@
* The medhod measureTool() has been moved from MarbleMap to MarbleModel.
You can continue accessing the measure tool from MarbleMap using MarbleMapp::model()->measureTool().
+
+* The method ViewParams *viewParams() has been removed from MarbleMap in favor of ViewportParams *viewport().
+ Setting and getting the MapQuality can now be done using MarbleMap::setMapQuality() and MarbleMap::mapQuality().
+ Access to the current AbstractProjection is still possible using MarbleMap::viewport()->currentProjection().
+ MarbleMap::viewParams()->propertyAvailable() can now be reached under MarbleMap::model()->mapTheme()->settings()->propertyAvailable().
+ The canvas and coast images are not accessible any longer by inention. Use MarbleMap::mapScreenShot() to access the resulting map, or implement a plugin to draw onto the map.
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1165651:1165652
@@ -321,12 +321,23 @@
return d->m_model;
}
-ViewParams *MarbleMap::viewParams()
+ViewportParams *MarbleMap::viewport()
{
- return &d->m_viewParams;
+ return d->m_viewParams.viewport();
}
+void MarbleMap::setMapQuality( MapQuality quality )
+{
+ d->m_viewParams.setMapQuality( quality );
+}
+
+MapQuality MarbleMap::mapQuality() const
+{
+ return d->m_viewParams.mapQuality();
+}
+
+
void MarbleMap::setSize( int width, int height )
{
d->m_width = width;
@@ -521,7 +532,7 @@
QPixmap screenshotPixmap( size() );
screenshotPixmap.fill( Qt::transparent );
- GeoPainter painter( &screenshotPixmap, viewParams()->viewport(),
+ GeoPainter painter( &screenshotPixmap, viewport(),
PrintQuality );
painter.begin( &screenshotPixmap );
QRect dirtyRect( QPoint(), size() );
@@ -800,7 +811,7 @@
void MarbleMap::moveLeft()
{
- int polarity = viewParams()->viewport()->polarity();
+ int polarity = viewport()->polarity();
if ( polarity < 0 )
rotateBy( +moveStep(), 0 );
@@ -810,7 +821,7 @@
void MarbleMap::moveRight()
{
- int polarity = viewParams()->viewport()->polarity();
+ int polarity = viewport()->polarity();
if ( polarity < 0 )
rotateBy( -moveStep(), 0 );
@@ -885,7 +896,7 @@
{
Q_UNUSED( painter );
- if ( !viewParams()->mapTheme() ) {
+ if ( !d->m_viewParams.mapTheme() ) {
return;
}
}
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1165651:1165652
@@ -50,7 +50,7 @@
// Marble
class GeoDataLatLonAltBox;
class MarbleModel;
-class ViewParams;
+class ViewportParams;
class SunLocator;
class FileViewModel;
class GeoPainter;
@@ -124,8 +124,11 @@
MarbleModel *model() const;
// Accessors to internal objects;
- ViewParams *viewParams();
+ ViewportParams *viewport();
+ void setMapQuality( MapQuality quality );
+ MapQuality mapQuality() const;
+
void setSize( int width, int height );
void setSize( const QSize& size );
QSize size() const;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1165651:1165652
@@ -186,7 +186,7 @@
// Initialize the map and forward some signals.
m_map->setSize( m_widget->width(), m_widget->height() );
- m_map->viewParams()->setMapQuality( m_stillQuality );
+ m_map->setMapQuality( m_stillQuality );
m_widget->connect( m_map, SIGNAL( projectionChanged( Projection ) ),
m_widget, SIGNAL( projectionChanged( Projection ) ) );
@@ -257,7 +257,7 @@
void MarbleWidgetPrivate::moveByStep( MarbleWidget* widget, int stepsRight, int stepsDown, FlyToMode mode )
{
- int polarity = m_map->viewParams()->viewport()->polarity();
+ int polarity = m_map->viewport()->polarity();
qreal left = polarity * stepsRight * m_map->moveStep();
qreal down = stepsDown * m_map->moveStep();
widget->rotateBy( left, down, mode );
@@ -573,7 +573,7 @@
Quaternion rotPhi( 1.0, deltaLat / 180.0, 0.0, 0.0 );
Quaternion rotTheta( 1.0, 0.0, deltaLon / 180.0, 0.0 );
- Quaternion axis = d->m_map->viewParams()->planetAxis();
+ Quaternion axis = d->m_map->planetAxis();
qreal lon( 0.0 ), lat( 0.0 );
axis.getSpherical( lon, lat );
axis = rotTheta * axis;
@@ -627,7 +627,7 @@
{
Q_UNUSED( animated );
- ViewportParams* viewparams = d->m_map->viewParams()->viewport();
+ ViewportParams* viewparams = d->m_map->viewport();
//prevent divide by zero
if( box.height() && box.width() ) {
//work out the needed zoom level
@@ -775,12 +775,12 @@
QRegion MarbleWidget::activeRegion()
{
- return d->m_map->viewParams()->viewport()->activeRegion();
+ return d->m_map->viewport()->activeRegion();
}
QRegion MarbleWidget::mapRegion()
{
- return d->m_map->viewParams()->currentProjection()->mapRegion( d->m_map->viewParams()->viewport() );
+ return d->m_map->viewport()->currentProjection()->mapRegion( d->m_map->viewport() );
}
void MarbleWidget::paintEvent( QPaintEvent *evt )
@@ -811,8 +811,8 @@
}
// Create a painter that will do the painting.
- GeoPainter painter( paintDevice, map()->viewParams()->viewport(),
- map()->viewParams()->mapQuality(), doClip );
+ GeoPainter painter( paintDevice, map()->viewport(),
+ map()->mapQuality(), doClip );
QRect dirtyRect = evt->rect();
@@ -831,8 +831,8 @@
*pixel = qRgb( gray, gray, gray );
}
- GeoPainter widgetPainter( this, map()->viewParams()->viewport(),
- map()->viewParams()->mapQuality(), doClip );
+ GeoPainter widgetPainter( this, map()->viewport(),
+ map()->mapQuality(), doClip );
widgetPainter.drawImage( rect(), image );
}
@@ -902,7 +902,7 @@
GeoSceneDocument *MarbleWidget::mapTheme() const
{
- return d->m_map->viewParams()->mapTheme();
+ return d->m_model->mapTheme();
}
void MarbleWidget::setPropertyValue( const QString& name, bool value )
@@ -1142,11 +1142,11 @@
}
if ( viewContext() == Still ) {
- map()->viewParams()->setMapQuality( d->m_stillQuality );
+ map()->setMapQuality( d->m_stillQuality );
}
else if ( viewContext() == Animation )
{
- map()->viewParams()->setMapQuality( d->m_animationQuality );
+ map()->setMapQuality( d->m_animationQuality );
}
}
@@ -1160,9 +1160,9 @@
d->m_viewContext = viewContext;
if ( viewContext == Still )
- map()->viewParams()->setMapQuality( d->m_stillQuality );
+ map()->setMapQuality( d->m_stillQuality );
if ( viewContext == Animation )
- map()->viewParams()->setMapQuality( d->m_animationQuality );
+ map()->setMapQuality( d->m_animationQuality );
}
bool MarbleWidget::animationsEnabled() const
@@ -1202,8 +1202,8 @@
mDebug() << "Selection region: (" << tl.x() << ", " << tl.y() << ") ("
<< br.x() << ", " << br.y() << ")" << endl;
- AbstractProjection *proj = d->m_map->viewParams()->currentProjection();
- GeoDataLatLonAltBox box = proj->latLonAltBox( region, d->m_map->viewParams()->viewport() );
+ AbstractProjection *proj = d->m_map->viewport()->currentProjection();
+ GeoDataLatLonAltBox box = proj->latLonAltBox( region, d->m_map->viewport() );
// NOTE: coordinates as lon1, lat1, lon2, lat2 (or West, North, East, South)
// as left/top, right/bottom rectangle.
@@ -1388,7 +1388,7 @@
else {
GeoDataLookAt source = d->m_map->lookAt();
setViewContext( Marble::Animation );
- ViewportParams *viewport = d->m_map->viewParams()->viewport();
+ ViewportParams *viewport = d->m_map->viewport();
d->m_physics->flyTo( source, lookAt, viewport, mode );
}
}
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1165651:1165652
@@ -235,7 +235,7 @@
return;
}
- ViewportParams* now = marbleWidget->map()->viewParams()->viewport();
+ ViewportParams* now = marbleWidget->map()->viewport();
qreal x(0), y(0);
if (!now->currentProjection()->screenCoordinates(destLon, destLat, now, x, y)) {
@@ -267,7 +267,7 @@
lookAt.setAltitude( 0.0 );
lookAt.setRange( newDistance * KM2METER );
- marbleWidget->map()->viewParams()->viewport()->setFocusPoint( GeoDataCoordinates( destLon,
+ marbleWidget->map()->viewport()->setFocusPoint( GeoDataCoordinates( destLon,
destLat ) );
marbleWidget->flyTo( lookAt, Linear );
}
@@ -333,7 +333,7 @@
d->m_widget->updateChangedMap();
}
- d->m_widget->map()->viewParams()->viewport()->resetFocusPoint();
+ d->m_widget->map()->viewport()->resetFocusPoint();
d->m_wheelZoomTargetDistance = 0.0;
}
@@ -432,7 +432,7 @@
return true;
}
- int polarity = MarbleWidgetInputHandler::d->m_widget->map()->viewParams()->viewport()->polarity();
+ int polarity = MarbleWidgetInputHandler::d->m_widget->map()->viewport()->polarity();
if ( e->type() == QEvent::MouseMove
|| e->type() == QEvent::MouseButtonPress
@@ -783,7 +783,7 @@
destLon, destLat, GeoDataCoordinates::Radian );
if (isValid) {
- marbleWidget->map()->viewParams()->viewport()->setFocusPoint(GeoDataCoordinates(destLon, destLat));
+ marbleWidget->map()->viewport()->setFocusPoint(GeoDataCoordinates(destLon, destLat));
}
//convert the scaleFactor to be 0: the same: < 0: smaller, > 0: bigger and make it bigger by multiplying for an arbitrary big value
--- trunk/KDE/kdeedu/marble/src/lib/routing/AdjustNavigation.cpp #1165651:1165652
@@ -156,7 +156,7 @@
m_widget->centerOn( position, false );
}
else {
- ViewportParams const * const viewparams = m_widget->map()->viewParams()->viewport();
+ ViewportParams const * const viewparams = m_widget->map()->viewport();
qreal width = viewparams->width();
qreal height = viewparams->height();
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1165651:1165652
@@ -1179,7 +1179,7 @@
m_downloadRegionDialog->setAllowedTileLevelRange( 0, 18 );
m_downloadRegionDialog->setSelectionMethod( DownloadRegionDialog::VisibleRegionMethod );
ViewportParams const * const viewport =
- m_controlView->marbleWidget()->map()->viewParams()->viewport();
+ m_controlView->marbleWidget()->map()->viewport();
m_downloadRegionDialog->setSpecifiedLatLonAltBox( viewport->viewLatLonAltBox() );
m_downloadRegionDialog->setVisibleLatLonAltBox( viewport->viewLatLonAltBox() );
m_downloadRegionDialog->setVisibleTileLevel( model->tileZoomLevel() );
--- trunk/KDE/kdeedu/marble/src/plasmoid/worldclock.cpp #1165651:1165652
@@ -232,8 +232,8 @@
QString WorldClock::getZone()
{
qreal lat, lon;
- bool ok = m_map->viewParams()->viewport()->currentProjection()->geoCoordinates(
- m_hover.x(), m_hover.y(), m_map->viewParams()->viewport(), lon, lat );
+ bool ok = m_map->viewport()->currentProjection()->geoCoordinates(
+ m_hover.x(), m_hover.y(), m_map->viewport(), lon, lat );
QString timezone;
if( !ok ) {
@@ -355,7 +355,7 @@
//p->drawRect( m_lastRect );
QPixmap pixmap( m_map->width(), m_map->height() );
pixmap.fill( Qt::transparent );
- GeoPainter gp( &pixmap, m_map->viewParams()->viewport(),
+ GeoPainter gp( &pixmap, m_map->viewport(),
Marble::NormalQuality, true );
QRect mapRect( 0, 0, m_map->width(), m_map->height() );
m_map->paint(gp, mapRect );
@@ -370,8 +370,8 @@
qreal tzy = 0;
qreal lon = m_locations.value(m_locationkey).longitude() * DEG2RAD;
qreal lat = m_locations.value(m_locationkey).latitude() * DEG2RAD;
- bool ok = m_map->viewParams()->viewport()->currentProjection()
- ->screenCoordinates(lon, lat, m_map->viewParams()->viewport(), tzx, tzy);
+ bool ok = m_map->viewport()->currentProjection()
+ ->screenCoordinates(lon, lat, m_map->viewport(), tzx, tzy);
if ( ok /*&& m_isHovered*/ ) {
QPoint tz( tzx, tzy );
tz += m_t;
More information about the Marble-commits
mailing list