Skip to content
Permalink
Browse files

Avoid use of deprecated rotation field methods

  • Loading branch information
nyalldawson committed Aug 6, 2015
1 parent 013e1da commit 728ead8a5322408001718c462c11fc1865631d46
@@ -254,7 +254,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
static QgsRuleBasedRendererV2* convertFromRenderer( const QgsFeatureRendererV2 *renderer ) /Factory/;

//! helper function to convert the size scale and rotation fields present in some other renderers to data defined symbology
static void convertToDataDefinedSymbology( QgsSymbolV2* symbol, QString sizeScaleField, QString rotationField );
static void convertToDataDefinedSymbology( QgsSymbolV2* symbol, QString sizeScaleField, QString rotationField = QString() );

private:
QgsRuleBasedRendererV2( const QgsRuleBasedRendererV2 & );
@@ -32,7 +32,6 @@ class QgsCategorizedSymbolRendererV2Widget : QgsRendererV2Widget
void deleteCategories();
void deleteAllCategories();

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

@@ -30,7 +30,6 @@ class QgsGraduatedSymbolRendererV2Widget : QgsRendererV2Widget
/** Toggle the link between classes boundaries */
void toggleBoundariesLink( bool linked );

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
void labelFormatChanged();
@@ -14,7 +14,6 @@ class QgsSingleSymbolRendererV2Widget : QgsRendererV2Widget
public slots:
void changeSingleSymbol();

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

@@ -21,6 +21,7 @@
#include "qgssnappingutils.h"
#include "qgssymbolv2.h"
#include "qgsvectorlayer.h"
#include "qgsdatadefined.h"
#include <QGraphicsPixmapItem>
#include <QMouseEvent>

