add sip bindings for QgsPalLabeling, QgsSimpleMarkerSymbolLayerV2,

QgsSvgMarkerSymbolLayerV2, QgsFontMarkerSymbolLayerV2
This commit is contained in:
Juergen E. Fischer 2012-09-16 20:20:01 +02:00
parent 21c5988556
commit d8675ba32a
8 changed files with 263 additions and 64 deletions

View File

@ -102,6 +102,7 @@
%Include qgsnetworkaccessmanager.sip
%Include symbology-ng-core.sip
%Include qgspallabeling.sip
%Include qgsgpsconnection.sip
%Include qgsgpsconnectionregistry.sip

View File

@ -609,6 +609,7 @@ class QgsSymbolLayerV2
public:
// not necessarily supported by all symbol layers...
virtual void setColor(const QColor& color);
virtual QColor color() const;
@ -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;
@ -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);
@ -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);
@ -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
@ -794,52 +815,56 @@ 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
@ -847,6 +872,8 @@ public:
//! @note added in 1.5
void setRenderHints( int hints );
QSet<QString> usedAttributes() const;
protected:
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers /Transfer/); // can't be instantiated
@ -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());
@ -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/;
@ -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;

View File

@ -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
{
@ -88,8 +89,9 @@ struct CORE_EXPORT QgsDiagramLayerSettings
};
//diagram settings for rendering
struct CORE_EXPORT QgsDiagramSettings
class CORE_EXPORT QgsDiagramSettings
{
public:
enum SizeType
{
MM,
@ -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;

View File

@ -39,10 +39,11 @@ class QgsDistanceArea;
class QgsOverlayObjectPositionManager;
class QgsVectorLayer;
struct QgsDiagramLayerSettings;
class QgsDiagramLayerSettings;
struct CORE_EXPORT QgsLabelPosition
class CORE_EXPORT QgsLabelPosition
{
public:
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, bool upside_down, bool diagram = false, bool pinned = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
@ -61,7 +62,7 @@ struct CORE_EXPORT QgsLabelPosition
/** Labeling engine interface.
* \note Added in QGIS v1.4
*/
class QgsLabelingEngineInterface
class CORE_EXPORT QgsLabelingEngineInterface
{
public:

View File

@ -28,7 +28,7 @@ class QgsMapRenderer;
class QgsRectangle;
class QgsCoordinateTransform;
class QgsLabelSearchTree;
struct QgsDiagramLayerSettings;
class QgsDiagramLayerSettings;
#include <QString>
#include <QFont>
@ -121,8 +121,12 @@ class CORE_EXPORT QgsPalLayerSettings
unsigned int placementFlags;
// offset labels of point/centroid features default to center
// move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
int xQuadOffset, yQuadOffset;
double xOffset, yOffset; // offset from point in mm or map units
int xQuadOffset;
int yQuadOffset;
// offset from point in mm or map units
double xOffset;
double yOffset;
double angleOffset; // rotation applied to offset labels
bool centroidWhole; // whether centroid calculated from whole or visible polygon
QFont textFont;
@ -136,7 +140,10 @@ class CORE_EXPORT QgsPalLayerSettings
double dist; // distance from the feature (in mm)
double vectorScaleFactor; //scale factor painter units->pixels
double rasterCompressFactor; //pixel resolution scale factor
int scaleMin, scaleMax; // disabled if both are zero
// disabled if both are zero
int scaleMin;
int scaleMax;
double bufferSize; //buffer size (in mm)
QColor bufferColor;
int bufferTransp;
@ -171,16 +178,6 @@ class CORE_EXPORT QgsPalLayerSettings
/**Set a property to static instead data defined*/
void removeDataDefinedProperty( DataDefinedProperties p );
// temporary stuff: set when layer gets prepared
pal::Layer* palLayer;
int fieldIndex;
QFontMetricsF* fontMetrics;
const QgsMapToPixel* xform;
const QgsCoordinateTransform* ct;
QgsPoint ptZero, ptOne;
QList<QgsPalGeometry*> geometries;
QgsGeometry* extentGeom;
/**Stores field indices for data defined layer properties*/
QMap< DataDefinedProperties, int > dataDefinedProperties;
@ -193,6 +190,16 @@ class CORE_EXPORT QgsPalLayerSettings
@return font pixel size*/
int sizeToPixel( double size, const QgsRenderContext& c , bool buffer = false ) const;
// temporary stuff: set when layer gets prepared
pal::Layer* palLayer;
int fieldIndex;
QFontMetricsF* fontMetrics;
const QgsMapToPixel* xform;
const QgsCoordinateTransform* ct;
QgsPoint ptZero, ptOne;
QList<QgsPalGeometry*> geometries;
QgsGeometry* extentGeom;
private:
/**Checks if a feature is larger than a minimum size (in mm)
@return true if above size, false if below*/

View File

@ -48,7 +48,7 @@ class QgsRectangle;
class QgsVectorLayerJoinBuffer;
class QgsFeatureRendererV2;
class QgsDiagramRendererV2;
struct QgsDiagramLayerSettings;
class QgsDiagramLayerSettings;
typedef QList<int> QgsAttributeList;
typedef QSet<int> QgsAttributeIds;

View File

@ -97,7 +97,6 @@ class CORE_EXPORT QgsSymbolV2
//! delete layer at specified index and set a new one
bool changeSymbolLayer( int index, QgsSymbolLayerV2* layer );
void startRender( QgsRenderContext& context, const QgsVectorLayer* layer = 0 );
void stopRender( QgsRenderContext& context );

View File

@ -1029,12 +1029,15 @@ bool QgsPostgresProvider::loadFields()
QString attnum = tresult.PQgetvalue( 0, 0 );
formattedFieldType = tresult.PQgetvalue( 0, 1 );
sql = QString( "SELECT description FROM pg_description WHERE objoid=%1 AND objsubid=%2" )
.arg( tableoid ).arg( attnum );
if( !attnum.isEmpty() )
{
sql = QString( "SELECT description FROM pg_description WHERE objoid=%1 AND objsubid=%2" )
.arg( tableoid ).arg( attnum );
tresult = mConnectionRO->PQexec( sql );
if ( tresult.PQntuples() > 0 )
fieldComment = tresult.PQgetvalue( 0, 0 );
tresult = mConnectionRO->PQexec( sql );
if ( tresult.PQntuples() > 0 )
fieldComment = tresult.PQgetvalue( 0, 0 );
}
}
QVariant::Type fieldType;