Skip to content
Permalink
Browse files
Merge branch 'master' of github.com:qgis/Quantum-GIS
  • Loading branch information
timlinux committed Mar 2, 2012
2 parents 32be114 + ad955e2 commit fd7e03d7b3881b8a8e7eb4515b317b2be2d24301
@@ -77,6 +77,17 @@ public:

virtual QString dump();

enum Capabilities
{
SymbolLevels = 1, // rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
RotationField = 2, // rotate symbols by attribute value
MoreSymbolsPerFeature = 4 // may use more than one symbol to render a feature: symbolsForFeature() will return them
};

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities();

virtual QgsFeatureRendererV2* clone()=0 /Factory/;

virtual QgsSymbolV2List symbols()=0;
@@ -105,6 +116,18 @@ public:
//! @note added in 1.9
virtual void setRotationField( QString fieldName );

//! return whether the renderer will render a feature or not.
//! Must be called between startRender() and stopRender() calls.
//! Default implementation uses symbolForFeature().
//! @note added in 1.9
virtual bool willRenderFeature( QgsFeature& feat );

//! return list of symbols used for rendering the feature.
//! For renderers that do not support MoreSymbolsPerFeature it is more efficient
//! to use symbolForFeature()
//! @note added in 1.9
virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat );

protected:
QgsFeatureRendererV2(QString type);

@@ -154,6 +177,10 @@ public:

virtual QString dump();

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities();

virtual QgsFeatureRendererV2* clone() /Factory/;

virtual QgsSymbolV2List symbols();
@@ -221,6 +248,10 @@ public:

virtual QString dump();

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities();

virtual QgsFeatureRendererV2* clone() /Factory/;

virtual QgsSymbolV2List symbols();
@@ -320,6 +351,10 @@ public:

virtual QString dump();

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities();

virtual QgsFeatureRendererV2* clone() /Factory/;

virtual QgsSymbolV2List symbols();
@@ -410,27 +445,76 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
class Rule
{
public:
//! Constructor takes ownership of the symbol
Rule( QgsSymbolV2* symbol /Transfer/, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString() );
//Rule( const QgsRuleBasedRendererV2::Rule& other );

Rule( QgsSymbolV2* symbol /Transfer/, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString(),
QString label = QString(), QString description = QString() );
~Rule();
QString dump() const;
//QStringList needsFields() const;
QString dump( int offset = 0 ) const;
QSet<QString> usedAttributes();
QgsSymbolV2List symbols();
// TODO QgsLegendSymbolList legendSymbolItems();
bool isFilterOK( QgsFeature& f ) const;
bool isScaleOK( double scale ) const;

QgsSymbolV2* symbol();
QString label() const;
bool dependsOnScale() const;
int scaleMinDenom() const;
int scaleMaxDenom() const;
QString filterExpression() const;
QgsExpression* filter() const;
QString filterExpression() const;
QString description() const;

//! set a new symbol (or NULL). Deletes old symbol.
void setSymbol( QgsSymbolV2* sym /Transfer/ );
void setLabel( QString label );
void setScaleMinDenom( int scaleMinDenom );
void setScaleMaxDenom( int scaleMaxDenom );
void setFilterExpression( QString filterExp );
void setDescription( QString description );

//! clone this rule, return new instance
QgsRuleBasedRendererV2::Rule* clone() const /Factory/;

QDomElement save( QDomDocument& doc, QgsSymbolV2Map& symbolMap );

//! prepare the rule for rendering and its children (build active children array)
bool startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer );
//! get all used z-levels from this rule and children
QSet<int> collectZLevels();
//! assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering
// TODO void setNormZLevels( const QMap<int, int>& zLevelsToNormLevels );

// TODO bool renderFeature( FeatureToRender& featToRender, QgsRenderContext& context, RenderQueue& renderQueue );

//! only tell whether a feature will be rendered without actually rendering it
//! @note added in 1.9
bool willRenderFeature( QgsFeature& feat );

//! tell which symbols will be used to render the feature
//! @note added in 1.9
QgsSymbolV2List symbolsForFeature( QgsFeature& feat );

void stopRender( QgsRenderContext& context );

static QgsRuleBasedRendererV2::Rule* create( QDomElement& ruleElem, QgsSymbolV2Map& symbolMap ) /Factory/;

QList<QgsRuleBasedRendererV2::Rule*>& children();
QgsRuleBasedRendererV2::Rule* parent();

