@@ -86,11 +86,68 @@ void QgsGraduatedSymbolRenderer::removeSymbols()
86
86
mSymbols .clear ();
87
87
}
88
88
89
+ bool QgsGraduatedSymbolRenderer::willRenderFeature (QgsFeature *f)
90
+ {
91
+ return (symbolForFeature (f) != 0 );
92
+ }
93
+
89
94
void QgsGraduatedSymbolRenderer::renderFeature (QPainter * p, QgsFeature & f, QImage* img,
90
95
double * scalefactor, bool selected, double widthScale)
96
+ {
97
+ QgsSymbol* theSymbol = symbolForFeature (&f);
98
+ if (!theSymbol)
99
+ {
100
+ if ( img && mVectorType == QGis::Point )
101
+ {
102
+ img->fill (0 );
103
+ }
104
+ else if ( mVectorType != QGis::Point )
105
+ {
106
+ p->setPen (Qt::NoPen);
107
+ p->setBrush (Qt::NoBrush);
108
+ }
109
+ return ;
110
+ }
111
+
112
+ // set the qpen and qpainter to the right values
113
+ // Point
114
+ if ( img && mVectorType == QGis::Point )
115
+ {
116
+ *img = theSymbol->getPointSymbolAsImage ( widthScale, selected, mSelectionColor );
117
+ if ( scalefactor )
118
+ {
119
+ *scalefactor = 1 ;
120
+ }
121
+ }
122
+
123
+ // Line, polygon
124
+ if ( mVectorType != QGis::Point )
125
+ {
126
+ if ( !selected )
127
+ {
128
+ QPen pen=theSymbol->pen ();
129
+ pen.setWidthF ( widthScale * pen.width () );
130
+ p->setPen (pen);
131
+ p->setBrush (theSymbol->brush ());
132
+ }
133
+ else
134
+ {
135
+ QPen pen=theSymbol->pen ();
136
+ pen.setColor (mSelectionColor );
137
+ pen.setWidthF ( widthScale * pen.width () );
138
+ QBrush brush=theSymbol->brush ();
139
+ brush.setColor (mSelectionColor );
140
+ p->setPen (pen);
141
+ p->setBrush (brush);
142
+ }
143
+ }
144
+ }
145
+
146
+
147
+ QgsSymbol* QgsGraduatedSymbolRenderer::symbolForFeature (const QgsFeature* f)
91
148
{
92
149
// first find out the value for the classification attribute
93
- const QgsAttributeMap& attrs = f. attributeMap ();
150
+ const QgsAttributeMap& attrs = f-> attributeMap ();
94
151
double value = attrs[mClassificationField ].fieldValue ().toDouble ();
95
152
96
153
std::list < QgsSymbol* >::iterator it;
@@ -104,46 +161,10 @@ void QgsGraduatedSymbolRenderer::renderFeature(QPainter * p, QgsFeature & f, QIm
104
161
}
105
162
106
163
if (it == mSymbols .end ()) // only draw features which are covered by a render item
107
- {
108
- QgsDebugMsg (" Warning, value is contained in no class" );
109
- p->setPen (QPen (Qt::NoPen));
110
- p->setBrush (QBrush (Qt::NoBrush));
111
- return ;
112
- }
113
- else
114
- {
115
- // set the qpen and qpainter to the right values
116
- // Point
117
- if ( img && mVectorType == QGis::Point )
118
164
{
119
- *img = (*it)->getPointSymbolAsImage ( widthScale,
120
- selected, mSelectionColor );
121
-
122
- if ( scalefactor ) *scalefactor = 1 ;
123
- }
124
-
125
- // Line, polygon
126
- if ( mVectorType != QGis::Point )
127
- {
128
- if ( !selected )
129
- {
130
- QPen pen=(*it)->pen ();
131
- pen.setWidthF ( widthScale * pen.width () );
132
- p->setPen (pen);
133
- p->setBrush ((*it)->brush ());
134
- }
135
- else
136
- {
137
- QPen pen=(*it)->pen ();
138
- pen.setColor (mSelectionColor );
139
- pen.setWidthF ( widthScale * pen.width () );
140
- QBrush brush=(*it)->brush ();
141
- brush.setColor (mSelectionColor );
142
- p->setPen (pen);
143
- p->setBrush (brush);
144
- }
165
+ return 0 ;
145
166
}
146
- }
167
+ return (*it);
147
168
}
148
169
149
170
void QgsGraduatedSymbolRenderer::readXML (const QDomNode& rnode, QgsVectorLayer& vl)
0 commit comments