Skip to content

Commit 7479708

Browse files
author
wonder
committed
MarkerLine symbol layer: fixed usage with map units, set minimal interval 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@13421 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent bdc4a9c commit 7479708

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,19 @@ void QgsMarkerLineSymbolLayerV2::setColor( QColor color )
246246

247247
void QgsMarkerLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
248248
{
249+
mMarker->setAlpha( context.alpha() );
250+
mMarker->setOutputUnit( context.outputUnit() );
251+
249252
// if being rotated, it gets initialized with every line segment
250-
if ( !mRotateMarker )
251-
{
252-
mMarker->setAlpha( context.alpha() );
253-
mMarker->startRender( context.renderContext() );
254-
}
253+
if ( mRotateMarker )
254+
mMarker->setRenderHints( QgsSymbolV2::DataDefinedRotation );
255+
256+
mMarker->startRender( context.renderContext() );
255257
}
256258

257259
void QgsMarkerLineSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
258260
{
259-
if ( !mRotateMarker )
260-
{
261-
mMarker->stopRender( context.renderContext() );
262-
}
261+
mMarker->stopRender( context.renderContext() );
263262
}
264263

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

285-
double painterUnitInterval = context.outputLineWidth( mInterval );
284+
double painterUnitInterval = context.outputLineWidth( mInterval > 0 ? mInterval : 0.1 );
286285

287286
QgsRenderContext& rc = context.renderContext();
288287

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

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

331328
lastPt = pt;
332-
333-
if ( mRotateMarker )
334-
mMarker->stopRender( rc );
335329
}
336330

337331
// restore original rotation
@@ -375,6 +369,16 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::clone() const
375369
return x;
376370
}
377371

372+
void QgsMarkerLineSymbolLayerV2::setWidth( double width )
373+
{
374+
mMarker->setSize( width );
375+
}
376+
377+
double QgsMarkerLineSymbolLayerV2::width() const
378+
{
379+
return mMarker->size();
380+
}
381+
378382
/////////////
379383

380384
QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2( QColor color )

src/core/symbology-ng/qgslinesymbollayerv2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2
108108
QgsSymbolV2* subSymbol();
109109
bool setSubSymbol( QgsSymbolV2* symbol );
110110

111+
virtual void setWidth( double width );
112+
virtual double width() const;
113+
111114
// new stuff
112115

113116
bool rotateMarker() const { return mRotateMarker; }

src/core/symbology-ng/qgssymbollayerv2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
9999
public:
100100
virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0;
101101

102-
void setWidth( double width ) { mWidth = width; }
103-
double width() const { return mWidth; }
102+
virtual void setWidth( double width ) { mWidth = width; }
103+
virtual double width() const { return mWidth; }
104104

105105
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
106106

0 commit comments

Comments
 (0)