Skip to content
Permalink
Browse files
Rename "respect multipart" to "place on every part"
  • Loading branch information
nyalldawson committed Nov 13, 2021
1 parent a6d4f92 commit 637e5ca748dbd68eb9ce5c3aa7370916274865e4
@@ -714,36 +714,36 @@ Sets the ``placement`` of the symbols.
.. versionadded:: 3.24
%End

bool respectMultipart() const;
bool placeOnEveryPart() const;
%Docstring
Returns ``True`` if the placement respects multi-part feature geometries.
Returns ``True`` if the placement applies for every part of multi-part feature geometries.

The default is ``False``, which means that Qgis.MarkerLinePlacement.FirstVertex or
The default is ``True``, which means that Qgis.MarkerLinePlacement.FirstVertex or
Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on
the first/last vertex of EVERY part of a multipart feature.

If ``True``, then Qgis.MarkerLinePlacement.FirstVertex or
If ``False``, then Qgis.MarkerLinePlacement.FirstVertex or
Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on
the first/last vertex of the overall multipart geometry only.

.. seealso:: :py:func:`setRespectMultipart`
.. seealso:: :py:func:`setPlaceOnEveryPart`

.. versionadded:: 3.24
%End

void setRespectMultipart( bool respect );
void setPlaceOnEveryPart( bool respect );
%Docstring
Sets whether the placement respects multi-part feature geometries.
Sets whether the placement applies for every part of multi-part feature geometries.

The default is ``False``, which means that Qgis.MarkerLinePlacement.FirstVertex or
The default is ``True``, which means that Qgis.MarkerLinePlacement.FirstVertex or
Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on
the first/last vertex of EVERY part of a multipart feature.

If ``True``, then Qgis.MarkerLinePlacement.FirstVertex or
If ``False``, then Qgis.MarkerLinePlacement.FirstVertex or
Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on
the first/last vertex of the overall multipart geometry only.

.. seealso:: :py:func:`respectMultipart`
.. seealso:: :py:func:`placeOnEveryPart`

