[QGIS Commit] r12961 - in trunk/qgis: . src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Feb 22 04:55:10 EST 2010
Author: wonder
Date: 2010-02-22 04:55:08 -0500 (Mon, 22 Feb 2010)
New Revision: 12961
Modified:
trunk/qgis/CONTRIBUTORS
trunk/qgis/src/core/qgsvectorlayer.cpp
trunk/qgis/src/core/qgsvectorlayer.h
Log:
Applied patch from #2461: add support for incremental rendering with symbology-ng.
Fixes $2409.
Contributed by Jeremy Palmer, thanks!
Modified: trunk/qgis/CONTRIBUTORS
===================================================================
--- trunk/qgis/CONTRIBUTORS 2010-02-21 19:23:01 UTC (rev 12960)
+++ trunk/qgis/CONTRIBUTORS 2010-02-22 09:55:08 UTC (rev 12961)
@@ -42,3 +42,4 @@
Alexander Bruy
Andres Manz
Mark Baas
+Jeremy Palmer
Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp 2010-02-21 19:23:01 UTC (rev 12960)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp 2010-02-22 09:55:08 UTC (rev 12961)
@@ -718,11 +718,35 @@
selRenderer->startRender( rendererContext, this );
}
+#ifndef Q_WS_MAC
+ int totalFeatures = pendingFeatureCount();
+ int featureCount = 0;
+#endif //Q_WS_MAC
+
QgsFeature fet;
while ( nextFeature( fet ) )
{
try
{
+ if ( rendererContext.renderingStopped() )
+ {
+ break;
+ }
+
+#ifndef Q_WS_MAC //MH: disable this on Mac for now to avoid problems with resizing
+ if ( mUpdateThreshold > 0 && 0 == featureCount % mUpdateThreshold )
+ {
+ emit screenUpdateRequested();
+ emit drawingProgress( featureCount, totalFeatures );
+ qApp->processEvents();
+ }
+ else if ( featureCount % 1000 == 0 )
+ {
+ emit drawingProgress( featureCount, totalFeatures );
+ qApp->processEvents();
+ }
+#endif //Q_WS_MAC
+
bool sel = mSelectedFeatureIds.contains( fet.id() );
bool drawMarker = ( mEditable && ( !vertexMarkerOnlyForSelection || sel ) );
@@ -749,15 +773,12 @@
msg += cse.what();
QgsLogger::warning( msg );
}
+#ifndef Q_WS_MAC
+ ++featureCount;
+#endif //Q_WS_MAC
}
- mRendererV2->stopRender( rendererContext );
-
- if ( selRenderer )
- {
- selRenderer->stopRender( rendererContext );
- delete selRenderer;
- }
+ stopRendererV2( rendererContext, selRenderer );
}
void QgsVectorLayer::drawRendererV2Levels( QgsRenderContext& rendererContext, bool labeling )
@@ -781,8 +802,22 @@
// 1. fetch features
QgsFeature fet;
+#ifndef Q_WS_MAC
+ int featureCount = 0;
+#endif //Q_WS_MAC
while ( nextFeature( fet ) )
{
+ if ( rendererContext.renderingStopped() )
+ {
+ stopRendererV2( rendererContext, selRenderer );
+ return;
+ }
+#ifndef Q_WS_MAC
+ if ( featureCount % 1000 == 0 )
+ {
+ qApp->processEvents();
+ }
+#endif //Q_WS_MAC
QgsSymbolV2* sym = mRendererV2->symbolForFeature( fet );
if ( !features.contains( sym ) )
{
@@ -798,6 +833,9 @@
// Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
mCachedGeometries[fet.id()] = *fet.geometry();
}
+#ifndef Q_WS_MAC
+ ++featureCount;
+#endif //Q_WS_MAC
}
// find out the order
@@ -831,8 +869,22 @@
int layer = item.layer();
QList<QgsFeature>& lst = features[item.symbol()];
QList<QgsFeature>::iterator fit;
+#ifndef Q_WS_MAC
+ featureCount = 0;
+#endif //Q_WS_MAC
for ( fit = lst.begin(); fit != lst.end(); ++fit )
{
+ if ( rendererContext.renderingStopped() )
+ {
+ stopRendererV2( rendererContext, selRenderer );
+ return;
+ }
+#ifndef Q_WS_MAC
+ if ( featureCount % 1000 == 0 )
+ {
+ qApp->processEvents();
+ }
+#endif //Q_WS_MAC
bool sel = mSelectedFeatureIds.contains( fit->id() );
// maybe vertex markers should be drawn only during the last pass...
bool drawMarker = ( mEditable && ( !vertexMarkerOnlyForSelection || sel ) );
@@ -851,21 +903,22 @@
msg += cse.what();
QgsLogger::warning( msg );
}
+#ifndef Q_WS_MAC
+ ++featureCount;
+#endif //Q_WS_MAC
}
}
}
- mRendererV2->stopRender( rendererContext );
-
- if ( selRenderer )
- {
- selRenderer->stopRender( rendererContext );
- delete selRenderer;
- }
+ stopRendererV2( rendererContext, selRenderer );
}
bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
{
+ //set update threshold before each draw to make sure the current setting is picked up
+ QSettings settings;
+ mUpdateThreshold = settings.value( "Map/updateThreshold", 0 ).toInt();
+
if ( mUsingRendererV2 )
{
if ( mRendererV2 == NULL )
@@ -916,9 +969,6 @@
return TRUE;
}
- //set update threshold before each draw to make sure the current setting is picked up
- QSettings settings;
- mUpdateThreshold = settings.value( "Map/updateThreshold", 0 ).toInt();
//draw ( p, viewExtent, theMapToPixelTransform, ct, drawingToEditingCanvas, 1., 1.);
if ( mRenderer )
@@ -4540,3 +4590,13 @@
}
return -1;
}
+
+void QgsVectorLayer::stopRendererV2( QgsRenderContext& rendererContext, QgsSingleSymbolRendererV2* selRenderer )
+{
+ mRendererV2->stopRender( rendererContext );
+ if ( selRenderer )
+ {
+ selRenderer->stopRender( rendererContext );
+ delete selRenderer;
+ }
+}
Modified: trunk/qgis/src/core/qgsvectorlayer.h
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.h 2010-02-21 19:23:01 UTC (rev 12960)
+++ trunk/qgis/src/core/qgsvectorlayer.h 2010-02-22 09:55:08 UTC (rev 12961)
@@ -44,6 +44,7 @@
class QgsUndoCommand;
class QgsVectorDataProvider;
class QgsVectorOverlay;
+class QgsSingleSymbolRendererV2;
class QgsRectangle;
@@ -660,6 +661,8 @@
/** Record changed attribute, store in active command (if any) */
void editAttributeChange( int featureId, int field, QVariant value );
+ /** Stop version 2 renderer and selected renderer (if required) */
+ void stopRendererV2( QgsRenderContext& rendererContext, QgsSingleSymbolRendererV2* selRenderer );
private: // Private attributes
More information about the QGIS-commit
mailing list