[Kde-bindings] KDE/kdeedu/marble
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sat Nov 13 13:59:33 UTC 2010
SVN commit 1196449 by beschow:
cleanup MarbleMap::setSize(), add ViewParams::setSize(), remove ViewParams::set{Canvas, Coast}Image
* remove MarbleMapPrivate::{m_width, m_heigt} such that ViewParams is the single point of truth for the map size
* handle canvas and coast image resizing in ViewParams::setSize(), removing the need for ViewParams::set{Canvas, Coast}Image
note for bindings: ViewParams is exported
CCMAIL: kde-bindings at kde.org
M +6 -0 docs/release_notes/APIChanges-0.11.txt
M +7 -39 src/lib/MarbleMap.cpp
M +0 -3 src/lib/MarbleMap_p.h
M +18 -11 src/lib/ViewParams.cpp
M +9 -2 src/lib/ViewParams.h
--- trunk/KDE/kdeedu/marble/docs/release_notes/APIChanges-0.11.txt #1196448:1196449
@@ -50,3 +50,9 @@
* Remove or make private Marble{Map, Widget}::{needsUpdate(), setNeedsUpdate(), updateChangedMap()}.
There is no need to call these methods any more since they are invoked internally when needed.
It should be safe to remove any code that calls these methods from outside MarbleMap/MarbleWidget.
+
+2010-11-13 Bernhard Beschow <bbeschow at cs.tu-berlin.de>
+
+* Remove ViewParams::set{Canvas, Coast}Image. Introduce ViewParams::setSize().
+ Instead of manually setting the canvas and coast images to the same size already specified in ViewParams::ViewportParams (using setCanvasImage and setCoastImage),
+ calling setSize will update the viewportParam's and the images sizes and keep them synchronized.
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1196448:1196449
@@ -94,29 +94,6 @@
m_parent, SIGNAL( repaintNeeded( QRegion ) ) );
}
-// Used to be resizeEvent()
-void MarbleMapPrivate::doResize()
-{
- QSize size( m_parent->width(), m_parent->height() );
- m_viewParams.viewport()->setSize( size );
-
- // If the globe covers fully the screen then we can use the faster
- // RGB32 as there are no translucent areas involved.
- QImage::Format imageFormat = ( m_parent->mapCoversViewport() )
- ? QImage::Format_RGB32
- : QImage::Format_ARGB32_Premultiplied;
-
- // Recreate the canvas image with the new size.
- m_viewParams.setCanvasImage( new QImage( m_parent->width(), m_parent->height(),
- imageFormat ));
-
- // Recreate the coastline detection offscreen image
- m_viewParams.setCoastImage( new QImage( m_parent->width(), m_parent->height(),
- QImage::Format_RGB32 ));
-
- m_justModified = true;
-}
-
void MarbleMapPrivate::paintMarbleSplash( GeoPainter &painter, QRect &dirtyRect )
{
Q_UNUSED( dirtyRect )
@@ -219,10 +196,6 @@
MarbleMap::~MarbleMap()
{
- // Some basic initializations.
- d->m_width = 0;
- d->m_height = 0;
-
if ( d->m_modelIsOwned )
delete d->m_model;
delete d;
@@ -254,35 +227,30 @@
void MarbleMap::setSize( int width, int height )
{
- d->m_width = width;
- d->m_height = height;
-
- d->doResize();
+ d->m_viewParams.setSize( width, height );
emit visibleLatLonAltBoxChanged( d->m_viewParams.viewport()->viewLatLonAltBox() );
+
+ setNeedsUpdate();
}
void MarbleMap::setSize( const QSize& size )
{
- d->m_width = size.width();
- d->m_height = size.height();
-
- d->doResize();
- emit visibleLatLonAltBoxChanged( d->m_viewParams.viewport()->viewLatLonAltBox() );
+ setSize( size.width(), size.height() );
}
QSize MarbleMap::size() const
{
- return QSize( d->m_width, d->m_height );
+ return QSize( d->m_viewParams.width(), d->m_viewParams.height() );
}
int MarbleMap::width() const
{
- return d->m_width;
+ return d->m_viewParams.width();
}
int MarbleMap::height() const
{
- return d->m_height;
+ return d->m_viewParams.height();
}
Quaternion MarbleMap::planetAxis() const
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap_p.h #1196448:1196449
@@ -42,7 +42,6 @@
void paintMarbleSplash( GeoPainter &painter, QRect &dirtyRect );
void setBoundingBox();
- void doResize();
void paintGround( GeoPainter &painter, QRect &dirtyRect);
void paintFps( GeoPainter &painter, QRect &dirtyRect, qreal fps);
@@ -53,8 +52,6 @@
MarbleModel *m_model;
bool m_modelIsOwned;
- int m_width;
- int m_height;
ViewParams m_viewParams;
bool m_justModified; // FIXME: Rename to isDirty
--- trunk/KDE/kdeedu/marble/src/lib/ViewParams.cpp #1196448:1196449
@@ -274,31 +274,38 @@
return d->m_canvasImage->height();
}
-QImage * ViewParams::canvasImage() const
+void ViewParams::setSize( int width, int height )
{
- return d->m_canvasImage;
-}
+ d->m_viewport.setSize( QSize( width, height ) );
-void ViewParams::setCanvasImage( QImage * const image )
-{
+ // If the globe covers fully the screen then we can use the faster
+ // RGB32 as there are no translucent areas involved.
+ QImage::Format imageFormat = ( d->m_viewport.mapCoversViewport() )
+ ? QImage::Format_RGB32
+ : QImage::Format_ARGB32_Premultiplied;
+
+ // Recreate the canvas image with the new size.
delete d->m_canvasImage;
- d->m_canvasImage = image;
+ d->m_canvasImage = new QImage( width, height, imageFormat );
// Repaint the background if necessary
if ( !currentProjection()->mapCoversViewport( viewport() ) ) {
d->m_canvasImage->fill(0); // Using Qt::transparent is wrong here (equals "18")!
}
+
+ // Recreate the coastline detection offscreen image
+ delete d->m_coastImage;
+ d->m_coastImage = new QImage( width, height, QImage::Format_RGB32 );
}
-QImage * ViewParams::coastImage() const
+QImage * ViewParams::canvasImage() const
{
- return d->m_coastImage;
+ return d->m_canvasImage;
}
-void ViewParams::setCoastImage( QImage * const image )
+QImage * ViewParams::coastImage() const
{
- delete d->m_coastImage;
- d->m_coastImage = image;
+ return d->m_coastImage;
}
bool ViewParams::showGps() const
--- trunk/KDE/kdeedu/marble/src/lib/ViewParams.h #1196448:1196449
@@ -105,11 +105,18 @@
int width() const;
int height() const;
+ /**
+ * @brief Sets the size of the viewport and the sizes of
+ * canvasImage and coastImage.
+ *
+ * @param width new width of viewport
+ * @param height new height of viewport
+ */
+ void setSize( int width, int height );
+
QImage * canvasImage() const;
- void setCanvasImage( QImage * const );
QImage * coastImage() const;
- void setCoastImage( QImage * const );
bool showGps() const;
void setShowGps( bool );
More information about the Kde-bindings
mailing list