ranged_gradient_render.diff
src/gui/qgsgraduatedsymbolrenderer.h (working copy) | ||
---|---|---|
33 | 33 |
/**This class contains the information for graduate symbol rendering*/ |
34 | 34 |
class QgsGraduatedSymbolRenderer: public QgsRenderer |
35 | 35 |
{ |
36 |
private: |
|
37 |
/**Helper function for finding symbol having feature value in range*/ |
|
38 |
std::list < QgsSymbol* >::iterator firstSymbolForFeature(QgsFeature *f); |
|
36 | 39 |
public: |
37 | 40 |
QgsGraduatedSymbolRenderer(QGis::VectorType type); |
38 | 41 |
QgsGraduatedSymbolRenderer(const QgsGraduatedSymbolRenderer& other); |
... | ... | |
45 | 48 |
int classificationField() const; |
46 | 49 |
/**Removes all symbols*/ |
47 | 50 |
void removeSymbols(); |
51 |
/**Determines if an OGRFeature is in range of any symbol's upper and lower bounds |
|
52 |
\param f a pointer to the feature to check*/ |
|
53 |
bool willRenderFeature(QgsFeature *f); |
|
48 | 54 |
/**Renders an OGRFeature |
49 | 55 |
\param p a painter (usually the one from the current map canvas) |
50 | 56 |
\param f a pointer to a feature to render |
src/gui/qgsvectorlayer.cpp (working copy) | ||
---|---|---|
360 | 360 |
if(mDeletedFeatureIds.find(fet->featureId())==mDeletedFeatureIds.end()) |
361 | 361 |
{ |
362 | 362 |
bool sel=mSelectedFeatureIds.find(fet->featureId()) != mSelectedFeatureIds.end(); |
363 |
mLabel->renderLabel ( p, viewExtent, *mCoordinateTransform, |
|
363 |
if (m_renderer && m_renderer->willRenderFeature(fet)) |
|
364 |
{ |
|
365 |
mLabel->renderLabel ( p, viewExtent, *mCoordinateTransform, |
|
364 | 366 |
projectionsEnabledFlag, |
365 | 367 |
theMapToPixelTransform, fet, sel, 0, scale); |
368 |
} |
|
366 | 369 |
} |
367 | 370 |
} |
368 | 371 |
delete fet; |
... | ... | |
374 | 377 |
for(std::vector<QgsFeature*>::iterator it=mAddedFeatures.begin();it!=mAddedFeatures.end();++it) |
375 | 378 |
{ |
376 | 379 |
bool sel=mSelectedFeatureIds.find((*it)->featureId()) != mSelectedFeatureIds.end(); |
377 |
mLabel->renderLabel ( p, viewExtent, *mCoordinateTransform, projectionsEnabledFlag, |
|
380 |
if (m_renderer && m_renderer->willRenderFeature(*it)) |
|
381 |
{ |
|
382 |
mLabel->renderLabel ( p, viewExtent, *mCoordinateTransform, projectionsEnabledFlag, |
|
378 | 383 |
theMapToPixelTransform, *it, sel, 0, scale); |
384 |
} |
|
379 | 385 |
} |
380 | 386 |
} |
381 | 387 |
catch (QgsCsException &e) |
... | ... | |
880 | 886 |
sel = FALSE; |
881 | 887 |
} |
882 | 888 | |
883 |
m_renderer->renderFeature(p, fet, &marker, &markerScaleFactor, sel, widthScale ); |
|
884 |
double scale = markerScaleFactor * symbolScale; |
|
885 |
drawFeature(p, |
|
889 |
if (m_renderer->willRenderFeature(fet)) |
|
890 |
{ |
|
891 |
m_renderer->renderFeature(p, fet, &marker, &markerScaleFactor, sel, widthScale ); |
|
892 |
double scale = markerScaleFactor * symbolScale; |
|
893 |
drawFeature(p, |
|
886 | 894 |
fet, |
887 | 895 |
theMapToPixelTransform, |
888 | 896 |
&marker, |
889 | 897 |
scale, |
890 | 898 |
projectionsEnabledFlag, |
891 | 899 |
drawingToEditingCanvas); |
892 |
++featureCount; |
|
893 |
delete fet; |
|
900 |
++featureCount; |
|
901 |
delete fet; |
|
902 |
} |
|
894 | 903 |
} |
895 | 904 | |
896 | 905 |
//also draw the not yet commited features |
... | ... | |
899 | 908 |
for(std::vector<QgsFeature*>::iterator it = mAddedFeatures.begin(); it != mAddedFeatures.end(); ++it) |
900 | 909 |
{ |
901 | 910 |
bool sel=mSelectedFeatureIds.find((*it)->featureId()) != mSelectedFeatureIds.end(); |
911 |
if (!m_renderer->willRenderFeature(*it)) |
|
912 |
{ |
|
913 |
continue; |
|
914 |
} |
|
902 | 915 |
m_renderer->renderFeature(p, *it, &marker, &markerScaleFactor, sel, widthScale); |
903 | 916 |
double scale = markerScaleFactor * symbolScale; |
904 | 917 |
if (mChangedGeometries.find((*it)->featureId()) != mChangedGeometries.end()) |
src/gui/qgsgraduatedsymbolrenderer.cpp (working copy) | ||
---|---|---|
83 | 83 |
mSymbols.clear(); |
84 | 84 |
} |
85 | 85 | |
86 |
void QgsGraduatedSymbolRenderer::renderFeature(QPainter * p, QgsFeature * f, QPixmap* pic, |
|
87 |
double* scalefactor, bool selected, double widthScale) |
|
86 |
std::list < QgsSymbol* >::iterator QgsGraduatedSymbolRenderer::firstSymbolForFeature(QgsFeature *f) |
|
88 | 87 |
{ |
88 |
|
|
89 | 89 |
//first find out the value for the classification attribute |
90 | 90 |
std::vector < QgsFeatureAttribute > vec = f->attributeMap(); |
91 | 91 |
double value = vec[0].fieldValue().toDouble(); |
... | ... | |
99 | 99 |
break; |
100 | 100 |
} |
101 | 101 |
} |
102 |
return it; |
|
103 |
} |
|
102 | 104 | |
105 |
bool QgsGraduatedSymbolRenderer::willRenderFeature(QgsFeature *f) |
|
106 |
{ |
|
107 |
std::list < QgsSymbol* >::iterator it = firstSymbolForFeature(f); |
|
108 | ||
103 | 109 |
if (it == mSymbols.end()) //only draw features which are covered by a render item |
104 | 110 |
{ |
111 |
return false; |
|
112 |
} |
|
113 |
return true; |
|
114 |
} |
|
115 | ||
116 |
void QgsGraduatedSymbolRenderer::renderFeature(QPainter * p, QgsFeature * f, QPixmap* pic, |
|
117 |
double* scalefactor, bool selected, double widthScale) |
|
118 |
{ |
|
119 |
std::list < QgsSymbol* >::iterator it = firstSymbolForFeature(f); |
|
120 | ||
121 |
if (it == mSymbols.end()) //only draw features which are covered by a render item |
|
122 |
{ |
|
105 | 123 |
p->setPen(QPen(Qt::NoPen)); |
106 | 124 |
p->setBrush(QBrush(Qt::NoBrush)); |
107 | 125 |
return; |
src/core/qgsrenderer.h (working copy) | ||
---|---|---|
48 | 48 |
QgsRenderer(); |
49 | 49 |
/** Virtual destructor because we have virtual methods... */ |
50 | 50 |
virtual ~QgsRenderer() {}; |
51 |
/** Determines if a feature will be rendered or not |
|
52 |
* @param f a pointer to the feature to determine if rendering will happen*/ |
|
53 |
virtual bool willRenderFeature(QgsFeature *f); |
|
51 | 54 |
/**A vector layer passes features to a renderer object to change the brush and pen of the qpainter |
52 | 55 |
@param p the painter storing brush and pen |
53 | 56 |
@param f a pointer to the feature to be rendered |
src/core/qgsrenderer.cpp (working copy) | ||
---|---|---|
13 | 13 | |
14 | 14 |
} |
15 | 15 | |
16 |
bool QgsRenderer::willRenderFeature(QgsFeature *f) |
|
17 |
{ |
|
18 |
// Normally render the feature, unless told otherwise |
|
19 |
return true; |
|
20 |
} |
|
21 | ||
16 | 22 |
void QgsRenderer::refreshLegend(std::list< std::pair<QString, QPixmap> >* symbologyList) const |
17 | 23 |
{ |
18 | 24 |
if(symbologyList) |