Skip to content
Permalink
Browse files
Fix for ticket #86.
Resolved the point symbol colour issue and the misplacement of the
point symbols in the print composer. The actual changes to fix the
problem don't even hint at the amount of time it to track the
problem down!

Also added an explicit copy constructor for QgsSymbol.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5448 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed May 13, 2006
1 parent 185c96f commit 8487326787a0dae9bc9fc11511abc35c982c0213
Showing with 35 additions and 8 deletions.
  1. +6 −7 src/composer/qgscomposervectorlegend.cpp
  2. +28 −1 src/core/qgssymbol.cpp
  3. +1 −0 src/core/qgssymbol.h
@@ -303,8 +303,8 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
if ( itemHeights[icnt] < mSymbolHeight ) { // init first
itemHeights[icnt] = mSymbolHeight;
}
QPixmap pic = sym->getPointSymbolAsPixmap(0,widthScale);

QPixmap pic = sym->getPointSymbolAsPixmap(widthScale, false);

int h = (int) ( scale * pic.height() );
if ( h > itemHeights[icnt] ) {
@@ -361,7 +361,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
layer = mMapCanvas->getZpos(groupLayers[j]);
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
const QgsRenderer *renderer = vector->renderer();

// Symbol
std::list<QgsSymbol*> symbols = renderer->symbols();

@@ -385,13 +385,12 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
double scale = map->symbolScale() * mComposition->scale();

// Get the picture of appropriate size directly from catalogue
QPixmap pic = sym->getPointSymbolAsPixmap(0,widthScale);


QPixmap pic = sym->getPointSymbolAsPixmap(widthScale,false,sym->color());

painter->save();
painter->scale(scale,scale);
painter->drawPixmap ( static_cast<int>( (1.*mMargin+mSymbolWidth/2)/scale-pic.width()-1.*pic.width()/2),
static_cast<int>( (1.*localHeight+symbolHeight/2)/scale-pic.height()-1.*pic.height()/2),
painter->drawPixmap ( static_cast<int>( (1.*mMargin+mSymbolWidth/2)/scale-pic.width()/2),
static_cast<int>( (1.*localHeight+symbolHeight/2)/scale-1.*pic.height()/2),
pic );
painter->restore();

@@ -76,6 +76,30 @@ QgsSymbol::QgsSymbol(QColor c)
mCacheUpToDate2( false )
{}

QgsSymbol::QgsSymbol(const QgsSymbol& s)
{
if (this != &s)
{
mLowerValue = s.mLowerValue;
mUpperValue = s.mUpperValue;
mLabel = s.mLabel;
mType = s.mType;
mPen = s.mPen;
mBrush = s.mBrush;
mPointSymbolName = s.mPointSymbolName;
mPointSize = s.mPointSize;
mPointSymbolPixmap = s.mPointSymbolPixmap;
mPointSymbolPixmapSelected = s.mPointSymbolPixmapSelected;
mWidthScale = s.mWidthScale;
mPointSymbolPixmap2 = s.mPointSymbolPixmap2;
mPointSymbolPixmapSelected2 = s.mPointSymbolPixmapSelected2;
mCacheUpToDate = s.mCacheUpToDate;
mCacheUpToDate2 = s.mCacheUpToDate2;
mSelectionColor = s.mSelectionColor;
mSelectionColor2 = s.mSelectionColor2;
}
}

QgsSymbol::~QgsSymbol()
{

@@ -200,7 +224,10 @@ void QgsSymbol::cache( QColor selectionColor )
QPen pen = mPen;
pen.setColor ( selectionColor );
QBrush brush = mBrush;
brush.setColor ( selectionColor );
// For symbols that have a different coloured border, the line
// below causes the fill colour to be wrong for the print
// composer. Not sure why...
// brush.setColor ( selectionColor );

mPointSymbolPixmap = QgsMarkerCatalogue::instance()->marker ( mPointSymbolName, mPointSize,
mPen, mBrush );
@@ -38,6 +38,7 @@ class QgsSymbol{
QgsSymbol(QGis::VectorType t, QString lvalue="", QString uvalue="", QString label="");
/**Constructor*/
QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString label, QColor c);
QgsSymbol(const QgsSymbol&);
/**old constructors*/
QgsSymbol();
QgsSymbol(QColor c);

0 comments on commit 8487326

Please sign in to comment.