Skip to content

Commit

Permalink
add sip bindings for QgsPalLabeling, QgsSimpleMarkerSymbolLayerV2,
Browse files Browse the repository at this point in the history
QgsSvgMarkerSymbolLayerV2, QgsFontMarkerSymbolLayerV2
  • Loading branch information
jef-n committed Sep 16, 2012
1 parent 21c5988 commit d8675ba
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 64 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -102,6 +102,7 @@
%Include qgsnetworkaccessmanager.sip

%Include symbology-ng-core.sip
%Include qgspallabeling.sip

%Include qgsgpsconnection.sip
%Include qgsgpsconnectionregistry.sip
Expand Down
259 changes: 222 additions & 37 deletions python/core/symbology-ng-core.sip
Expand Up @@ -609,6 +609,7 @@ class QgsSymbolLayerV2

public:

// not necessarily supported by all symbol layers...
virtual void setColor(const QColor& color);
virtual QColor color() const;

Expand All @@ -621,6 +622,8 @@ public:

virtual QgsSymbolLayerV2* clone() const = 0 /Factory/;

virtual void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

virtual QgsStringMap properties() const = 0;

virtual void drawPreviewIcon(QgsSymbolV2RenderContext& context, QSize size) = 0;
Expand All @@ -637,6 +640,8 @@ public:
void setRenderingPass(int renderingPass);
int renderingPass() const;

virtual QSet<QString> usedAttributes() const;

protected:
QgsSymbolLayerV2(QgsSymbolV2::SymbolType type, bool locked = false);

Expand All @@ -661,6 +666,16 @@ public:
void setSize(double size);
double size() const;

void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
QgsSymbolV2::ScaleMethod scaleMethod() const;

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

void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

protected:
QgsMarkerSymbolLayerV2(bool locked = false);

Expand Down Expand Up @@ -780,12 +795,18 @@ public:
MapUnit
};

enum SymbolType
{
Marker,
Line,
Fill
};
enum SymbolType
{
Marker,
Line,
Fill
};

enum ScaleMethod
{
ScaleArea,
ScaleDiameter
};

//! @note added in 1.5
enum RenderHint
Expand All @@ -794,59 +815,65 @@ public:
DataDefinedRotation = 2
};

virtual ~QgsSymbolV2();
virtual ~QgsSymbolV2();

//! return new default symbol for specified geometry type
static QgsSymbolV2* defaultSymbol(QGis::GeometryType geomType) /Factory/;
//! return new default symbol for specified geometry type
static QgsSymbolV2* defaultSymbol(QGis::GeometryType geomType) /Factory/;

SymbolType type() const;
SymbolType type() const;

// symbol layers handling
// symbol layers handling

QgsSymbolLayerV2* symbolLayer(int layer);
QgsSymbolLayerV2* symbolLayer(int layer);

int symbolLayerCount();
int symbolLayerCount();

//! insert symbol layer to specified index
bool insertSymbolLayer(int index, QgsSymbolLayerV2* layer /Transfer/);
//! insert symbol layer to specified index
bool insertSymbolLayer(int index, QgsSymbolLayerV2* layer /Transfer/);

//! append symbol layer at the end of the list
bool appendSymbolLayer(QgsSymbolLayerV2* layer /Transfer/);
//! append symbol layer at the end of the list
bool appendSymbolLayer(QgsSymbolLayerV2* layer /Transfer/);

//! delete symbol layer at specified index
bool deleteSymbolLayer(int index);
//! delete symbol layer at specified index
bool deleteSymbolLayer(int index);

//! remove symbol layer from the list and return pointer to it
QgsSymbolLayerV2* takeSymbolLayer(int index) /TransferBack/;
//! remove symbol layer from the list and return pointer to it
QgsSymbolLayerV2* takeSymbolLayer(int index) /TransferBack/;

//! delete layer at specified index and set a new one
bool changeSymbolLayer(int index, QgsSymbolLayerV2* layer /Transfer/);
//! delete layer at specified index and set a new one
bool changeSymbolLayer(int index, QgsSymbolLayerV2* layer /Transfer/);

void startRender( QgsRenderContext& context, const QgsVectorLayer* layer = 0 );
void stopRender(QgsRenderContext& context);
void startRender( QgsRenderContext& context, const QgsVectorLayer* layer = 0 );
void stopRender(QgsRenderContext& context);

void setColor(const QColor& color);
QColor color();
void setColor(const QColor& color);
QColor color();

void drawPreviewIcon(QPainter* painter, QSize size);
void drawPreviewIcon(QPainter* painter, QSize size);

QImage bigSymbolPreviewImage();
QImage bigSymbolPreviewImage();

QString dump();
QString dump();

virtual QgsSymbolV2* clone() const = 0 /Factory/;

virtual QgsSymbolV2* clone() const = 0 /Factory/;
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

OutputUnit outputUnit() const;
void setOutputUnit( OutputUnit u );

//! Get alpha transparency 1 for opaque, 0 for invisible
qreal alpha() const;
//! Set alpha transparency 1 for opaque, 0 for invisible
void setAlpha( qreal alpha );