//! add child rule, take ownership, sets this as parent
void appendChild( QgsRuleBasedRendererV2::Rule* rule /Transfer/ );
//! add child rule, take ownership, sets this as parent
void insertChild( int i, QgsRuleBasedRendererV2::Rule* rule /Transfer/ );
//! delete child rule
void removeChild( QgsRuleBasedRendererV2::Rule* rule );
//! delete child rule
void removeChildAt( int i );
//! take child rule out, set parent as null
void takeChild( QgsRuleBasedRendererV2::Rule* rule );
//! take child rule out, set parent as null
QgsRuleBasedRendererV2::Rule* takeChildAt( int i );

//Rule& operator=( const Rule& other );
};

/////
@@ -453,6 +537,12 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2

virtual QList<QString> usedAttributes();

virtual QString dump();

//! returns bitwise OR-ed capabilities of the renderer
//! \note added in 2.0
virtual int capabilities();

virtual QgsFeatureRendererV2* clone() /Factory/;

virtual QgsSymbolV2List symbols();
@@ -463,6 +553,17 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
//! return a list of symbology items for the legend
virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );

//! return whether the renderer will render a feature or not.
//! Must be called between startRender() and stopRender() calls.
//! @note added in 1.9
virtual bool willRenderFeature( QgsFeature& feat );

//! return list of symbols used for rendering the feature.
//! For renderers that do not support MoreSymbolsPerFeature it is more efficient
//! to use symbolForFeature()
//! @note added in 1.9
virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat );

/////


@@ -508,44 +508,48 @@ def lines_to_polygons( self ):
return True

def export_geometry_info( self ):
ellips = None
crs = None
coordTransform = None

# calculate with:
# 0 - layer CRS
# 1 - project CRS
# 2 - ellipsoidal
if self.myCalcType == 2:
settings = QSettings()
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString()
crs = self.vlayer.crs().srsid()
elif self.myCalcType == 1:
mapCRS = self.parent.iface.mapCanvas().mapRenderer().destinationCrs()
layCRS = self.vlayer.crs()
coordTransform = QgsCoordinateTransform( layCRS, mapCRS )

inFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
nElement = 0

vprovider = self.vlayer.dataProvider()

self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0)
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, vprovider.featureCount() ) )

if self.writeShape:
vprovider = self.vlayer.dataProvider()
allAttrs = vprovider.attributeIndexes()
vprovider.select( allAttrs )
( fields, index1, index2 ) = self.checkGeometryFields( self.vlayer )
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
vprovider.geometryType(), vprovider.crs() )
inFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
nFeat = vprovider.featureCount()
nElement = 0

# calculate with:
# 0 - layer CRS
# 1 - project CRS
# 2 - ellipsoidal
ellips = None
crs = None
coordTransform = None
if self.myCalcType == 2:
settings = QSettings()
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString()
crs = self.parent.iface.mapCanvas().mapRenderer().destinationCrs().srsid()
elif self.myCalcType == 1:
mapCRS = self.parent.iface.mapCanvas().mapRenderer().destinationCrs()
layCRS = self.vlayer.crs()
coordTransform = QgsCoordinateTransform( layCRS, mapCRS )

self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0)
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, nFeat ) )

while vprovider.nextFeature(inFeat):
self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), nElement )
nElement += 1
inGeom = inFeat.geometry()

if self.myCalcType == 1:
inGeom.transform( coordTransform )

( attr1, attr2 ) = self.simpleMeasure( inGeom, self.myCalcType, ellips, crs )

outFeat.setGeometry( inGeom )
@@ -558,34 +562,9 @@ def export_geometry_info( self ):
return True
else: # update existing file
newFields = []
vprovider = self.vlayer.dataProvider()
geomType = self.vlayer.geometryType()
( index1, index2 ) = self.findOrCreateFields()

inFeat = QgsFeature()
inGeom = QgsGeometry()
nFeat = vprovider.featureCount()
nElement = 0

# calculate with:
# 0 - layer CRS
# 1 - project CRS
# 2 - ellipsoidal
ellips = None
crs = None
coordTransform = None
if self.myCalcType == 2:
settings = QSettings()
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString()
crs = self.parent.iface.mapCanvas().mapRenderer().destinationCrs().srsid()
elif self.myCalcType == 1:
mapCRS = self.parent.iface.mapCanvas().mapRenderer().destinationCrs()
layCRS = self.vlayer.crs()
coordTransform = QgsCoordinateTransform( layCRS, mapCRS )

self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0)
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, nFeat ) )

