Skip to content
Permalink
Browse files

[FEATURE] Merge branch 'rules' - new rule-based rendering

Conflicts:
	src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  • Loading branch information
wonder-sk committed Jan 24, 2012
2 parents 0b1fd34 + 1c3c02f commit a7cf5e4b83dc0a1c60487ce2ecbbebcf45226e50
Showing with 2,849 additions and 969 deletions.
  1. +10 −18 python/core/symbology-ng-core.sip
  2. +0 −2 python/gui/symbology-ng-gui.sip
  3. +4 −1 src/core/qgsvectorlayer.cpp
  4. +4 −0 src/core/symbology-ng/qgscategorizedsymbolrendererv2.h
  5. +4 −0 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.h
  6. +5 −1 src/core/symbology-ng/qgsrendererv2.cpp
  7. +15 −5 src/core/symbology-ng/qgsrendererv2.h
  8. +358 −216 src/core/symbology-ng/qgsrulebasedrendererv2.cpp
  9. +90 −31 src/core/symbology-ng/qgsrulebasedrendererv2.h
  10. +4 −0 src/core/symbology-ng/qgssinglesymbolrendererv2.h
  11. +18 −1 src/gui/CMakeLists.txt
  12. +8 −0 src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
  13. +2 −0 src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.h
  14. +8 −0 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  15. +2 −0 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.h
  16. +0 −40 src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
  17. +0 −4 src/gui/symbology-ng/qgsrendererv2propertiesdialog.h
  18. +13 −0 src/gui/symbology-ng/qgsrendererv2widget.cpp
  19. +3 −0 src/gui/symbology-ng/qgsrendererv2widget.h
  20. +404 −396 src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
  21. +54 −38 src/gui/symbology-ng/qgsrulebasedrendererv2widget.h
  22. +7 −0 src/gui/symbology-ng/qgssinglesymbolrendererv2widget.cpp
  23. +2 −0 src/gui/symbology-ng/qgssinglesymbolrendererv2widget.h
  24. +24 −9 src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp
  25. +7 −0 src/gui/symbology-ng/qgssymbollevelsv2dialog.h
  26. +4 −34 src/ui/qgsrendererrulepropsdialogbase.ui
  27. +0 −8 src/ui/qgsrendererv2propsdialogbase.ui
  28. +29 −165 src/ui/qgsrulebasedrendererv2widget.ui
  29. +336 −0 tests/qt_modeltest/dynamictreemodel.cpp
  30. +197 −0 tests/qt_modeltest/dynamictreemodel.h
  31. +566 −0 tests/qt_modeltest/modeltest.cpp
  32. +94 −0 tests/qt_modeltest/modeltest.h
  33. +7 −0 tests/qt_modeltest/readme.txt
  34. +309 −0 tests/qt_modeltest/tst_modeltest.cpp
  35. +1 −0 tests/src/core/CMakeLists.txt
  36. +96 −0 tests/src/core/testqgsrulebasedrenderer.cpp
  37. +22 −0 tests/src/gui/CMakeLists.txt
  38. +84 −0 tests/src/gui/testrendererv2gui.cpp
  39. +24 −0 tests/src/gui/testrendererv2gui.h
  40. +2 −0 tests/testdata/rulebasedrenderer_invalid.xml
  41. +32 −0 tests/testdata/rulebasedrenderer_simple.xml
@@ -390,6 +390,8 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2

public:

//typedef QList<QgsRuleBasedRendererV2::Rule*> RuleList;