//! @note added in 1.5
int renderHints();
//! @note added in 1.5
void setRenderHints( int hints );

QSet<QString> usedAttributes() const;

protected:
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers /Transfer/); // can't be instantiated

Expand All @@ -861,12 +888,12 @@ class QgsMarkerSymbolV2 : QgsSymbolV2
#include <qgssymbolv2.h>
%End

public:
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
This is a convenience method for easier creation of marker symbols.
\note added in v1.7
*/
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
public:
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
This is a convenience method for easier creation of marker symbols.
\note added in v1.7
*/
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;

QgsMarkerSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());

Expand All @@ -876,6 +903,9 @@ public:
void setSize(double size);
double size();

void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
ScaleMethod scaleMethod();

void renderPoint(const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );

virtual QgsSymbolV2* clone() const /Factory/;
Expand Down Expand Up @@ -931,6 +961,161 @@ public:

//////////

class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
{
%TypeHeaderCode
#include <qgsmarkersymbollayerv2.h>
%End
public:
QgsSimpleMarkerSymbolLayerV2( QString name = DEFAULT_SIMPLEMARKER_NAME,
QColor color = DEFAULT_SIMPLEMARKER_COLOR,
QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
double size = DEFAULT_SIMPLEMARKER_SIZE,
double angle = DEFAULT_SIMPLEMARKER_ANGLE,
QgsSymbolV2::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );

// static stuff

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

// implemented from base classes

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );

QgsStringMap properties() const;

QgsSymbolLayerV2* clone() const /Factory/;

void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

QString name() const;
void setName( QString name );

QColor borderColor() const;
void setBorderColor( QColor color );

protected:

void drawMarker( QPainter* p, QgsSymbolV2RenderContext& context );

bool prepareShape();
bool preparePath();

void prepareCache( QgsSymbolV2RenderContext& context );
};

//////////

class QgsSvgMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
{
%TypeHeaderCode
#include <qgsmarkersymbollayerv2.h>
%End
public:
QgsSvgMarkerSymbolLayerV2( QString name = DEFAULT_SVGMARKER_NAME,
double size = DEFAULT_SVGMARKER_SIZE,
double angle = DEFAULT_SVGMARKER_ANGLE );

// static stuff

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

//! Return a list of all available svg files
static QStringList listSvgFiles();

//! Return a list of svg files at the specified directory
static QStringList listSvgFilesAt( QString directory );

//! Get symbol's path from its name
static QString symbolNameToPath( QString name );

//! Get symbols's name from its path
static QString symbolPathToName( QString path );

// implemented from base classes

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );

QgsStringMap properties() const;

QgsSymbolLayerV2* clone() const /Factory/;

void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

QString path() const;
void setPath( QString path );

QColor fillColor() const;
void setFillColor( const QColor& c );

QColor outlineColor() const;
void setOutlineColor( const QColor& c );

double outlineWidth() const;
void setOutlineWidth( double w );
};


//////////

class QgsFontMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
{
%TypeHeaderCode
#include <qgsmarkersymbollayerv2.h>
%End
public:
QgsFontMarkerSymbolLayerV2( QString fontFamily = DEFAULT_FONTMARKER_FONT,
QChar chr = DEFAULT_FONTMARKER_CHR,
double pointSize = DEFAULT_FONTMARKER_SIZE,
QColor color = DEFAULT_FONTMARKER_COLOR,
double angle = DEFAULT_FONTMARKER_ANGLE );

// static stuff

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

// implemented from base classes

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );

QgsStringMap properties() const;

QgsSymbolLayerV2* clone() const /Factory/;

void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

// new methods

QString fontFamily() const;
void setFontFamily( QString family );

QChar character() const;
void setCharacter( QChar ch );
};

//////////

typedef QMap<QString, QString> QgsStringMap;

typedef QMap<int, QgsField> QgsFieldMap;
Expand Down
9 changes: 6 additions & 3 deletions src/core/qgsdiagramrendererv2.h
Expand Up @@ -30,8 +30,9 @@ class QgsRenderContext;
class QDomElement;
namespace pal { class Layer; }

struct CORE_EXPORT QgsDiagramLayerSettings
class CORE_EXPORT QgsDiagramLayerSettings
{
public:
//avoid inclusion of QgsPalLabeling
enum Placement
{
Expand Down Expand Up @@ -88,8 +89,9 @@ struct CORE_EXPORT QgsDiagramLayerSettings
};

//diagram settings for rendering
struct CORE_EXPORT QgsDiagramSettings
class CORE_EXPORT QgsDiagramSettings
{
public:
enum SizeType
{
MM,
Expand Down Expand Up @@ -139,8 +141,9 @@ struct CORE_EXPORT QgsDiagramSettings
};

//additional diagram settings for interpolated size rendering
struct CORE_EXPORT QgsDiagramInterpolationSettings
class CORE_EXPORT QgsDiagramInterpolationSettings
{
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
Expand Down

0 comments on commit d8675ba

Please sign in to comment.