Skip to content

Commit a477f66

Browse files
author
g_j_m
committedMay 13, 2006
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/qgis@5448 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed
 

‎src/composer/qgscomposervectorlegend.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
303303
if ( itemHeights[icnt] < mSymbolHeight ) { // init first
304304
itemHeights[icnt] = mSymbolHeight;
305305
}
306-
QPixmap pic = sym->getPointSymbolAsPixmap(0,widthScale);
307306

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

309309
int h = (int) ( scale * pic.height() );
310310
if ( h > itemHeights[icnt] ) {
@@ -361,7 +361,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
361361
layer = mMapCanvas->getZpos(groupLayers[j]);
362362
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
363363
const QgsRenderer *renderer = vector->renderer();
364-
364+
365365
// Symbol
366366
std::list<QgsSymbol*> symbols = renderer->symbols();
367367

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

387387
// Get the picture of appropriate size directly from catalogue
388-
QPixmap pic = sym->getPointSymbolAsPixmap(0,widthScale);
389-
390-
388+
QPixmap pic = sym->getPointSymbolAsPixmap(widthScale,false,sym->color());
389+
391390
painter->save();
392391
painter->scale(scale,scale);
393-
painter->drawPixmap ( static_cast<int>( (1.*mMargin+mSymbolWidth/2)/scale-pic.width()-1.*pic.width()/2),
394-
static_cast<int>( (1.*localHeight+symbolHeight/2)/scale-pic.height()-1.*pic.height()/2),
392+
painter->drawPixmap ( static_cast<int>( (1.*mMargin+mSymbolWidth/2)/scale-pic.width()/2),
393+
static_cast<int>( (1.*localHeight+symbolHeight/2)/scale-1.*pic.height()/2),
395394
pic );
396395
painter->restore();
397396

‎src/core/qgssymbol.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ QgsSymbol::QgsSymbol(QColor c)
7676
mCacheUpToDate2( false )
7777
{}
7878

79+
QgsSymbol::QgsSymbol(const QgsSymbol& s)
80+
{
81+
if (this != &s)
82+
{
83+
mLowerValue = s.mLowerValue;
84+
mUpperValue = s.mUpperValue;
85+
mLabel = s.mLabel;
86+
mType = s.mType;
87+
mPen = s.mPen;
88+
mBrush = s.mBrush;
89+
mPointSymbolName = s.mPointSymbolName;
90+
mPointSize = s.mPointSize;
91+
mPointSymbolPixmap = s.mPointSymbolPixmap;
92+
mPointSymbolPixmapSelected = s.mPointSymbolPixmapSelected;
93+
mWidthScale = s.mWidthScale;
94+
mPointSymbolPixmap2 = s.mPointSymbolPixmap2;
95+
mPointSymbolPixmapSelected2 = s.mPointSymbolPixmapSelected2;
96+
mCacheUpToDate = s.mCacheUpToDate;
97+
mCacheUpToDate2 = s.mCacheUpToDate2;
98+
mSelectionColor = s.mSelectionColor;
99+
mSelectionColor2 = s.mSelectionColor2;
100+
}
101+
}
102+
79103
QgsSymbol::~QgsSymbol()
80104
{
81105

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

205232
mPointSymbolPixmap = QgsMarkerCatalogue::instance()->marker ( mPointSymbolName, mPointSize,
206233
mPen, mBrush );

‎src/core/qgssymbol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class QgsSymbol{
3838
QgsSymbol(QGis::VectorType t, QString lvalue="", QString uvalue="", QString label="");
3939
/**Constructor*/
4040
QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString label, QColor c);
41+
QgsSymbol(const QgsSymbol&);
4142
/**old constructors*/
4243
QgsSymbol();
4344
QgsSymbol(QColor c);

0 commit comments

Comments
 (0)
Please sign in to comment.