Skip to content

Commit

Permalink
MarkerLine symbol layer: fixed usage with map units, set minimal inte…
Browse files Browse the repository at this point in the history
…rval to avoid infinite loop, simpler markerline symbol handling.

Developed for Faunalia (http://www.faunalia.it) with funding from Regione Toscana - Sistema Informativo per la Gestione del Territorio e dell' Ambiente [RT-SIGTA]".
For the project: "Sviluppo di prodotti software GIS open-source basati sui prodotti QuantumGIS e Postgis (CIG 037728516E)"


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13421 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed May 4, 2010
1 parent 788e27e commit 0a5a263
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
34 changes: 19 additions & 15 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,19 @@ void QgsMarkerLineSymbolLayerV2::setColor( QColor color )

void QgsMarkerLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
mMarker->setAlpha( context.alpha() );
mMarker->setOutputUnit( context.outputUnit() );

// if being rotated, it gets initialized with every line segment
if ( !mRotateMarker )
{
mMarker->setAlpha( context.alpha() );
mMarker->startRender( context.renderContext() );
}
if ( mRotateMarker )
mMarker->setRenderHints( QgsSymbolV2::DataDefinedRotation );

mMarker->startRender( context.renderContext() );
}

void QgsMarkerLineSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
if ( !mRotateMarker )
{
mMarker->stopRender( context.renderContext() );
}
mMarker->stopRender( context.renderContext() );
}

void QgsMarkerLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
Expand All @@ -282,7 +281,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineNoOffset( const QPolygonF& points
bool first = true;
double origAngle = mMarker->angle();

double painterUnitInterval = context.outputLineWidth( mInterval );
double painterUnitInterval = context.outputLineWidth( mInterval > 0 ? mInterval : 0.1 );

QgsRenderContext& rc = context.renderContext();

Expand All @@ -306,9 +305,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineNoOffset( const QPolygonF& points
// rotate marker (if desired)
if ( mRotateMarker )
{
mMarker->setAlpha( context.alpha() );
mMarker->setAngle( origAngle + ( l.angle() * 180 / M_PI ) );
mMarker->startRender( rc );
}

// draw first marker
Expand All @@ -329,9 +326,6 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineNoOffset( const QPolygonF& points
}

lastPt = pt;

if ( mRotateMarker )
mMarker->stopRender( rc );
}

// restore original rotation
Expand Down Expand Up @@ -375,6 +369,16 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::clone() const
return x;
}

void QgsMarkerLineSymbolLayerV2::setWidth( double width )
{
mMarker->setSize( width );
}

double QgsMarkerLineSymbolLayerV2::width() const
{
return mMarker->size();
}

/////////////

QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color )
Expand Down
3 changes: 3 additions & 0 deletions src/core/symbology-ng/qgslinesymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
QgsSymbolV2* subSymbol();
bool setSubSymbol( QgsSymbolV2* symbol );

virtual void setWidth( double width );
virtual double width() const;

// new stuff

bool rotateMarker() const { return mRotateMarker; }
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgssymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
public:
virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0;

void setWidth( double width ) { mWidth = width; }
double width() const { return mWidth; }
virtual void setWidth( double width ) { mWidth = width; }
virtual double width() const { return mWidth; }

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

Expand Down

0 comments on commit 0a5a263

Please sign in to comment.