/**
This class keeps data about a rules for rule-based renderer.
A rule consists of a symbol, filter expression and range of scales.
@@ -403,10 +405,10 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
public:
//! Constructor takes ownership of the symbol
Rule( QgsSymbolV2* symbol /Transfer/, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString() );
Rule( const QgsRuleBasedRendererV2::Rule& other );
//Rule( const QgsRuleBasedRendererV2::Rule& other );
~Rule();
QString dump() const;
QStringList needsFields() const;
//QStringList needsFields() const;
bool isFilterOK( QgsFeature& f ) const;
bool isScaleOK( double scale ) const;

@@ -428,7 +430,9 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2

static QgsFeatureRendererV2* create( QDomElement& element ) /Factory/;

//! Constructor. Takes ownership of the defult symbol.
//! Constructs the renderer from given tree of rules
QgsRuleBasedRendererV2( QgsRuleBasedRendererV2::Rule* root /Transfer/ );
//! Constructor for convenience. Creates a root rule and adds a default rule with symbol
QgsRuleBasedRendererV2( QgsSymbolV2* defaultSymbol /Transfer/ );

//! return symbol for current feature. Should not be used individually: there could be more symbols for a feature
@@ -454,27 +458,15 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2

/////

//! return the total number of rules
int ruleCount();
//! get reference to rule at index (valid indexes: 0...count-1)
QgsRuleBasedRendererV2::Rule& ruleAt( int index );
//! add rule to the end of the list of rules
void addRule( const QgsRuleBasedRendererV2::Rule& rule );
//! insert rule to a specific position of the list of rules
void insertRule( int index, const QgsRuleBasedRendererV2::Rule& rule );
//! modify the rule at a specific position of the list of rules
void updateRuleAt( int index, const QgsRuleBasedRendererV2::Rule& rule );
//! remove the rule at the specified index
void removeRuleAt( int index );

//////

//! take a rule and create a list of new rules based on the categories from categorized symbol renderer
static QList<QgsRuleBasedRendererV2::Rule> refineRuleCategories( QgsRuleBasedRendererV2::Rule& initialRule, QgsCategorizedSymbolRendererV2* r );
//static QgsRuleBasedRendererV2::RuleList refineRuleCategories( QgsRuleBasedRendererV2::Rule* initialRule, QgsCategorizedSymbolRendererV2* r );
//! take a rule and create a list of new rules based on the ranges from graduated symbol renderer
static QList<QgsRuleBasedRendererV2::Rule> refineRuleRanges( QgsRuleBasedRendererV2::Rule& initialRule, QgsGraduatedSymbolRendererV2* r );
//static QgsRuleBasedRendererV2::RuleList refineRuleRanges( QgsRuleBasedRendererV2::Rule* initialRule, QgsGraduatedSymbolRendererV2* r );
//! take a rule and create a list of new rules with intervals of scales given by the passed scale denominators
static QList<QgsRuleBasedRendererV2::Rule> refineRuleScales( QgsRuleBasedRendererV2::Rule& initialRule, QList<int> scales );
//static QgsRuleBasedRendererV2::RuleList refineRuleScales( QgsRuleBasedRendererV2::Rule* initialRule, QList<int> scales );

};

@@ -42,8 +42,6 @@ public slots:
void apply();
void onOK();

void showSymbolLevels();

protected:

//! Reimplements dialog keyPress event so we can ignore it
@@ -776,6 +776,8 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
#endif //Q_WS_MAC
}

stopRendererV2( rendererContext, NULL );

#ifndef Q_WS_MAC
QgsDebugMsg( QString( "Total features processed %1" ).arg( featureCount ) );
#endif
@@ -977,7 +979,8 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )

select( attributes, rendererContext.extent() );

if ( mRendererV2->usingSymbolLevels() )
if ( ( mRendererV2->capabilities() & QgsFeatureRendererV2::SymbolLevels )
&& mRendererV2->usingSymbolLevels() )
drawRendererV2Levels( rendererContext, labeling );
else
drawRendererV2( rendererContext, labeling );
@@ -60,6 +60,10 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone();

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities() { return SymbolLevels; }

virtual QgsSymbolV2List symbols();

const QgsCategoryList& categories() { return mCategories; }
@@ -55,6 +55,10 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone();

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities() { return SymbolLevels; }

virtual QgsSymbolV2List symbols();

QString classAttribute() const { return mAttrName; }
@@ -194,6 +194,11 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
if ( symbol == NULL )
return;

renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
}

void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymbolV2* symbol, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
{
QgsSymbolV2::SymbolType symbolType = symbol->type();

QgsGeometry* geom = feature.geometry();
@@ -356,7 +361,6 @@ QgsFeatureRendererV2* QgsFeatureRendererV2::load( QDomElement& element )
if ( r )
{
r->setUsingSymbolLevels( element.attribute( "symbollevels", "0" ).toInt() );
r->setUsingFirstRule( element.attribute( "firstrule", "0" ).toInt() );
}
return r;
}
@@ -78,16 +78,20 @@ class CORE_EXPORT QgsFeatureRendererV2
//! for debugging
virtual QString dump();

enum Capabilities {
SymbolLevels = 1 // rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
};

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities() { return 0; }

//! for symbol levels
virtual QgsSymbolV2List symbols() = 0;

bool usingSymbolLevels() const { return mUsingSymbolLevels; }
void setUsingSymbolLevels( bool usingSymbolLevels ) { mUsingSymbolLevels = usingSymbolLevels; }

bool usingFirstRule() const { return mUsingFirstRule; }
void setUsingFirstRule( bool usingFirstRule ) { mUsingFirstRule = usingFirstRule; }


//! create a renderer from XML element
static QgsFeatureRendererV2* load( QDomElement& symbologyElem );

@@ -107,6 +111,13 @@ class CORE_EXPORT QgsFeatureRendererV2
protected:
QgsFeatureRendererV2( QString type );

void renderFeatureWithSymbol( QgsFeature& feature,
QgsSymbolV2* symbol,
QgsRenderContext& context,
int layer,
bool selected,
bool drawVertexMarker );

//! render editing vertex marker at specified point
void renderVertexMarker( QPointF& pt, QgsRenderContext& context );
//! render editing vertex marker for a polyline
@@ -121,7 +132,6 @@ class CORE_EXPORT QgsFeatureRendererV2
QString mType;

bool mUsingSymbolLevels;
bool mUsingFirstRule;

/** The current type of editing marker */
int mCurrentVertexMarkerType;

0 comments on commit a7cf5e4

Please sign in to comment.
You can’t perform that action at this time.