@@ -239,8 +240,10 @@ int QgsMapToolRotatePointSymbols::layerRotationAttributes( QgsVectorLayer* vl, Q
const QgsFeatureRendererV2* symbologyNgRenderer = vl->rendererV2();
if ( symbologyNgRenderer )
{
//rotation field is supported for QgsSingleSymbolRendererV2, QgsCategorizedRendererV2, QgsUniqueCategorizedRendererV2
//TODO - replace this method with code which handles data defined rotation on the symbol level
Q_NOWARN_DEPRECATED_PUSH
QString rotationFieldName = symbologyNgRenderer->rotationField();
Q_NOWARN_DEPRECATED_POP

if ( !rotationFieldName.isEmpty() )
{
@@ -277,13 +280,14 @@ void QgsMapToolRotatePointSymbols::createPixmapItem( QgsFeature& f )
if ( mActiveLayer && mActiveLayer->rendererV2() ) //symbology-ng
{
QgsFeatureRendererV2* rv2 = mActiveLayer->rendererV2()->clone();
rv2->setRotationField( "" );
rv2->startRender( renderContext, mActiveLayer->fields() );

QgsSymbolV2* symbolV2 = rv2->symbolForFeature( f );
if ( symbolV2 )
if ( symbolV2 && symbolV2->type() == QgsSymbolV2::Marker )
{
pointImage = symbolV2->bigSymbolPreviewImage();
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( symbolV2 );
markerSymbol->setDataDefinedAngle( QgsDataDefined() );
pointImage = markerSymbol->bigSymbolPreviewImage();
}
rv2->stopRender( renderContext );
delete rv2;
@@ -1125,7 +1125,7 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::convertFromRenderer( const QgsFe
return 0;

QgsSymbolV2* origSymbol = singleSymbolRenderer->symbol()->clone();
convertToDataDefinedSymbology( origSymbol, singleSymbolRenderer->sizeScaleField(), singleSymbolRenderer->rotationField() );
convertToDataDefinedSymbology( origSymbol, singleSymbolRenderer->sizeScaleField() );
return new QgsRuleBasedRendererV2( origSymbol );
}

@@ -1174,7 +1174,7 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::convertFromRenderer( const QgsFe
//data dependent area and rotation, so we need to convert these to obtain the same rendering

QgsSymbolV2* origSymbol = category.symbol()->clone();
convertToDataDefinedSymbology( origSymbol, categorizedRenderer->sizeScaleField(), categorizedRenderer->rotationField() );
convertToDataDefinedSymbology( origSymbol, categorizedRenderer->sizeScaleField() );
rule->setSymbol( origSymbol );

rootrule->appendChild( rule );
@@ -1216,7 +1216,7 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::convertFromRenderer( const QgsFe
//data dependent area and rotation, so we need to convert these to obtain the same rendering

QgsSymbolV2* symbol = range.symbol()->clone();
convertToDataDefinedSymbology( symbol, graduatedRenderer->sizeScaleField(), graduatedRenderer->rotationField() );
convertToDataDefinedSymbology( symbol, graduatedRenderer->sizeScaleField() );

rule->setSymbol( symbol );

@@ -1251,19 +1251,19 @@ void QgsRuleBasedRendererV2::convertToDataDefinedSymbology( QgsSymbolV2* symbol,
for ( int j = 0; j < symbol->symbolLayerCount();++j )
{
QgsMarkerSymbolLayerV2* msl = static_cast<QgsMarkerSymbolLayerV2*>( symbol->symbolLayer( j ) );
if ( ! sizeScaleField.isNull() )
if ( ! sizeScaleField.isEmpty() )
{
sizeExpression = QString( "%1*(%2)" ).arg( msl->size() ).arg( sizeScaleField );
msl->setDataDefinedProperty( "size", new QgsDataDefined( sizeExpression ) );
}
if ( ! rotationField.isNull() )
if ( ! rotationField.isEmpty() )
{
msl->setDataDefinedProperty( "angle", new QgsDataDefined( true, false, QString(), rotationField ) );
}
}
break;
case QgsSymbolV2::Line:
if ( ! sizeScaleField.isNull() )
if ( ! sizeScaleField.isEmpty() )
{
for ( int j = 0; j < symbol->symbolLayerCount();++j )
{
@@ -301,7 +301,7 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
static QgsRuleBasedRendererV2* convertFromRenderer( const QgsFeatureRendererV2 *renderer );

//! helper function to convert the size scale and rotation fields present in some other renderers to data defined symbology
static void convertToDataDefinedSymbology( QgsSymbolV2* symbol, QString sizeScaleField, QString rotationField );
static void convertToDataDefinedSymbology( QgsSymbolV2* symbol, QString sizeScaleField, QString rotationField = QString() );

protected:
//! the root node with hierarchical list of rules
@@ -749,7 +749,6 @@ void QgsCategorizedSymbolRendererV2Widget::addCategories()
r->setSourceSymbol( mCategorizedSymbol->clone() );
r->setScaleMethod( mRenderer->scaleMethod() );
r->setSizeScaleField( mRenderer->sizeScaleField() );
r->setRotationField( mRenderer->rotationField() );
r->setInvertedColorRamp( cbxInvertedColorRamp->isChecked() );
QgsVectorColorRampV2* ramp = getColorRamp();
if ( ramp ) r->setSourceColorRamp( ramp->clone() );
@@ -815,11 +814,6 @@ void QgsCategorizedSymbolRendererV2Widget::addCategory()
mModel->addCategory( cat );
}

void QgsCategorizedSymbolRendererV2Widget::rotationFieldChanged( QString fldName )
{
mRenderer->setRotationField( fldName );
}

void QgsCategorizedSymbolRendererV2Widget::sizeScaleFieldChanged( QString fldName )
{
mRenderer->setSizeScaleField( fldName );
@@ -100,7 +100,6 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg
void deleteCategories();
void deleteAllCategories();

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

@@ -985,11 +985,6 @@ void QgsGraduatedSymbolRendererV2Widget::changeCurrentValue( QStandardItem * ite
}
}

void QgsGraduatedSymbolRendererV2Widget::rotationFieldChanged( QString fldName )
{
mRenderer->setRotationField( fldName );
}

void QgsGraduatedSymbolRendererV2Widget::sizeScaleFieldChanged( QString fldName )
{
mRenderer->setSizeScaleField( fldName );
@@ -100,7 +100,6 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
/** Toggle the link between classes boundaries */
void toggleBoundariesLink( bool linked );

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
void labelFormatChanged();
@@ -94,14 +94,15 @@ class QgsFields;

/**
Utility class for providing GUI for data-defined rendering.
@deprecated unused, will be removed in QGIS 3.0
*/
class QgsRendererV2DataDefinedMenus : public QObject
{
Q_OBJECT

public:

QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
Q_DECL_DEPRECATED QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
~QgsRendererV2DataDefinedMenus();

void populateMenu( QMenu* menu, QString fieldName, QActionGroup *actionGroup );
@@ -86,11 +86,6 @@ void QgsSingleSymbolRendererV2Widget::changeSingleSymbol()
mRenderer->setSymbol( mSingleSymbol->clone() );
}

void QgsSingleSymbolRendererV2Widget::rotationFieldChanged( QString fldName )
{
mRenderer->setRotationField( fldName );
}

void QgsSingleSymbolRendererV2Widget::sizeScaleFieldChanged( QString fldName )
{
mRenderer->setSizeScaleField( fldName );
@@ -37,7 +37,6 @@ class GUI_EXPORT QgsSingleSymbolRendererV2Widget : public QgsRendererV2Widget
public slots:
void changeSingleSymbol();

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

0 comments on commit 728ead8

Please sign in to comment.
You can’t perform that action at this time.