while vprovider.nextFeature(inFeat):
self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), nElement )
nElement += 1
@@ -1018,7 +1018,10 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionMeasureAngle );
mMapToolGroup->addAction( mActionAddFeature );
mMapToolGroup->addAction( mActionMoveFeature );
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
mMapToolGroup->addAction( mActionOffsetCurve );
#endif
mMapToolGroup->addAction( mActionReshapeFeatures );
mMapToolGroup->addAction( mActionSplitFeatures );
mMapToolGroup->addAction( mActionDeleteSelected );
@@ -1667,8 +1670,15 @@ void QgisApp::createCanvasTools()
mMapTools.mAddFeature->setAction( mActionAddFeature );
mMapTools.mMoveFeature = new QgsMapToolMoveFeature( mMapCanvas );
mMapTools.mMoveFeature->setAction( mActionMoveFeature );
//need at least geos 3.3 for OffsetCurve tool
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
mMapTools.mOffsetCurve = new QgsMapToolOffsetCurve( mMapCanvas );
mMapTools.mOffsetCurve->setAction( mActionOffsetCurve );
#else
mAdvancedDigitizeToolBar->removeAction( mActionOffsetCurve );
mEditMenu->removeAction( mActionOffsetCurve );
#endif //GEOS_VERSION
mMapTools.mReshapeFeatures = new QgsMapToolReshape( mMapCanvas );
mMapTools.mReshapeFeatures->setAction( mActionReshapeFeatures );
mMapTools.mSplitFeatures = new QgsMapToolSplitFeatures( mMapCanvas );
@@ -352,7 +352,16 @@ void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset, bool leftSide
int joinStyle = s.value( "/qgis/digitizing/offset_join_style", 0 ).toInt();
int quadSegments = s.value( "/qgis/digitizing/offset_quad_seg", 8 ).toInt();
double mitreLimit = s.value( "/qgis/digitizine/offset_miter_limit", 5.0 ).toDouble();
GEOSGeometry* offsetGeom = GEOSSingleSidedBuffer( geosGeom, offset, quadSegments, joinStyle, mitreLimit, leftSide ? 1 : 0 );

GEOSGeometry* offsetGeom = 0;
//need at least geos 3.3 for OffsetCurve tool
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
GEOSGeometry* offsetGeom = GEOSOffsetCurve( geosGeom, ( leftSide > 0 ) ? offset : -offset, quadSegments, joinStyle, mitreLimit );
#else
return;
#endif //GEOS_VERSION

if ( !offsetGeom )
{
deleteRubberBandAndGeometry();
@@ -365,9 +374,6 @@ void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset, bool leftSide
return;
}

//GEOS >= 3.3
//GEOSGeometry* offsetGeom = GEOSOffsetCurve( geosGeom, (leftSide > 0) ? offset : -offset, quadSegments, joinStyle, mitreLimit );

if ( offsetGeom )
{
mModifiedGeometry.fromGeos( offsetGeom );
@@ -417,3 +417,11 @@ void QgsFeatureRendererV2::renderVertexMarkerPolygon( QPolygonF& pts, QList<QPol
}
}
}

QgsSymbolV2List QgsFeatureRendererV2::symbolsForFeature( QgsFeature& feat )
{
QgsSymbolV2List lst;
QgsSymbolV2* s = symbolForFeature( feat );
if ( s ) lst.append( s );
return lst;
}
@@ -81,7 +81,8 @@ class CORE_EXPORT QgsFeatureRendererV2
enum Capabilities
{
SymbolLevels = 1, // rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
RotationField = 1 << 1 // rotate symbols by attribute value
RotationField = 1 << 1, // rotate symbols by attribute value
MoreSymbolsPerFeature = 1 << 2 // may use more than one symbol to render a feature: symbolsForFeature() will return them
};

//! returns bitwise OR-ed capabilities of the renderer
@@ -117,7 +118,17 @@ class CORE_EXPORT QgsFeatureRendererV2
//! @note added in 1.9
virtual void setRotationField( QString fieldName ) { Q_UNUSED( fieldName ); }

//! return whether the renderer will render a feature or not.
//! Must be called between startRender() and stopRender() calls.
//! Default implementation uses symbolForFeature().
//! @note added in 1.9
virtual bool willRenderFeature( QgsFeature& feat ) { return symbolForFeature( feat ) != NULL; }

//! return list of symbols used for rendering the feature.
//! For renderers that do not support MoreSymbolsPerFeature it is more efficient
//! to use symbolForFeature()
//! @note added in 1.9
virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat );

protected:
QgsFeatureRendererV2( QString type );
Loading

0 comments on commit fd7e03d

Please sign in to comment.