Skip to content
Permalink
Browse files

[FEATURE] Add support for gradient fills for polygons

  • Loading branch information
nyalldawson committed Sep 8, 2013
1 parent 3d2814f commit 864df0fe376beef51e0f1a0a76eaccd5495179ed
Showing with 2,006 additions and 4 deletions.
  1. +96 −0 python/core/symbology-ng/qgsfillsymbollayerv2.sip
  2. +403 −0 src/core/symbology-ng/qgsfillsymbollayerv2.cpp
  3. +135 −0 src/core/symbology-ng/qgsfillsymbollayerv2.h
  4. +2 −0 src/core/symbology-ng/qgssymbollayerv2registry.cpp
  5. +14 −0 src/core/symbology-ng/qgsvectorcolorrampv2.cpp
  6. +5 −0 src/core/symbology-ng/qgsvectorcolorrampv2.h
  7. +15 −4 src/gui/symbology-ng/qgscolorrampcombobox.cpp
  8. +6 −0 src/gui/symbology-ng/qgscolorrampcombobox.h
  9. +17 −0 src/gui/symbology-ng/qgsdatadefinedsymboldialog.cpp
  10. +3 −0 src/gui/symbology-ng/qgsdatadefinedsymboldialog.h
  11. +1 −0 src/gui/symbology-ng/qgslayerpropertieswidget.cpp
  12. +295 −0 src/gui/symbology-ng/qgssymbollayerv2widget.cpp
  13. +38 −0 src/gui/symbology-ng/qgssymbollayerv2widget.h
  14. +437 −0 src/ui/symbollayer/widget_gradientfill.ui
  15. +2 −0 tests/src/core/CMakeLists.txt
  16. +273 −0 tests/src/core/testqgsgradients.cpp
  17. +82 −0 tests/src/python/test_qgssymbollayerv2.py
  18. BIN tests/testdata/control_images/expected_gradient/expected_gradient.png
  19. BIN tests/testdata/control_images/expected_gradient_colors/expected_gradient_colors.png
  20. BIN tests/testdata/control_images/expected_gradient_conical/expected_gradient_conical.png
  21. BIN tests/testdata/control_images/expected_gradient_from_qml/expected_gradient_from_qml.png
  22. BIN tests/testdata/control_images/expected_gradient_radial/expected_gradient_radial.png
  23. BIN tests/testdata/control_images/expected_gradient_ramp/expected_gradient_ramp.png
  24. BIN tests/testdata/control_images/expected_gradient_reflect/expected_gradient_reflect.png
  25. BIN tests/testdata/control_images/expected_gradient_refpoints/expected_gradient_refpoints.png
  26. BIN tests/testdata/control_images/expected_gradient_repeat/expected_gradient_repeat.png
  27. BIN tests/testdata/control_images/expected_gradient_rotate/expected_gradient_rotate.png
  28. BIN tests/testdata/control_images/expected_gradient_viewport/expected_gradient_viewport.png
  29. +182 −0 tests/testdata/polys_gradient_symbol.qml
@@ -59,6 +59,102 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2
QgsSymbolV2::OutputUnit outputUnit() const;
};

class QgsGradientFillSymbolLayerV2 : QgsFillSymbolLayerV2
{
%TypeHeaderCode
#include <qgsfillsymbollayerv2.h>
%End

public:

enum GradientColorType
{
SimpleTwoColor,
ColorRamp
};

enum GradientType
{
Linear,
Radial,
Conical
};

enum GradientCoordinateMode
{
Feature,
Viewport
};

enum GradientSpread
{
Pad,
Reflect,
Repeat
};

QgsGradientFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR,
QColor color2 = Qt::white,
GradientColorType gradientColorType = SimpleTwoColor,
GradientType gradientType = Linear,
GradientCoordinateMode coordinateMode = Feature,
GradientSpread gradientSpread = Pad );

// static stuff

static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;

// implemented from base classes

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );

QgsStringMap properties() const;

QgsSymbolLayerV2* clone() const /Factory/;

//up to here

GradientType gradientType() const;
void setGradientType( GradientType gradientType );

GradientColorType gradientColorType() const;
void setGradientColorType( GradientColorType gradientColorType );

QgsVectorColorRampV2* colorRamp();
void setColorRamp( QgsVectorColorRampV2* ramp );

QColor color2() const;
void setColor2( QColor color2 );

GradientCoordinateMode coordinateMode() const;
void setCoordinateMode( GradientCoordinateMode coordinateMode );

GradientSpread gradientSpread() const;
void setGradientSpread( GradientSpread gradientSpread );

void setReferencePoint1( QPointF referencePoint );
QPointF referencePoint1() const;

void setReferencePoint2( QPointF referencePoint );
QPointF referencePoint2() const;

void setAngle( double angle );
double angle() const;

void setOffset( QPointF offset );
QPointF offset() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

};

/**Base class for polygon renderers generating texture images*/
class QgsImageFillSymbolLayer: QgsFillSymbolLayerV2
{

0 comments on commit 864df0f

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