[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Wed Aug 25 10:47:27 CEST 2010
SVN commit 1167757 by nienhueser:
Extend LayerInterface to allow specifying a z value defining the paint order of sibling layers. Paint position marker antialised and on top of the route.
RB: 5080
M +7 -0 lib/LayerInterface.cpp
M +6 -0 lib/LayerInterface.h
M +19 -2 lib/LayerManager.cpp
M +1 -1 lib/RenderPluginInterface.h
M +6 -0 plugins/render/positionmarker/PositionMarker.cpp
M +3 -0 plugins/render/positionmarker/PositionMarker.h
--- trunk/KDE/kdeedu/marble/src/lib/LayerInterface.cpp #1167756:1167757
@@ -18,4 +18,11 @@
// nothing to do
}
+
+qreal LayerInterface::zValue() const
+{
+ return 0.0;
+}
+
+
} // namespace Marble
--- trunk/KDE/kdeedu/marble/src/lib/LayerInterface.h #1167756:1167757
@@ -56,6 +56,12 @@
virtual bool render( GeoPainter *painter, ViewportParams *viewport,
const QString& renderPos = "NONE", GeoSceneLayer * layer = 0 ) = 0;
+ /**
+ * @brief Returns the z value of the layer (default: 0.0). If two layers are painted
+ * at the same render position, the one with the higher z value is painted on top.
+ * If both have the same z value, their paint order is undefined.
+ */
+ virtual qreal zValue() const;
};
} // namespace Marble
--- trunk/KDE/kdeedu/marble/src/lib/LayerManager.cpp #1167756:1167757
@@ -33,6 +33,16 @@
namespace Marble
{
+/**
+ * Returns true if the zValue of one is lower than that of two. Null must not be passed
+ * as parameter.
+ */
+bool zValueLessThan( const LayerInterface * const one, const LayerInterface * const two )
+{
+ Q_ASSERT( one && two );
+ return one->zValue() < two->zValue();
+}
+
class LayerManagerPrivate
{
public:
@@ -137,6 +147,8 @@
ViewportParams* viewport = viewParams->viewport();
+ QList<LayerInterface*> layers;
+
foreach( RenderPlugin *renderPlugin, d->m_renderPlugins ) {
if ( renderPlugin && renderPlugin->renderPosition().contains( renderPosition ) ){
if ( renderPlugin->enabled() && renderPlugin->visible() ) {
@@ -145,17 +157,22 @@
renderPlugin->initialize();
emit renderPluginInitialized( renderPlugin );
}
- renderPlugin->render( painter, viewport, renderPosition );
+ layers.push_back( renderPlugin );
}
}
}
foreach( LayerInterface *layer, d->m_internalLayers) {
if ( layer && layer->renderPosition().contains( renderPosition )) {
+ layers.push_back( layer );
+ }
+ }
+
+ qSort( layers.begin(), layers.end(), zValueLessThan );
+ foreach( LayerInterface *layer, layers ) {
layer->render(painter, viewport, renderPosition);
}
}
-}
void LayerManager::loadLayers()
{
--- trunk/KDE/kdeedu/marble/src/lib/RenderPluginInterface.h #1167756:1167757
@@ -69,6 +69,6 @@
}
-Q_DECLARE_INTERFACE( Marble::RenderPluginInterface, "org.kde.Marble.RenderPluginInterface/1.05" )
+Q_DECLARE_INTERFACE( Marble::RenderPluginInterface, "org.kde.Marble.RenderPluginInterface/1.06" )
#endif
--- trunk/KDE/kdeedu/marble/src/plugins/render/positionmarker/PositionMarker.cpp #1167756:1167757
@@ -151,6 +151,7 @@
}
update();
painter->save();
+ painter->autoMapQuality();
painter->setPen( Qt::black );
painter->setBrush( Qt::white );
painter->drawPolygon( m_arrow );
@@ -170,8 +171,13 @@
}
}
+qreal PositionMarker::zValue() const
+{
+ return 1.0;
}
+}
+
Q_EXPORT_PLUGIN2( PositionMarker, Marble::PositionMarker )
#include "PositionMarker.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/positionmarker/PositionMarker.h #1167756:1167757
@@ -55,6 +55,9 @@
void update();
+ // Overriding LayerInterface to paint on top of the route
+ virtual qreal zValue() const;
+
public slots:
void setPosition( const GeoDataCoordinates &position );
More information about the Marble-commits
mailing list