Skip to content

Commit

Permalink
Differentiate between field scale and raster scale factor such that f…
Browse files Browse the repository at this point in the history
…ield scaled point symbols all have the same outline width

git-svn-id: http://svn.osgeo.org/qgis/trunk@8449 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 17, 2008
1 parent d528050 commit 328469a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/core/renderer/qgscontinuouscolorrenderer.cpp
Expand Up @@ -140,8 +140,8 @@ void QgsContinuousColorRenderer::renderFeature(QPainter * p, QgsFeature & f, QIm
}
brush.setStyle ( Qt::SolidPattern );

*img = QgsMarkerCatalogue::instance()->imageMarker ( mMinimumSymbol->pointSymbolName(), mMinimumSymbol->pointSize() *widthScale * rasterScaleFactor,
pen, brush);
*img = QgsMarkerCatalogue::instance()->imageMarker ( mMinimumSymbol->pointSymbolName(), \
mMinimumSymbol->pointSize() * widthScale * rasterScaleFactor, pen, brush);
}
else if ( mVectorType == QGis::Line )
{
Expand Down
3 changes: 1 addition & 2 deletions src/core/renderer/qgsgraduatedsymbolrenderer.cpp
Expand Up @@ -130,8 +130,7 @@ void QgsGraduatedSymbolRenderer::renderFeature(QPainter * p, QgsFeature & f, QIm
rotation = attrs[theSymbol->rotationClassificationField()].toDouble();
QgsDebugMsg(QString("Feature has rotation factor %1").arg(rotation));
}
*img = theSymbol->getPointSymbolAsImage( widthScale, selected, mSelectionColor,
rasterScaleFactor * fieldScale, rotation);
*img = theSymbol->getPointSymbolAsImage( widthScale, selected, mSelectionColor, fieldScale, rotation, rasterScaleFactor);
}

// Line, polygon
Expand Down
3 changes: 1 addition & 2 deletions src/core/renderer/qgssinglesymbolrenderer.cpp
Expand Up @@ -112,8 +112,7 @@ void QgsSingleSymbolRenderer::renderFeature(QPainter * p, QgsFeature & f, QImage
QgsDebugMsg(QString("Feature has rotation factor %1").arg(rotation));
}

*img = mSymbol->getPointSymbolAsImage( widthScale, selected, mSelectionColor,
rasterScaleFactor * fieldScale, rotation);
*img = mSymbol->getPointSymbolAsImage( widthScale, selected, mSelectionColor, fieldScale, rotation, rasterScaleFactor);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer/qgsuniquevaluerenderer.cpp
Expand Up @@ -140,7 +140,7 @@ void QgsUniqueValueRenderer::renderFeature(QPainter* p, QgsFeature& f,QImage* im
QgsDebugMsg(QString("Feature has rotation factor %1").arg(rotation));
}
*img = symbol->getPointSymbolAsImage( widthScale, selected, mSelectionColor,
rasterScaleFactor * fieldScale, rotation);
fieldScale, rotation, rasterScaleFactor);
}
// Line, polygon
else if ( mVectorType != QGis::Point )
Expand Down
12 changes: 6 additions & 6 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -324,31 +324,31 @@ QImage QgsSymbol::getCachedPointSymbolAsImage( double widthScale,
}
}

QImage QgsSymbol::getPointSymbolAsImage( double widthScale,
bool selected, QColor selectionColor, double scale, double rotation )
QImage QgsSymbol::getPointSymbolAsImage( double widthScale, bool selected, QColor selectionColor, double scale, \
double rotation, double rasterScaleFactor)
{
//QgsDebugMsg(QString("Symbol scale = %1, and rotation = %2").arg(scale).arg(rotation));
if ( 1.0 == scale && 0 == rotation )
if ( 1.0 == (scale * rasterScaleFactor) && 0 == rotation )
{
// If scale is 1.0 and rotation 0.0, use cached image.
return getCachedPointSymbolAsImage( widthScale, selected, selectionColor );
}

QImage preRotateImage;
QPen pen = mPen;
double newWidth = mPen.widthF() * widthScale * scale;
double newWidth = mPen.widthF() * widthScale * rasterScaleFactor;
pen.setWidth(newWidth);

if ( selected )
{
pen.setColor ( selectionColor );
QBrush brush = mBrush;
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale),
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale * rasterScaleFactor),
pen, mBrush );
}
else
{
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale),
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale * rasterScaleFactor),
pen, mBrush );
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/symbology/qgssymbol.h
Expand Up @@ -105,9 +105,10 @@ class CORE_EXPORT QgsSymbol{
*/
virtual QImage getPointSymbolAsImage( double widthScale = 1.,
bool selected = false,
QColor selectionColor = Qt::yellow,
QColor selectionColor = Qt::yellow,
double scale = 1.0,
double rotation = 0.0);
double rotation = 0.0,
double rasterScaleFactor = 1.0);

/**Writes the contents of the symbol to a configuration file
@ return true in case of success*/
Expand Down

0 comments on commit 328469a

Please sign in to comment.