Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Feature #8725: Fast rendering of geom (v-OGR)
Implements fast rendering of LineStrings and Polygons pre-applying a
view threshold filter to the geometries to render in qgis. Also disable
'Antialiasing' when it is possible.

View Table of test results in 'http://hub.qgis.org/issues/8725'

(This version of branch implements the improvement in vector-providers)
  • Loading branch information
ahuarte47 committed Dec 17, 2013
1 parent b192f64 commit 440ede9
Show file tree
Hide file tree
Showing 23 changed files with 746 additions and 44 deletions.
2 changes: 1 addition & 1 deletion python/core/symbology-ng/qgssymbollayerv2.sip
Expand Up @@ -202,5 +202,5 @@ class QgsFillSymbolLayerV2 : QgsSymbolLayerV2
protected:
QgsFillSymbolLayerV2( bool locked = false );
/**Default method to render polygon*/
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings );
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
};
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -81,6 +81,7 @@ SET(QGIS_CORE_SRCS
qgslabelattributes.cpp
qgslabelsearchtree.cpp
qgslogger.cpp
qgsmaprequest.cpp
qgsmaplayer.cpp
qgsmaplayerregistry.cpp
qgsmaprenderer.cpp
Expand Down
24 changes: 8 additions & 16 deletions src/core/qgsclipper.cpp
Expand Up @@ -45,6 +45,9 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const

bool hasZValue = ( wkbType == QGis::WKBLineString25D );

int sizeOfDoubleX = sizeof(double);
int sizeOfDoubleY = hasZValue ? 2*sizeof(double) : sizeof(double);

double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
double p1x_c, p1y_c; //clipped end coordinates
double lastClipX = 0.0, lastClipY = 0.0; //last successfully clipped coords
Expand All @@ -56,29 +59,18 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const
{
if ( i == 0 )
{
memcpy( &p1x, wkb, sizeof( double ) );
wkb += sizeof( double );
memcpy( &p1y, wkb, sizeof( double ) );
wkb += sizeof( double );
if ( hasZValue ) // ignore Z value
{
wkb += sizeof( double );
}
memcpy( &p1x, wkb, sizeof( double ) ); wkb += sizeOfDoubleX;
memcpy( &p1y, wkb, sizeof( double ) ); wkb += sizeOfDoubleY;

continue;
}
else
{
p0x = p1x;
p0y = p1y;

memcpy( &p1x, wkb, sizeof( double ) );
wkb += sizeof( double );
memcpy( &p1y, wkb, sizeof( double ) );
wkb += sizeof( double );
if ( hasZValue ) // ignore Z value
{
wkb += sizeof( double );
}
memcpy( &p1x, wkb, sizeof( double ) ); wkb += sizeOfDoubleX;
memcpy( &p1y, wkb, sizeof( double ) ); wkb += sizeOfDoubleY;

p1x_c = p1x; p1y_c = p1y;
if ( clipLineSegment( clipExtent.xMinimum(), clipExtent.xMaximum(), clipExtent.yMinimum(), clipExtent.yMaximum(),
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsfeaturerequest.cpp
Expand Up @@ -56,6 +56,8 @@ QgsFeatureRequest::QgsFeatureRequest( const QgsFeatureRequest &rh )

QgsFeatureRequest& QgsFeatureRequest::operator=( const QgsFeatureRequest & rh )
{
QgsMapRequest::operator=( rh );

mFlags = rh.mFlags;
mFilter = rh.mFilter;
mFilterRect = rh.mFilterRect;
Expand Down
6 changes: 4 additions & 2 deletions src/core/qgsfeaturerequest.h
Expand Up @@ -17,6 +17,7 @@

#include <QFlags>

#include "qgsmaprequest.h"
#include "qgsfeature.h"
#include "qgsrectangle.h"
#include "qgsexpression.h"
Expand Down Expand Up @@ -53,15 +54,16 @@ typedef QList<int> QgsAttributeList;
* QgsFeatureRequest().setFilterFid(45)
*
*/
class CORE_EXPORT QgsFeatureRequest
class CORE_EXPORT QgsFeatureRequest : public QgsMapRequest
{
public:
enum Flag
{
NoFlags = 0,
NoGeometry = 1, //!< Geometry is not required. It may still be returned if e.g. required for a filter condition.
SubsetOfAttributes = 2, //!< Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
ExactIntersect = 4 //!< Use exact geometry intersection (slower) instead of bounding boxes
ExactIntersect = 4, //!< Use exact geometry intersection (slower) instead of bounding boxes
SimplifyGeometries = 8 //!< Simplify the geometry using the current map2pixel context
};
Q_DECLARE_FLAGS( Flags, Flag )

Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsmaprenderer.cpp
Expand Up @@ -278,6 +278,10 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
//so must be false at every new render operation
mRenderContext.setRenderingStopped( false );

// Gets the configured Tolerance for simplify transformations between map coordinates and device coordinates
QSettings mySettings2;
mRenderContext.setMapToPixelTol( mySettings2.value( "Map/map2pixelTol", 1.0f ).toFloat() );

// set selection color
QgsProject* prj = QgsProject::instance();
int myRed = prj->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
Expand Down

0 comments on commit 440ede9

Please sign in to comment.