Skip to content

Commit

Permalink
Merge pull request #2955 from mhugo/arrows
Browse files Browse the repository at this point in the history
[Feature] Arrow symbol layer
  • Loading branch information
Hugo Mercier committed Apr 19, 2016
2 parents 831e7cd + 81a6ccf commit e849cad
Show file tree
Hide file tree
Showing 22 changed files with 1,566 additions and 1 deletion.
1 change: 1 addition & 0 deletions ci/travis/linux/qt5/blacklist.txt
@@ -1,6 +1,7 @@
ProcessingGdalAlgorithmsTest
ProcessingParametersTest
ProcessingQgisAlgorithmsTest
PyQgsArrowSymbolLayer
PyQgsBlendModes
PyQgsComposerEffects
PyQgsComposerHtml
Expand Down
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -305,6 +305,7 @@
%Include symbology-ng/qgssymbollayerv2registry.sip
%Include symbology-ng/qgssymbollayerv2utils.sip
%Include symbology-ng/qgsvectorfieldsymbollayer.sip
%Include symbology-ng/qgsarrowsymbollayer.sip

%Include symbology-ng/qgssymbologyv2conversion.sip

Expand Down
111 changes: 111 additions & 0 deletions python/core/symbology-ng/qgsarrowsymbollayer.sip
@@ -0,0 +1,111 @@
class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
{
%TypeHeaderCode
#include <qgsarrowsymbollayer.h>
%End
public:
/** Simple constructor */
QgsArrowSymbolLayer();

/**
* Create a new QgsArrowSymbolLayer
*
* @param properties A property map to deserialize saved information from properties()
*
* @return A new QgsArrowSymbolLayer
*/
static QgsSymbolLayerV2* create( const QgsStringMap& properties ) /Factory/;

/** Virtual constructor */
virtual QgsArrowSymbolLayer* clone() const /Factory/;

/** Get the sub symbol used for filling */
virtual QgsSymbolV2* subSymbol();

/** Set the sub symbol used for filling */
virtual bool setSubSymbol( QgsSymbolV2* symbol );

/** Return a list of attributes required to render this feature */
virtual QSet<QString> usedAttributes() const;

/** Get current arrow width */
double arrowWidth() const;
/** Set the arrow width */
void setArrowWidth( double w );
/** Get the unit for the arrow width */
QgsSymbolV2::OutputUnit arrowWidthUnit() const;
/** Set the unit for the arrow width */
void setArrowWidthUnit( QgsSymbolV2::OutputUnit u );
/** Get the scale for the arrow width */
QgsMapUnitScale arrowWidthUnitScale() const;
/** Set the scale for the arrow width */
void setArrowWidthUnitScale( const QgsMapUnitScale& s );

/** Get current arrow start width. Only meaningfull for single headed arrows */
double arrowStartWidth() const;
/** Set the arrow start width */
void setArrowStartWidth( double w );
/** Get the unit for the arrow start width */
QgsSymbolV2::OutputUnit arrowStartWidthUnit() const;
/** Set the unit for the arrow start width */
void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit u );
/** Get the scale for the arrow start width */
QgsMapUnitScale arrowStartWidthUnitScale() const;
/** Set the scale for the arrow start width */
void setArrowStartWidthUnitScale( const QgsMapUnitScale& s );

/** Get the current arrow head size */
double headSize() const;
/** Set the arrow head size */
void setHeadSize( double s );
/** Get the unit for the head size */
QgsSymbolV2::OutputUnit headSizeUnit() const;
/** Set the unit for the head size */
void setHeadSizeUnit( QgsSymbolV2::OutputUnit u );
/** Get the scale for the head size */
QgsMapUnitScale headSizeUnitScale() const;
/** Set the scale for the head size */
void setHeadSizeUnitScale( const QgsMapUnitScale& s );

/** Return whether it is a curved arrow or a straight one */
bool isCurved() const;
/** Set whether it is a curved arrow or a straight one */
void setIsCurved( bool isCurved );

/** Possible head types */
enum HeadType
{
HeadSingle, //< One single head at the end
HeadReversed, //< One single head at the beginning
HeadDouble //< Two heads
};

/** Get the current head type */
HeadType headType() const;
/** Set the head type */
void setHeadType( HeadType t );

/**
* Should be reimplemented by subclasses to return a string map that
* contains the configuration information for the symbol layer. This
* is used to serialize a symbol layer perstistently.
*/
QgsStringMap properties() const;

/**
* Returns a string that represents this layer type. Used for serialization.
* Should match with the string used to register this symbol layer in the registry.
*/
QString layerType() const;

