Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a bunch of core symbology classes.
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10770 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
May 12, 2009
1 parent
2413981
commit 8a12078
Showing
23 changed files
with
3,613 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
#include "qgsfillsymbollayerv2.h" | ||
#include "qgssymbollayerv2utils.h" | ||
|
||
#include "qgsrendercontext.h" | ||
|
||
#include <QPainter> | ||
|
||
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, QColor borderColor, Qt::BrushStyle style) | ||
: mBrushStyle(style), mBorderColor(borderColor) | ||
{ | ||
mColor = color; | ||
} | ||
|
||
|
||
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create(const QgsStringMap& props) | ||
{ | ||
QColor color = DEFAULT_SIMPLEFILL_COLOR; | ||
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR; | ||
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE; | ||
|
||
if (props.contains("color")) | ||
color = QgsSymbolLayerV2Utils::decodeColor(props["color"]); | ||
if (props.contains("color_border")) | ||
borderColor = QgsSymbolLayerV2Utils::decodeColor(props["color_border"]); | ||
if (props.contains("style")) | ||
style = QgsSymbolLayerV2Utils::decodeBrushStyle(props["style"]); | ||
|
||
return new QgsSimpleFillSymbolLayerV2(color, borderColor, style); | ||
} | ||
|
||
|
||
QString QgsSimpleFillSymbolLayerV2::layerType() const | ||
{ | ||
return "SimpleFill"; | ||
} | ||
|
||
void QgsSimpleFillSymbolLayerV2::startRender(QgsRenderContext& context) | ||
{ | ||
mBrush = QBrush(mColor, mBrushStyle); | ||
mPen = QPen(mBorderColor); | ||
} | ||
|
||
void QgsSimpleFillSymbolLayerV2::stopRender(QgsRenderContext& context) | ||
{ | ||
} | ||
|
||
void QgsSimpleFillSymbolLayerV2::renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context) | ||
{ | ||
QPainter* p = context.painter(); | ||
p->setBrush(mBrush); | ||
p->setPen(mPen); | ||
|
||
if (rings == NULL) | ||
{ | ||
// simple polygon without holes | ||
p->drawPolygon(points); | ||
} | ||
else | ||
{ | ||
// polygon with holes must be drawn using painter path | ||
QPainterPath path; | ||
path.addPolygon(points); | ||
QList<QPolygonF>::iterator it; | ||
for (it = rings->begin(); it != rings->end(); ++it) | ||
path.addPolygon(*it); | ||
|
||
p->drawPath(path); | ||
} | ||
} | ||
|
||
QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const | ||
{ | ||
QgsStringMap map; | ||
map["color"] = QgsSymbolLayerV2Utils::encodeColor(mColor); | ||
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor(mBorderColor); | ||
map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle(mBrushStyle); | ||
return map; | ||
} | ||
|
||
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const | ||
{ | ||
return new QgsSimpleFillSymbolLayerV2(mColor, mBorderColor, mBrushStyle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
#ifndef QGSFILLSYMBOLLAYERV2_H | ||
#define QGSFILLSYMBOLLAYERV2_H | ||
|
||
#include "qgssymbollayerv2.h" | ||
|
||
#define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255) | ||
#define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern | ||
#define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor(0,0,0) | ||
|
||
#include <QPen> | ||
#include <QBrush> | ||
|
||
class QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2 | ||
{ | ||
public: | ||
QgsSimpleFillSymbolLayerV2(QColor color = DEFAULT_SIMPLEFILL_COLOR, | ||
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR, | ||
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE); | ||
|
||
// static stuff | ||
|
||
static QgsSymbolLayerV2* create(const QgsStringMap& properties = QgsStringMap()); | ||
|
||
// implemented from base classes | ||
|
||
QString layerType() const; | ||
|
||
void startRender(QgsRenderContext& context); | ||
|
||
void stopRender(QgsRenderContext& context); | ||
|
||
void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context); | ||
|
||
QgsStringMap properties() const; | ||
|
||
QgsSymbolLayerV2* clone() const; | ||
|
||
Qt::BrushStyle brushStyle() const { return mBrushStyle; } | ||
void setBrushStyle(Qt::BrushStyle style) { mBrushStyle = style; } | ||
|
||
QColor borderColor() const { return mBorderColor; } | ||
void setBorderColor(QColor borderColor) { mBorderColor = borderColor; } | ||
|
||
protected: | ||
QBrush mBrush; | ||
Qt::BrushStyle mBrushStyle; | ||
QColor mBorderColor; | ||
QPen mPen; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.