Skip to content

Commit 52c37ff

Browse files
author
mhugent
committed
Added the possibility for renderers to have different transparency levels for different classes
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6967 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9e763f2 commit 52c37ff

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

python/core/qgsrenderer.sip

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class QgsRenderer /Abstract/
3838
static void setSelectionColor(QColor color);
3939
/**Returns true if this renderer returns a pixmap in the render method (e.g. for point data or diagrams)*/
4040
virtual bool containsPixmap() const;
41+
/**Returns true if this renderer uses its own transparency settings, e.g. differentiated by classification.
42+
This is a hint for QgsVectorLayer to not use the transparency setting on layer level in this cases*/
43+
virtual bool usesTransparency() const;
4144

4245
};
4346

src/core/qgsvectorlayer.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,12 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
407407
//
408408
QPen myTransparentPen = p->pen(); // store current pen
409409
QColor myColor = myTransparentPen.color();
410-
myColor.setAlpha(mTransparencyLevel);
410+
//only set transparency from layer level if renderer does not provide
411+
//transparency on class level
412+
if(!mRenderer->usesTransparency())
413+
{
414+
myColor.setAlpha(mTransparencyLevel);
415+
}
411416
myTransparentPen.setColor(myColor);
412417
p->setPen(myTransparentPen);
413418
p->drawPolyline(pa);
@@ -631,11 +636,23 @@ std::cerr << i << ": " << ring->first[i]
631636
//
632637
QBrush myTransparentBrush = p->brush();
633638
QColor myColor = brush.color();
634-
myColor.setAlpha(mTransparencyLevel);
639+
640+
//only set transparency from layer level if renderer does not provide
641+
//transparency on class level
642+
if(!mRenderer->usesTransparency())
643+
{
644+
myColor.setAlpha(mTransparencyLevel);
645+
}
635646
myTransparentBrush.setColor(myColor);
636647
QPen myTransparentPen = p->pen(); // store current pen
637648
myColor = myTransparentPen.color();
638-
myColor.setAlpha(mTransparencyLevel);
649+
650+
//only set transparency from layer level if renderer does not provide
651+
//transparency on class level
652+
if(!mRenderer->usesTransparency())
653+
{
654+
myColor.setAlpha(mTransparencyLevel);
655+
}
639656
myTransparentPen.setColor(myColor);
640657

641658
p->setBrush(myTransparentBrush);

src/core/renderer/qgsrenderer.h

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class CORE_EXPORT QgsRenderer
7373
static void setSelectionColor(QColor color);
7474
/**Returns true if this renderer returns a pixmap in the render method (e.g. for point data or diagrams)*/
7575
virtual bool containsPixmap() const;
76+
/**Returns true if this renderer uses its own transparency settings, e.g. differentiated by classification.
77+
This is a hint for QgsVectorLayer to not use the transparency setting on layer level in this cases*/
78+
virtual bool usesTransparency() const {return false;}
7679

7780
protected:
7881
/**Color to draw selected features - static so we can change it in proj props and automatically

0 commit comments

Comments
 (0)