31
31
QgsUniqueValueRenderer::QgsUniqueValueRenderer (QGis::VectorType type): mClassificationField(0 )
32
32
{
33
33
mVectorType = type;
34
+ mSymbolAttributesDirty = false ;
34
35
}
35
36
36
37
QgsUniqueValueRenderer::QgsUniqueValueRenderer (const QgsUniqueValueRenderer& other)
@@ -84,7 +85,7 @@ const QList<QgsSymbol*> QgsUniqueValueRenderer::symbols() const
84
85
void QgsUniqueValueRenderer::insertValue (QString name, QgsSymbol* symbol)
85
86
{
86
87
mSymbols .insert (name, symbol);
87
- updateSymbolAttributes () ;
88
+ mSymbolAttributesDirty = true ;
88
89
}
89
90
90
91
void QgsUniqueValueRenderer::setClassificationField (int field)
@@ -105,6 +106,11 @@ bool QgsUniqueValueRenderer::willRenderFeature(QgsFeature *f)
105
106
void QgsUniqueValueRenderer::renderFeature (QPainter* p, QgsFeature& f,QImage* img,
106
107
double * scalefactor, bool selected, double widthScale)
107
108
{
109
+ if (mSymbolAttributesDirty ) {
110
+ QgsDebugMsg (" Missed updateSymbolAttributes() call - doing it now" );
111
+ updateSymbolAttributes ();
112
+ }
113
+
108
114
QgsSymbol* symbol = symbolForFeature (&f);
109
115
if (!symbol) // no matching symbol
110
116
{
@@ -131,13 +137,13 @@ void QgsUniqueValueRenderer::renderFeature(QPainter* p, QgsFeature& f,QImage* im
131
137
// first find out the value for the scale classification attribute
132
138
const QgsAttributeMap& attrs = f.attributeMap ();
133
139
fieldScale = sqrt (fabs (attrs[symbol->scaleClassificationField ()].toDouble ()));
134
- QgsDebugMsg (QString (" Feature has field scale factor %1" ).arg (fieldScale));
140
+ QgsDebugMsgLevel (QString (" Feature has field scale factor %1" ).arg (fieldScale), 3 );
135
141
}
136
142
if ( symbol->rotationClassificationField () >= 0 )
137
143
{
138
144
const QgsAttributeMap& attrs = f.attributeMap ();
139
145
rotation = attrs[symbol->rotationClassificationField ()].toDouble ();
140
- QgsDebugMsg (QString (" Feature has rotation factor %1" ).arg (rotation));
146
+ QgsDebugMsgLevel (QString (" Feature has rotation factor %1" ).arg (rotation), 3 );
141
147
}
142
148
*img = symbol->getPointSymbolAsImage ( widthScale, selected, mSelectionColor ,
143
149
*scalefactor * fieldScale, rotation);
@@ -194,10 +200,11 @@ void QgsUniqueValueRenderer::readXML(const QDomNode& rnode, QgsVectorLayer& vl)
194
200
{
195
201
QgsSymbol* msy = new QgsSymbol (mVectorType );
196
202
msy->readXML ( symbolnode );
197
- this -> insertValue (msy->lowerValue (),msy);
203
+ insertValue (msy->lowerValue (),msy);
198
204
symbolnode = symbolnode.nextSibling ();
199
- vl.setRenderer (this );
200
205
}
206
+ updateSymbolAttributes ();
207
+ vl.setRenderer (this );
201
208
}
202
209
203
210
void QgsUniqueValueRenderer::clearValues ()
@@ -212,8 +219,7 @@ void QgsUniqueValueRenderer::clearValues()
212
219
213
220
void QgsUniqueValueRenderer::updateSymbolAttributes ()
214
221
{
215
- // This function is only called after changing field specifier in the GUI.
216
- // Timing is not so important.
222
+ mSymbolAttributesDirty = false ;
217
223
218
224
mSymbolAttributes .clear ();
219
225
0 commit comments