.. versionadded:: 3.24
%End
@@ -1342,7 +1342,7 @@ void QgsTemplatedLineSymbolLayerBase::renderPolyline( const QPolygonF &points, Q
if ( placements & Qgis::MarkerLinePlacement::Vertex )
renderPolylineVertex( points, context, Qgis::MarkerLinePlacement::Vertex );
if ( placements & Qgis::MarkerLinePlacement::FirstVertex
&& ( !mRespectMultipart || !mHasRenderedFirstPart ) )
&& ( mPlaceOnEveryPart || !mHasRenderedFirstPart ) )
{
renderPolylineVertex( points, context, Qgis::MarkerLinePlacement::FirstVertex );
mHasRenderedFirstPart = mRenderingFeature;
@@ -1376,7 +1376,7 @@ void QgsTemplatedLineSymbolLayerBase::renderPolyline( const QPolygonF &points, Q
if ( placements & Qgis::MarkerLinePlacement::LastVertex )
renderPolylineVertex( points2, context, Qgis::MarkerLinePlacement::LastVertex );
if ( placements & Qgis::MarkerLinePlacement::FirstVertex
&& ( !mRespectMultipart || !mHasRenderedFirstPart ) )
&& ( mPlaceOnEveryPart || !mHasRenderedFirstPart ) )
{
renderPolylineVertex( points2, context, Qgis::MarkerLinePlacement::FirstVertex );
mHasRenderedFirstPart = mRenderingFeature;
@@ -1498,13 +1498,13 @@ QVariantMap QgsTemplatedLineSymbolLayerBase::properties() const
map[QStringLiteral( "placements" )] = qgsFlagValueToKeys( mPlacements );

map[QStringLiteral( "ring_filter" )] = QString::number( static_cast< int >( mRingFilter ) );
map[QStringLiteral( "respect_multipart" )] = mRespectMultipart;
map[QStringLiteral( "place_on_every_part" )] = mPlaceOnEveryPart;
return map;
}

bool QgsTemplatedLineSymbolLayerBase::canCauseArtifactsBetweenAdjacentTiles() const
{
return mRespectMultipart
return mPlaceOnEveryPart
|| ( mPlacements & Qgis::MarkerLinePlacement::Interval )
|| ( mPlacements & Qgis::MarkerLinePlacement::CentralPoint )
|| ( mPlacements & Qgis::MarkerLinePlacement::SegmentCenter );
@@ -1519,7 +1519,7 @@ void QgsTemplatedLineSymbolLayerBase::startFeatureRender( const QgsFeature &, Qg
void QgsTemplatedLineSymbolLayerBase::stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context )
{
mRenderingFeature = false;
if ( !mRespectMultipart || !( mPlacements & Qgis::MarkerLinePlacement::LastVertex ) )
if ( mPlaceOnEveryPart || !( mPlacements & Qgis::MarkerLinePlacement::LastVertex ) )
return;

const double prevOpacity = subSymbol()->opacity();
@@ -1547,7 +1547,7 @@ void QgsTemplatedLineSymbolLayerBase::copyTemplateSymbolProperties( QgsTemplated
destLayer->setAverageAngleUnit( mAverageAngleLengthUnit );
destLayer->setAverageAngleMapUnitScale( mAverageAngleLengthMapUnitScale );
destLayer->setRingFilter( mRingFilter );
destLayer->setRespectMultipart( mRespectMultipart );
destLayer->setPlaceOnEveryPart( mPlaceOnEveryPart );
copyDataDefinedProperties( destLayer );
copyPaintEffect( destLayer );
}
@@ -1629,7 +1629,7 @@ void QgsTemplatedLineSymbolLayerBase::setCommonProperties( QgsTemplatedLineSymbo
destLayer->setRingFilter( static_cast< RenderRingFilter>( properties[QStringLiteral( "ring_filter" )].toInt() ) );
}

destLayer->setRespectMultipart( properties.value( QStringLiteral( "respect_multipart" ), false ).toBool() );
destLayer->setPlaceOnEveryPart( properties.value( QStringLiteral( "place_on_every_part" ), true ).toBool() );

destLayer->restoreOldDataDefinedProperties( properties );
}
@@ -1970,7 +1970,7 @@ void QgsTemplatedLineSymbolLayerBase::renderPolylineVertex( const QPolygonF &poi
}

mFinalVertex = symbolPoint;
if ( i != points.count() - 1 || placement != Qgis::MarkerLinePlacement::LastVertex || !mRespectMultipart || !mRenderingFeature )
if ( i != points.count() - 1 || placement != Qgis::MarkerLinePlacement::LastVertex || mPlaceOnEveryPart || !mRenderingFeature )
renderSymbol( symbolPoint, context.feature(), rc, -1, context.selected() );
}
}
@@ -2068,7 +2068,7 @@ void QgsTemplatedLineSymbolLayerBase::renderOffsetVertexAlongLine( const QPolygo
setSymbolLineAngle( angle * 180 / M_PI );
}
mFinalVertex = points[vertex];
if ( placement != Qgis::MarkerLinePlacement::LastVertex || !mRespectMultipart || !mRenderingFeature )
if ( placement != Qgis::MarkerLinePlacement::LastVertex || mPlaceOnEveryPart || !mRenderingFeature )
renderSymbol( points[vertex], context.feature(), rc, -1, context.selected() );
return;
}
@@ -2099,7 +2099,7 @@ void QgsTemplatedLineSymbolLayerBase::renderOffsetVertexAlongLine( const QPolygo
setSymbolLineAngle( l.angle() * 180 / M_PI );
}
mFinalVertex = markerPoint;
if ( placement != Qgis::MarkerLinePlacement::LastVertex || !mRespectMultipart || !mRenderingFeature )
if ( placement != Qgis::MarkerLinePlacement::LastVertex || mPlaceOnEveryPart || !mRenderingFeature )
renderSymbol( markerPoint, context.feature(), rc, -1, context.selected() );
return;
}
@@ -652,36 +652,36 @@ class CORE_EXPORT QgsTemplatedLineSymbolLayerBase : public QgsLineSymbolLayer
void setPlacements( Qgis::MarkerLinePlacements placements ) { mPlacements = placements; }

/**
* Returns TRUE if the placement respects multi-part feature geometries.
* Returns TRUE if the placement applies for every part of multi-part feature geometries.
*
* The default is FALSE, which means that Qgis::MarkerLinePlacement::FirstVertex or
* The default is TRUE, which means that Qgis::MarkerLinePlacement::FirstVertex or
* Qgis::MarkerLinePlacement::LastVertex placements will result in a symbol on
* the first/last vertex of EVERY part of a multipart feature.
*
* If TRUE, then Qgis::MarkerLinePlacement::FirstVertex or
* If FALSE, then Qgis::MarkerLinePlacement::FirstVertex or
* Qgis::MarkerLinePlacement::LastVertex placements will result in a symbol on
* the first/last vertex of the overall multipart geometry only.
*
* \see setRespectMultipart()
* \see setPlaceOnEveryPart()
* \since QGIS 3.24
*/
bool respectMultipart() const { return mRespectMultipart; }
bool placeOnEveryPart() const { return mPlaceOnEveryPart; }

