Skip to content
Permalink
Browse files

Force a small minimum distance when label outside mode is used, so th…

…at labels don't touch the polygon by default
  • Loading branch information
nyalldawson committed Apr 30, 2020
1 parent af9bf7e commit 17c47f5ff0107c69774ca7a3c3f7d0c0e57ea586
Showing with 12 additions and 2 deletions.
  1. +11 −1 src/core/labeling/qgspallabeling.cpp
  2. +1 −1 src/ui/qgstextformatwidgetbase.ui
@@ -2505,10 +2505,20 @@ void QgsPalLayerSettings::registerFeature( const QgsFeature &f, QgsRenderContext

// when using certain placement modes, we force a tiny minimum distance. This ensures that
// candidates are created just offset from a border and avoids candidates being incorrectly flagged as colliding with neighbours
if ( placement == QgsPalLayerSettings::Line || placement == QgsPalLayerSettings::Curved || placement == QgsPalLayerSettings::PerimeterCurved )
if ( placement == QgsPalLayerSettings::Line
|| placement == QgsPalLayerSettings::Curved
|| placement == QgsPalLayerSettings::PerimeterCurved )
{
distance = ( distance < 0 ? -1 : 1 ) * std::max( std::fabs( distance ), 1.0 );
}
else if ( placement == QgsPalLayerSettings::OutsidePolygons
|| ( ( placement == QgsPalLayerSettings::Horizontal
|| placement == QgsPalLayerSettings::AroundPoint
|| placement == QgsPalLayerSettings::OverPoint ||
placement == QgsPalLayerSettings::Free ) && polygonPlacementFlags() & QgsLabeling::PolygonPlacementFlag::AllowPlacementOutsideOfPolygon ) )
{
distance = std::max( distance, 1.0 );
}

if ( !qgsDoubleNear( distance, 0.0 ) )
{
@@ -694,7 +694,7 @@
<item>
<widget class="QStackedWidget" name="mLabelStackedWidget">
<property name="currentIndex">
<number>6</number>
<number>7</number>
</property>
<widget class="QWidget" name="mLabelPage_Text">
<layout class="QVBoxLayout" name="verticalLayout_6">

0 comments on commit 17c47f5

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