Showing with 24 additions and 11 deletions.
  1. +9 −0 src/core/qgsfeature.cpp
  2. +1 −1 src/core/qgsfeature.h
  3. +14 −10 src/core/symbology-ng/qgsrendererv2.cpp
9 changes: 9 additions & 0 deletions src/core/qgsfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ void QgsFeature::setValid( bool validity )
mValid = validity;
}

void QgsFeature::initAttributes( int fieldCount )
{
mAttributes.resize( fieldCount );
QVariant* ptr = mAttributes.data();
for ( int i = 0; i < fieldCount; ++i, ++ptr )
ptr->clear();
}


bool QgsFeature::setAttribute( const QString& name, QVariant value )
{
int fieldIdx = fieldNameIndex( name );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class CORE_EXPORT QgsFeature
QgsAttributes& attributes() { return mAttributes; }
void setAttributes( const QgsAttributes& attrs ) { mAttributes = attrs; }
void setAttribute( int field, const QVariant& attr ) { mAttributes[field] = attr; }
void initAttributes( int fieldCount ) { mAttributes.resize( fieldCount ); for ( int i = 0;i < fieldCount;++i ) mAttributes[i].clear(); }
void initAttributes( int fieldCount );

/**Deletes an attribute and its value*/
void deleteAttribute( int field );
Expand Down
24 changes: 14 additions & 10 deletions src/core/symbology-ng/qgsrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderCo
{
pts.resize( nPoints );

for ( unsigned int i = 0; i < nPoints; ++i )
QPointF* ptr = pts.data();
for ( unsigned int i = 0; i < nPoints; ++i, ++ptr )
{
x = *(( double * ) wkb );
wkb += sizeof( double );
Expand All @@ -98,19 +99,20 @@ unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderCo
if ( hasZValue ) // ignore Z value
wkb += sizeof( double );

pts[i] = QPointF( x, y );
*ptr = QPointF( x, y );
}
}

//transform the QPolygonF to screen coordinates
for ( int i = 0; i < pts.size(); ++i )
QPointF* ptr = pts.data();
for ( int i = 0; i < pts.size(); ++i, ++ptr )
{
if ( ct )
{
z = 0;
ct->transformInPlace( pts[i].rx(), pts[i].ry(), z );
ct->transformInPlace( ptr->rx(), ptr->ry(), z );
}
mtp.transformInPlace( pts[i].rx(), pts[i].ry() );
mtp.transformInPlace( ptr->rx(), ptr->ry() );
}


Expand Down Expand Up @@ -151,12 +153,13 @@ unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygon
QPolygonF poly( nPoints );

// Extract the points from the WKB and store in a pair of vectors.
for ( unsigned int jdx = 0; jdx < nPoints; jdx++ )
QPointF* ptr = poly.data();
for ( unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
{
x = *(( double * ) wkb ); wkb += sizeof( double );
y = *(( double * ) wkb ); wkb += sizeof( double );

poly[jdx] = QPointF( x, y );
*ptr = QPointF( x, y );

if ( hasZValue )
wkb += sizeof( double );
Expand All @@ -169,14 +172,15 @@ unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygon
QgsClipper::trimPolygon( poly, clipRect );

//transform the QPolygonF to screen coordinates
for ( int i = 0; i < poly.size(); ++i )
ptr = poly.data();
for ( int i = 0; i < poly.size(); ++i, ++ptr )
{
if ( ct )
{
z = 0;
ct->transformInPlace( poly[i].rx(), poly[i].ry(), z );
ct->transformInPlace( ptr->rx(), ptr->ry(), z );
}
mtp.transformInPlace( poly[i].rx(), poly[i].ry() );
mtp.transformInPlace( ptr->rx(), ptr->ry() );
}

if ( idx == 0 )
Expand Down