Skip to content

Commit

Permalink
Fix for ticket #86.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
g_j_m committed May 13, 2006
1 parent bb8ca55 commit a477f66
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/composer/qgscomposervectorlegend.cpp
Expand Up @@ -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] ) {
Expand Down Expand Up @@ -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();

Expand All @@ -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();

Expand Down
29 changes: 28 additions & 1 deletion src/core/qgssymbol.cpp
Expand Up @@ -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()
{

Expand Down Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/core/qgssymbol.h
Expand Up @@ -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);
Expand Down

0 comments on commit a477f66

Please sign in to comment.