2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
typedef QList<QgsSymbolLayerV2*> QgsSymbolLayerV2List;
|
|
|
|
|
|
|
|
class QgsSymbolV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgssymbolv2.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
%ConvertToSubClassCode
|
|
|
|
switch (sipCpp->type())
|
|
|
|
{
|
|
|
|
case QgsSymbolV2::Marker: sipClass = sipClass_QgsMarkerSymbolV2; break;
|
|
|
|
case QgsSymbolV2::Line: sipClass = sipClass_QgsLineSymbolV2; break;
|
|
|
|
case QgsSymbolV2::Fill: sipClass = sipClass_QgsFillSymbolV2; break;
|
|
|
|
default: sipClass = 0; break;
|
|
|
|
}
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum OutputUnit
|
|
|
|
{
|
|
|
|
MM,
|
2014-01-27 09:22:24 +01:00
|
|
|
MapUnit,
|
2014-11-17 23:30:00 +11:00
|
|
|
Mixed, //mixed units in symbol layers
|
|
|
|
Pixel
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SymbolType
|
|
|
|
{
|
|
|
|
Marker,
|
|
|
|
Line,
|
|
|
|
Fill
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ScaleMethod
|
|
|
|
{
|
|
|
|
ScaleArea,
|
|
|
|
ScaleDiameter
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RenderHint
|
|
|
|
{
|
2014-06-02 21:00:51 +02:00
|
|
|
DataDefinedSizeScale,
|
|
|
|
DataDefinedRotation
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~QgsSymbolV2();
|
|
|
|
|
|
|
|
//! return new default symbol for specified geometry type
|
|
|
|
static QgsSymbolV2* defaultSymbol( QGis::GeometryType geomType ) /Factory/;
|
|
|
|
|
|
|
|
SymbolType type() const;
|
|
|
|
|
|
|
|
// symbol layers handling
|
2014-11-30 10:26:17 +01:00
|
|
|
|
2014-11-24 20:44:33 +11:00
|
|
|
/**Returns list of symbol layers contained in the symbol.
|
|
|
|
* @returns symbol layers list
|
|
|
|
* @note added in QGIS 2.7
|
|
|
|
* @see symbolLayer
|
|
|
|
* @see symbolLayerCount
|
|
|
|
*/
|
|
|
|
QgsSymbolLayerV2List symbolLayers();
|
|
|
|
|
|
|
|
/**Returns a specific symbol layers contained in the symbol.
|
|
|
|
* @param layer layer number
|
|
|
|
* @returns corresponding symbol layer
|
|
|
|
* @note added in QGIS 2.7
|
|
|
|
* @see symbolLayers
|
|
|
|
* @see symbolLayerCount
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsSymbolLayerV2* symbolLayer( int layer );
|
|
|
|
|
2014-11-24 20:44:33 +11:00
|
|
|
/**Returns total number of symbol layers contained in the symbol.
|
|
|
|
* @returns count of symbol layers
|
|
|
|
* @note added in QGIS 2.7
|
|
|
|
* @see symbolLayers
|
|
|
|
* @see symbolLayer
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
int symbolLayerCount();
|
|
|
|
|
|
|
|
//! 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/ );
|
|
|
|
|
|
|
|
//! 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/;
|
|
|
|
|
|
|
|
//! delete layer at specified index and set a new one
|
|
|
|
bool changeSymbolLayer( int index, QgsSymbolLayerV2 *layer /Transfer/ );
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
void startRender( QgsRenderContext& context, const QgsFields* fields = 0 );
|
2012-09-24 02:28:15 +02:00
|
|
|
void stopRender( QgsRenderContext& context );
|
|
|
|
|
|
|
|
void setColor( const QColor& color );
|
2014-01-26 18:35:21 +01:00
|
|
|
QColor color() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-08-25 21:17:38 +07:00
|
|
|
//! Draw icon of the symbol that occupyies area given by size using the painter.
|
|
|
|
//! Optionally custom context may be given in order to get rendering of symbols that use map units right.
|
|
|
|
//! @note customContext parameter added in 2.6
|
|
|
|
void drawPreviewIcon( QPainter* painter, QSize size, QgsRenderContext* customContext = 0 );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-09-19 21:21:04 +10:00
|
|
|
QImage asImage( QSize size, QgsRenderContext* customContext = 0 );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
QImage bigSymbolPreviewImage();
|
|
|
|
|
2013-07-22 21:41:44 +02:00
|
|
|
QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
virtual QgsSymbolV2* clone() const = 0 /Factory/;
|
|
|
|
|
|
|
|
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
|
|
|
|
|
|
|
|
OutputUnit outputUnit() const;
|
|
|
|
void setOutputUnit( OutputUnit u );
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2014-04-06 21:14:02 +02:00
|
|
|
QgsMapUnitScale mapUnitScale() const;
|
|
|
|
void setMapUnitScale( const QgsMapUnitScale& scale );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! 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 );
|
|
|
|
|
|
|
|
void setRenderHints( int hints );
|
|
|
|
int renderHints() const;
|
|
|
|
|
2015-03-24 23:01:25 +11:00
|
|
|
/**Sets whether features drawn by the symbol should be clipped to the render context's
|
|
|
|
* extent. If this option is enabled then features which are partially outside the extent
|
|
|
|
* will be clipped. This speeds up rendering of the feature, but may have undesirable
|
|
|
|
* side effects for certain symbol types.
|
|
|
|
* @param clipFeaturesToExtent set to true to enable clipping (defaults to true)
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see clipFeaturesToExtent
|
|
|
|
*/
|
|
|
|
void setClipFeaturesToExtent( bool clipFeaturesToExtent );
|
|
|
|
|
|
|
|
/**Returns whether features drawn by the symbol will be clipped to the render context's
|
|
|
|
* extent. If this option is enabled then features which are partially outside the extent
|
|
|
|
* will be clipped. This speeds up rendering of the feature, but may have undesirable
|
|
|
|
* side effects for certain symbol types.
|
|
|
|
* @returns true if features will be clipped
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see setClipFeaturesToExtent
|
|
|
|
*/
|
|
|
|
double clipFeaturesToExtent() const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
QSet<QString> usedAttributes() const;
|
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
void setLayer( const QgsVectorLayer* layer );
|
|
|
|
const QgsVectorLayer* layer() const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
|
|
|
QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers /Transfer/ ); // can't be instantiated
|
|
|
|
|
|
|
|
QgsSymbolLayerV2List cloneLayers() const /Factory/;
|
|
|
|
|
|
|
|
//! check whether a symbol layer type can be used within the symbol
|
|
|
|
//! (marker-marker, line-line, fill-fill/line)
|
|
|
|
bool isSymbolLayerCompatible( SymbolType t );
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
class QgsSymbolV2RenderContext
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgssymbolv2.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2014-11-21 01:17:21 +01:00
|
|
|
QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u, qreal alpha = 1.0, bool selected = false, int renderHints = 0, const QgsFeature* f = 0, const QgsFields* fields = 0, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
|
2012-09-24 02:28:15 +02:00
|
|
|
~QgsSymbolV2RenderContext();
|
|
|
|
|
|
|
|
QgsRenderContext& renderContext();
|
|
|
|
//void setRenderContext( QgsRenderContext& c );
|
|
|
|
|
|
|
|
QgsSymbolV2::OutputUnit outputUnit() const;
|
|
|
|
void setOutputUnit( QgsSymbolV2::OutputUnit u );
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2014-04-06 21:14:02 +02:00
|
|
|
QgsMapUnitScale mapUnitScale() const;
|
|
|
|
void setMapUnitScale( const QgsMapUnitScale& scale);
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! 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 );
|
|
|
|
|
|
|
|
bool selected() const;
|
|
|
|
void setSelected( bool selected );
|
|
|
|
|
|
|
|
int renderHints() const;
|
|
|
|
void setRenderHints( int hints );
|
|
|
|
|
|
|
|
void setFeature( const QgsFeature* f );
|
2013-12-05 18:27:45 +07:00
|
|
|
//! Current feature being rendered - may be null
|
2012-09-24 02:28:15 +02:00
|
|
|
const QgsFeature* feature() const;
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
//! Fields of the layer. Currently only available in startRender() calls
|
|
|
|
//! to allow symbols with data-defined properties prepare the expressions
|
|
|
|
//! (other times fields() returns null)
|
2014-02-21 17:33:09 +07:00
|
|
|
//! @note added in 2.4
|
2013-12-05 18:27:45 +07:00
|
|
|
const QgsFields* fields() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
double outputLineWidth( double width ) const;
|
|
|
|
double outputPixelSize( double size ) const;
|
|
|
|
|
|
|
|
// workaround for sip 4.7. Don't use assignment - will fail with assertion error
|
|
|
|
// QgsSymbolV2RenderContext& operator=( const QgsSymbolV2RenderContext& );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsMarkerSymbolV2 : QgsSymbolV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#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.
|
|
|
|
*/
|
|
|
|
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
|
|
|
|
|
|
|
|
QgsMarkerSymbolV2( QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List() );
|
|
|
|
|
|
|
|
void setAngle( double angle );
|
|
|
|
double angle();
|
|
|
|
|
|
|
|
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/;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsLineSymbolV2 : QgsSymbolV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgssymbolv2.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Create a line symbol with one symbol layer: SimpleLine with specified properties.
|
|
|
|
This is a convenience method for easier creation of line symbols.
|
|
|
|
*/
|
|
|
|
static QgsLineSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
|
|
|
|
|
|
|
|
QgsLineSymbolV2( QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List() );
|
|
|
|
|
|
|
|
void setWidth( double width );
|
|
|
|
double width();
|
|
|
|
|
|
|
|
void renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );
|
|
|
|
|
|
|
|
virtual QgsSymbolV2* clone() const /Factory/;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsFillSymbolV2 : QgsSymbolV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgssymbolv2.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Create a fill symbol with one symbol layer: SimpleFill with specified properties.
|
|
|
|
This is a convenience method for easier creation of fill symbols.
|
|
|
|
*/
|
|
|
|
static QgsFillSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
|
|
|
|
|
|
|
|
QgsFillSymbolV2( QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List() );
|
|
|
|
|
|
|
|
void setAngle( double angle );
|
|
|
|
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );
|
|
|
|
|
|
|
|
virtual QgsSymbolV2* clone() const /Factory/;
|
|
|
|
};
|