/** Prepare the rendering */
void startRender( QgsSymbolV2RenderContext& context );

/** End of the rendering */
void stopRender( QgsSymbolV2RenderContext& context );

/** Main drawing method */
void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
private:
QgsArrowSymbolLayer( const QgsArrowSymbolLayer& );
};
1 change: 1 addition & 0 deletions python/gui/gui.sip
Expand Up @@ -198,6 +198,7 @@

%Include symbology-ng/characterwidget.sip
%Include symbology-ng/qgs25drendererwidget.sip
%Include symbology-ng/qgsarrowsymbollayerwidget.sip
%Include symbology-ng/qgsbrushstylecombobox.sip
%Include symbology-ng/qgscategorizedsymbolrendererv2widget.sip
%Include symbology-ng/qgscolorrampcombobox.sip
Expand Down
22 changes: 22 additions & 0 deletions python/gui/symbology-ng/qgsarrowsymbollayerwidget.sip
@@ -0,0 +1,22 @@
class QgsArrowSymbolLayerWidget: QgsSymbolLayerV2Widget
{
%TypeHeaderCode
#include <qgsarrowsymbollayerwidget.h>
%End
public:
/** Constructor
* @param layer the layer where this symbol layer is applied
* @param parent the parent widget
*/
QgsArrowSymbolLayerWidget( const QgsVectorLayer* layer, QWidget* parent /TransferThis/ = 0 );

/** Static creation method
* @param layer the layer where this symbol layer is applied
*/
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* layer ) /Factory/;

/** Set the symbol layer */
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
/** Get the current symbol layer */
virtual QgsSymbolLayerV2* symbolLayer();
};
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -16,6 +16,7 @@ SET(QGIS_CORE_SRCS
gps/tok.c

symbology-ng/qgs25drenderer.cpp
symbology-ng/qgsarrowsymbollayer.cpp
symbology-ng/qgscategorizedsymbolrendererv2.cpp
symbology-ng/qgscolorbrewerpalette.cpp
symbology-ng/qgscptcityarchive.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsexpression.cpp
Expand Up @@ -4601,6 +4601,8 @@ void QgsExpression::initVariableHelp()
//symbol variables
gVariableHelpTexts.insert( "geometry_part_count", QCoreApplication::translate( "variable_help", "Number of parts in rendered feature's geometry." ) );
gVariableHelpTexts.insert( "geometry_part_num", QCoreApplication::translate( "variable_help", "Current geometry part number for feature being rendered." ) );
gVariableHelpTexts.insert( "geometry_point_count", QCoreApplication::translate( "variable_help", "Number of points in the rendered geometry's part. It is only meaningful for line geometries and for symbol layers that set this variable." ) );
gVariableHelpTexts.insert( "geometry_point_num", QCoreApplication::translate( "variable_help", "Current point number in the rendered geometry's part. It is only meaningful for line geometries and for symbol layers that set this variable." ) );

gVariableHelpTexts.insert( "symbol_color", QCoreApplication::translate( "symbol_color", "Color of symbol used to render the feature." ) );
gVariableHelpTexts.insert( "symbol_angle", QCoreApplication::translate( "symbol_angle", "Angle of symbol used to render the feature (valid for marker symbols only)." ) );
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsexpressioncontext.cpp
Expand Up @@ -37,6 +37,8 @@ const QString QgsExpressionContext::EXPR_SYMBOL_COLOR( "symbol_color" );
const QString QgsExpressionContext::EXPR_SYMBOL_ANGLE( "symbol_angle" );
const QString QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT( "geometry_part_count" );
const QString QgsExpressionContext::EXPR_GEOMETRY_PART_NUM( "geometry_part_num" );
const QString QgsExpressionContext::EXPR_GEOMETRY_POINT_COUNT( "geometry_point_count" );
const QString QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM( "geometry_point_num" );

//
// QgsExpressionContextScope
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsexpressioncontext.h
Expand Up @@ -444,6 +444,10 @@ class CORE_EXPORT QgsExpressionContext
static const QString EXPR_GEOMETRY_PART_COUNT;
//! Inbuilt variable name for geometry part number variable
static const QString EXPR_GEOMETRY_PART_NUM;
//! Inbuilt variable name for point count variable
static const QString EXPR_GEOMETRY_POINT_COUNT;
//! Inbuilt variable name for point number variable
static const QString EXPR_GEOMETRY_POINT_NUM;

private:

Expand Down

0 comments on commit e849cad

Please sign in to comment.