Skip to content

Commit

Permalink
[FEATURE] Raster image marker
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Dec 5, 2018
1 parent a8be1ff commit c642533
Show file tree
Hide file tree
Showing 20 changed files with 1,818 additions and 0 deletions.
160 changes: 160 additions & 0 deletions python/core/auto_generated/symbology/qgsmarkersymbollayer.sip.in
Expand Up @@ -697,6 +697,166 @@ Calculates the marker aspect ratio between width and height.



class QgsRasterMarkerSymbolLayer : QgsMarkerSymbolLayer
{
%Docstring
Raster marker symbol layer class.

.. versionadded:: 3.6
%End

%TypeHeaderCode
#include "qgsmarkersymbollayer.h"
%End
public:
QgsRasterMarkerSymbolLayer( const QString &path = QString(),
double size = DEFAULT_SVGMARKER_SIZE,
double angle = DEFAULT_SVGMARKER_ANGLE,
QgsSymbol::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
%Docstring
Constructs raster marker symbol layer with picture from given absolute path to a raster image file
%End


static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
%Docstring
Creates a raster marker symbol layer from a string map of properties.

:param properties: QgsStringMap properties object
%End

static void resolvePaths( QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving );
%Docstring
Turns relative paths in properties map to absolute when reading and vice versa when writing.
Used internally when reading/writing symbols.

.. versionadded:: 3.0
%End


virtual QString layerType() const;


virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context );


virtual QgsStringMap properties() const;


virtual QgsRasterMarkerSymbolLayer *clone() const /Factory/;


double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
%Docstring
Calculates the marker aspect ratio between width and height.

:param context: symbol render context
:param scaledSize: size of symbol to render
:param hasDataDefinedAspectRatio: will be set to true if marker has data defined aspectRatio
%End

QString path() const;
%Docstring
Returns the marker raster image path.

.. seealso:: :py:func:`setPath`
%End

void setPath( const QString &path );
%Docstring
Set the marker raster image path.

:param path: raster image path

.. seealso:: :py:func:`path`
%End

double opacity() const;
%Docstring
Returns the marker opacity.

:return: opacity value between 0 (fully transparent) and 1 (fully opaque)

.. seealso:: :py:func:`setOpacity`
%End

void setOpacity( double opacity );
%Docstring
Set the marker opacity.

:param opacity: opacity value between 0 (fully transparent) and 1 (fully opaque)

.. seealso:: :py:func:`opacity`
%End

double defaultAspectRatio() const;
%Docstring
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.

.. seealso:: :py:func:`updateDefaultAspectRatio`
%End

double updateDefaultAspectRatio();
%Docstring
Calculates the default marker aspect ratio between width and height.

:return: the default aspect ratio value

.. seealso:: :py:func:`defaultAspectRatio`
%End

bool preservedAspectRatio() const;
%Docstring
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.

.. seealso:: :py:func:`setPreservedAspectRatio`
%End

bool setPreservedAspectRatio( bool par );
%Docstring
Set preserved the marker aspect ratio between width and height.

:param par: Preserved Aspect Ratio

:return: the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0

.. seealso:: :py:func:`preservedAspectRatio`
%End

double fixedAspectRatio() const;
%Docstring
Returns the marker aspect ratio between width and height to be used in rendering,
if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

.. seealso:: :py:func:`setFixedAspectRatio`
%End

void setFixedAspectRatio( double ratio );
%Docstring
Set the marker aspect ratio between width and height to be used in rendering,
if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

:param ratio: Fixed Aspect Ratio

.. seealso:: :py:func:`fixedAspectRatio`
%End

virtual void setMapUnitScale( const QgsMapUnitScale &scale );

virtual QgsMapUnitScale mapUnitScale() const;


virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context );


protected:


};





class QgsFontMarkerSymbolLayer : QgsMarkerSymbolLayer
{
Expand Down
5 changes: 5 additions & 0 deletions python/core/auto_generated/symbology/qgssymbollayer.sip.in
Expand Up @@ -33,6 +33,8 @@ class QgsSymbolLayer
sipType = sipType_QgsFilledMarkerSymbolLayer;
else if ( sipCpp->layerType() == "SvgMarker" )
sipType = sipType_QgsSvgMarkerSymbolLayer;
else if ( sipCpp->layerType() == "RasterMarker" )
sipType = sipType_QgsRasterMarkerSymbolLayer;
else if ( sipCpp->layerType() == "VectorField" )
sipType = sipType_QgsVectorFieldSymbolLayer;
else
Expand Down Expand Up @@ -463,6 +465,9 @@ Abstract base class for marker symbol layers.
virtual void startRender( QgsSymbolRenderContext &context );


virtual void stopRender( QgsSymbolRenderContext &context );


virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
%Docstring
Renders a marker at the specified point. Derived classes must implement this to
Expand Down
41 changes: 41 additions & 0 deletions python/gui/auto_generated/symbology/qgssymbollayerwidget.sip.in
Expand Up @@ -417,6 +417,47 @@ Creates a new QgsSvgMarkerSymbolLayerWidget.



class QgsRasterMarkerSymbolLayerWidget : QgsSymbolLayerWidget
{
%Docstring
Widget for configuring QgsRasterMarkerSymbolLayer symbol layers.

.. versionadded:: 3.6
%End

%TypeHeaderCode
#include "qgssymbollayerwidget.h"
%End
public:

QgsRasterMarkerSymbolLayerWidget( QgsVectorLayer *vl, QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsRasterMarkerSymbolLayerWidget.

:param vl: associated vector layer
:param parent: parent widget
%End

static QgsSymbolLayerWidget *create( QgsVectorLayer *vl ) /Factory/;
%Docstring
Creates a new QgsRasterMarkerSymbolLayerWidget.

:param vl: associated vector layer
%End

virtual void setSymbolLayer( QgsSymbolLayer *layer );

virtual QgsSymbolLayer *symbolLayer();


protected:


};




class QgsRasterFillSymbolLayerWidget : QgsSymbolLayerWidget
{

Expand Down
1 change: 1 addition & 0 deletions src/core/qgsimagecache.cpp
Expand Up @@ -132,6 +132,7 @@ QImage QgsImageCache::pathAsImage( const QString &file, const QSize size, const
}
else
{
QgsDebugMsg( "HITTTTTTTTTTTTTTTTTTTTTTTTT!!!!!!!!!!!!!!" );

This comment has been minimized.

Copy link
@havatv

havatv Dec 5, 2018

Contributor

?

result = currentEntry->image;
}

Expand Down

0 comments on commit c642533

Please sign in to comment.