Skip to content
Permalink
Browse files

symbology-ng: small refactoring - every renderer can now returns its …

…list of symbols

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11114 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 20, 2009
1 parent 3a37031 commit 2b082edf0b579abc762f177f41db2fe8f8005164
@@ -1,4 +1,6 @@

typedef QList<QgsSymbolV2*> QgsSymbolV2List;

///////////////


@@ -55,6 +57,8 @@ public:

virtual QgsFeatureRendererV2* clone()=0 /Factory/;

virtual QgsSymbolV2List symbols()=0;

void renderFeature(QgsFeature& feature, QgsRenderContext& context, int layer = -1);

QgsSymbolV2LevelOrder& symbolLevels();
@@ -241,6 +241,7 @@ QString QgsFeatureRendererV2::dump()
return "UNKNOWN RENDERER\n";
}


///////////////////

QgsSingleSymbolRendererV2::QgsSingleSymbolRendererV2(QgsSymbolV2* symbol)
@@ -297,6 +298,13 @@ QgsFeatureRendererV2* QgsSingleSymbolRendererV2::clone()
return r;
}

QgsSymbolV2List QgsSingleSymbolRendererV2::symbols()
{
QgsSymbolV2List lst;
lst.append(mSymbol);
return lst;
}

///////////////////

QgsRendererCategoryV2::QgsRendererCategoryV2(QVariant value, QgsSymbolV2* symbol, QString label)
@@ -492,6 +500,13 @@ QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2::clone()
return r;
}

QgsSymbolV2List QgsCategorizedSymbolRendererV2::symbols()
{
QgsSymbolV2List lst;
for (int i = 0; i < mCategories.count(); i++)
lst.append(mCategories[i].symbol());
return lst;
}

/////////////////////////
// graduated
@@ -643,6 +658,13 @@ QgsFeatureRendererV2* QgsGraduatedSymbolRendererV2::clone()
return r;
}

QgsSymbolV2List QgsGraduatedSymbolRendererV2::symbols()
{
QgsSymbolV2List lst;
for (int i = 0; i < mRanges.count(); i++)
lst.append(mRanges[i].symbol());
return lst;
}

static QList<double> _calcEqualIntervalBreaks(double minimum, double maximum, int classes)
{
@@ -11,6 +11,7 @@ class QgsSymbolV2;
class QgsRenderContext;
class QgsFeature;

typedef QList<QgsSymbolV2*> QgsSymbolV2List;

////////
// symbol levels
@@ -69,7 +70,8 @@ class QgsFeatureRendererV2
//! for debugging
virtual QString dump();

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

QgsSymbolV2LevelOrder& symbolLevels() { return mLevelOrder; }
void setSymbolLevels(const QgsSymbolV2LevelOrder& levelOrder) { mLevelOrder = levelOrder; }
@@ -105,6 +107,8 @@ class QgsSingleSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone();

virtual QgsSymbolV2List symbols();

protected:
QgsSymbolV2* mSymbol;
};
@@ -160,6 +164,8 @@ class QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone();

virtual QgsSymbolV2List symbols();

const QgsCategoryList& categories() { return mCategories; }

//! return index of category with specified value (-1 if not found)
@@ -239,6 +245,8 @@ class QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone();

virtual QgsSymbolV2List symbols();

int attributeIndex() const { return mAttrNum; }
void setAttributeIndex(int attr) { mAttrNum = attr; }

@@ -548,46 +548,7 @@ void QgsRendererV2PropertiesDialog::changeRangeSymbol(int rangeIdx)

void QgsRendererV2PropertiesDialog::symbolLevels()
{
QgsSymbolV2List symbols;

switch (mRenderer->type())
{
case QgsFeatureRendererV2::RendererSingleSymbol:
{
QgsSingleSymbolRendererV2* r = rendererSingle();
symbols.append(r->symbol());
}
break;

case QgsFeatureRendererV2::RendererCategorizedSymbol:
{
QgsCategorizedSymbolRendererV2* r = rendererCategorized();
int i, count = r->categories().count();

for (i = 0; i < count; i++)
{
const QgsRendererCategoryV2& cat = r->categories()[i];
symbols.append(cat.symbol());
}
}
break;

case QgsFeatureRendererV2::RendererGraduatedSymbol:
{
QgsGraduatedSymbolRendererV2* r = rendererGraduated();
int i, count = r->ranges().count();

for (i = 0; i < count; i++)
{
const QgsRendererRangeV2& range = r->ranges()[i];
symbols.append(range.symbol());
}
}
break;

default:
break;
}
QgsSymbolV2List symbols = mRenderer->symbols();

QgsSymbolLevelsV2Dialog dlg(symbols, mRenderer->symbolLevels(), this);
if (dlg.exec())
@@ -8,8 +8,6 @@

#include "ui_qgssymbollevelsv2dialogbase.h"

typedef QList<QgsSymbolV2*> QgsSymbolV2List;


class QgsSymbolLevelsV2Dialog : public QDialog, private Ui::QgsSymbolLevelsV2DialogBase
{

0 comments on commit 2b082ed

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