/**
* Sets whether the placement respects multi-part feature geometries.
* Sets whether the placement applies for every part of multi-part feature geometries.
*
* The default is FALSE, which means that Qgis::MarkerLinePlacement::FirstVertex or
* The default is TRUE, which means that Qgis::MarkerLinePlacement::FirstVertex or
* Qgis::MarkerLinePlacement::LastVertex placements will result in a symbol on
* the first/last vertex of EVERY part of a multipart feature.
*
* If TRUE, then Qgis::MarkerLinePlacement::FirstVertex or
* If FALSE, then Qgis::MarkerLinePlacement::FirstVertex or
* Qgis::MarkerLinePlacement::LastVertex placements will result in a symbol on
* the first/last vertex of the overall multipart geometry only.
*
* \see respectMultipart()
* \see placeOnEveryPart()
* \since QGIS 3.24
*/
void setRespectMultipart( bool respect ) { mRespectMultipart = respect; }
void setPlaceOnEveryPart( bool respect ) { mPlaceOnEveryPart = respect; }

/**
* Returns the offset along the line for the symbol placement. For Interval placements, this is the distance
@@ -894,7 +894,7 @@ class CORE_EXPORT QgsTemplatedLineSymbolLayerBase : public QgsLineSymbolLayer
double mAverageAngleLength = 4;
QgsUnitTypes::RenderUnit mAverageAngleLengthUnit = QgsUnitTypes::RenderMillimeters;
QgsMapUnitScale mAverageAngleLengthMapUnitScale;
bool mRespectMultipart = false;
bool mPlaceOnEveryPart = true;

bool mRenderingFeature = false;
bool mHasRenderedFirstPart = false;
@@ -1934,11 +1934,11 @@ QgsMarkerLineSymbolLayerWidget::QgsMarkerLineSymbolLayerWidget( QgsVectorLayer *
connect( mCheckCentralPoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
connect( mCheckCurvePoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
connect( mCheckSegmentCentralPoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
connect( mCheckRespectMultipart, &QCheckBox::toggled, this, [ = ]
connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled, this, [ = ]
{
if ( mLayer )
{
mLayer->setRespectMultipart( mCheckRespectMultipart->isChecked() );
mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
emit changed();
}
} );
@@ -1976,7 +1976,7 @@ void QgsMarkerLineSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
whileBlocking( mCheckCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CentralPoint );
whileBlocking( mCheckCurvePoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CurvePoint );
whileBlocking( mCheckSegmentCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::SegmentCenter );
whileBlocking( mCheckRespectMultipart )->setChecked( mLayer->respectMultipart() );
whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );

// set units
mIntervalUnitWidget->blockSignals( true );
@@ -2194,11 +2194,11 @@ QgsHashedLineSymbolLayerWidget::QgsHashedLineSymbolLayerWidget( QgsVectorLayer *
connect( mCheckCurvePoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
connect( mCheckSegmentCentralPoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );

connect( mCheckRespectMultipart, &QCheckBox::toggled, this, [ = ]
connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled, this, [ = ]
{
if ( mLayer )
{
mLayer->setRespectMultipart( mCheckRespectMultipart->isChecked() );
mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
emit changed();
}
} );
@@ -2238,7 +2238,7 @@ void QgsHashedLineSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
whileBlocking( mCheckCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CentralPoint );
whileBlocking( mCheckCurvePoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CurvePoint );
whileBlocking( mCheckSegmentCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::SegmentCenter );
whileBlocking( mCheckRespectMultipart )->setChecked( mLayer->respectMultipart() );
whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );

// set units
mIntervalUnitWidget->blockSignals( true );
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>385</width>
<height>502</height>
<height>533</height>
</rect>
</property>
<property name="windowTitle">
@@ -473,12 +473,12 @@
</widget>
</item>
<item row="4" column="0" colspan="5">
<widget class="QCheckBox" name="mCheckRespectMultipart">
<widget class="QCheckBox" name="mCheckPlaceOnEveryPart">
<property name="toolTip">
<string>If checked, the &quot;first vertex&quot; or &quot;last vertex&quot; placements will only be rendered once for each multipart geometry</string>
<string>If checked, the &quot;first vertex&quot; or &quot;last vertex&quot; placements will rendered at the first and last vertex for every part of multipart geometries</string>
</property>
<property name="text">
<string>Respect multipart geometries</string>
<string>Place on every part</string>
</property>
</widget>
</item>
@@ -525,7 +525,7 @@
<tabstop>mHashRotationSpinBox</tabstop>
<tabstop>mHashRotationDDBtn</tabstop>
<tabstop>chkRotateMarker</tabstop>
<tabstop>mCheckRespectMultipart</tabstop>
<tabstop>mCheckPlaceOnEveryPart</tabstop>
<tabstop>mSpinAverageAngleLength</tabstop>
<tabstop>mAverageAngleUnit</tabstop>
<tabstop>mAverageAngleDDBtn</tabstop>
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>385</width>
<height>434</height>
<height>465</height>
</rect>
</property>
<property name="windowTitle">
@@ -382,12 +382,12 @@
<widget class="QComboBox" name="mRingFilterComboBox"/>
</item>
<item row="2" column="0" colspan="5">
<widget class="QCheckBox" name="mCheckRespectMultipart">
<widget class="QCheckBox" name="mCheckPlaceOnEveryPart">
<property name="toolTip">
<string>If checked, the &quot;first vertex&quot; or &quot;last vertex&quot; placements will only be rendered once for each multipart geometry</string>
<string>If checked, the &quot;first vertex&quot; or &quot;last vertex&quot; placements will rendered at the first and last vertex for every part of multipart geometries</string>
</property>
<property name="text">
<string>Respect multipart geometries</string>
<string>Place on every part</string>
</property>
</widget>
</item>
@@ -429,7 +429,7 @@
<tabstop>mOffsetAlongLineUnitWidget</tabstop>
<tabstop>mOffsetAlongLineDDBtn</tabstop>
<tabstop>chkRotateMarker</tabstop>
<tabstop>mCheckRespectMultipart</tabstop>
<tabstop>mCheckPlaceOnEveryPart</tabstop>
<tabstop>mSpinAverageAngleLength</tabstop>
<tabstop>mAverageAngleUnit</tabstop>
<tabstop>mAverageAngleDDBtn</tabstop>
@@ -137,7 +137,7 @@ def testFirstVertexNoRespectMultipart(self):
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
line_symbol[0].setSubSymbol(marker_symbol)
line_symbol[0].setRespectMultipart(False)
line_symbol[0].setPlaceOnEveryPart(True)

g = QgsGeometry.fromWkt('MultiLineString((0 0, 10 0, 10 10, 0 10),(3 3, 7 3, 7 7, 3 7))')
rendered_image = self.renderGeometry(line_symbol, g)
@@ -156,7 +156,7 @@ def testFirstVertexRespectMultipart(self):
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
line_symbol[0].setSubSymbol(marker_symbol)
line_symbol[0].setRespectMultipart(True)
line_symbol[0].setPlaceOnEveryPart(False)

g = QgsGeometry.fromWkt('MultiLineString((0 0, 10 0, 10 10, 0 10),(3 3, 7 3, 7 7, 3 7))')
rendered_image = self.renderGeometry(line_symbol, g)
@@ -175,7 +175,7 @@ def testLastVertexNoRespectMultipart(self):
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
line_symbol[0].setSubSymbol(marker_symbol)
line_symbol[0].setRespectMultipart(False)
line_symbol[0].setPlaceOnEveryPart(True)

g = QgsGeometry.fromWkt('MultiLineString((0 0, 10 0, 10 10, 0 10),(3 3, 7 3, 7 7, 3 7))')
rendered_image = self.renderGeometry(line_symbol, g)
@@ -194,7 +194,7 @@ def testLastVertexRespectMultipart(self):
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
line_symbol[0].setSubSymbol(marker_symbol)
line_symbol[0].setRespectMultipart(True)
line_symbol[0].setPlaceOnEveryPart(False)

g = QgsGeometry.fromWkt('MultiLineString((0 0, 10 0, 10 10, 0 10),(3 3, 7 3, 7 7, 3 7))')
rendered_image = self.renderGeometry(line_symbol, g)
@@ -213,7 +213,7 @@ def testFirstLastVertexNoRespectMultipart(self):
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
line_symbol[0].setSubSymbol(marker_symbol)
line_symbol[0].setRespectMultipart(False)
line_symbol[0].setPlaceOnEveryPart(True)

g = QgsGeometry.fromWkt('MultiLineString((0 0, 10 0, 10 10, 0 10),(3 3, 7 3, 7 7, 3 7))')
rendered_image = self.renderGeometry(line_symbol, g)
@@ -232,7 +232,7 @@ def testFirstLastVertexRespectMultipart(self):
marker_symbol = QgsMarkerSymbol()
marker_symbol.changeSymbolLayer(0, marker)
line_symbol[0].setSubSymbol(marker_symbol)
line_symbol[0].setRespectMultipart(True)
line_symbol[0].setPlaceOnEveryPart(False)

g = QgsGeometry.fromWkt('MultiLineString((0 0, 10 0, 10 10, 0 10),(3 3, 7 3, 7 7, 3 7))')
rendered_image = self.renderGeometry(line_symbol, g)

0 comments on commit 637e5ca

Please sign in to comment.