Skip to content
Permalink
Browse files
#9480: Add GUI checkbox option in labeling
  • Loading branch information
ahuarte47 committed May 27, 2014
1 parent 59427e2 commit 0fdd3acfe2eacbb2cc5663971233ec3f87aaffff
Showing with 16 additions and 2 deletions.
  1. +2 −0 src/app/qgslabelinggui.cpp
  2. +6 −2 src/core/qgspallabeling.cpp
  3. +1 −0 src/core/qgspallabeling.h
  4. +7 −0 src/ui/qgslabelingguibase.ui
@@ -259,6 +259,7 @@ void QgsLabelingGui::init()

// populate placement options
mCentroidRadioWhole->setChecked( lyr.centroidWhole );
mCentroidInsideCheckBox->setChecked( lyr.centroidInside );
switch ( lyr.placement )
{
case QgsPalLayerSettings::AroundPoint:
@@ -545,6 +546,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()

QWidget* curPlacementWdgt = stackedPlacement->currentWidget();
lyr.centroidWhole = mCentroidRadioWhole->isChecked();
lyr.centroidInside = mCentroidInsideCheckBox->isChecked();
if (( curPlacementWdgt == pagePoint && radAroundPoint->isChecked() )
|| ( curPlacementWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
{
@@ -311,6 +311,7 @@ QgsPalLayerSettings::QgsPalLayerSettings()
placement = AroundPoint;
placementFlags = 0;
centroidWhole = false;
centroidInside = false;
quadOffset = QuadrantOver;
xOffset = 0;
yOffset = 0;
@@ -502,6 +503,7 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
placement = s.placement;
placementFlags = s.placementFlags;
centroidWhole = s.centroidWhole;
centroidInside = s.centroidInside;
quadOffset = s.quadOffset;
xOffset = s.xOffset;
yOffset = s.yOffset;
@@ -997,6 +999,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
placement = ( Placement )layer->customProperty( "labeling/placement" ).toInt();
placementFlags = layer->customProperty( "labeling/placementFlags" ).toUInt();
centroidWhole = layer->customProperty( "labeling/centroidWhole", QVariant( false ) ).toBool();
centroidInside = layer->customProperty( "labeling/centroidInside", QVariant( false ) ).toBool();
dist = layer->customProperty( "labeling/dist" ).toDouble();
distInMapUnits = layer->customProperty( "labeling/distInMapUnits" ).toBool();
distMapUnitScale.minScale = layer->customProperty( "labeling/distMapUnitMinScale", 0.0 ).toDouble();
@@ -1167,6 +1170,7 @@ void QgsPalLayerSettings::writeToLayer( QgsVectorLayer* layer )
layer->setCustomProperty( "labeling/placement", placement );
layer->setCustomProperty( "labeling/placementFlags", ( unsigned int )placementFlags );
layer->setCustomProperty( "labeling/centroidWhole", centroidWhole );
layer->setCustomProperty( "labeling/centroidInside", centroidInside );
layer->setCustomProperty( "labeling/dist", dist );
layer->setCustomProperty( "labeling/distInMapUnits", distInMapUnits );
layer->setCustomProperty( "labeling/distMapUnitMinScale", distMapUnitScale.minScale );
@@ -3389,8 +3393,8 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QStringList& attrNames,
// set whether adjacent lines should be merged
l->setMergeConnectedLines( lyr.mergeLines );

// force the location of the centroid inside of polygons
l->setCentroidInside( true );
// set whether location of centroid must be inside of polygons
l->setCentroidInside( lyr.centroidInside );

// set how to show upside-down labels
Layer::UpsideDownLabels upsdnlabels;
@@ -375,6 +375,7 @@ class CORE_EXPORT QgsPalLayerSettings
unsigned int placementFlags;

bool centroidWhole; // whether centroid calculated from whole or visible polygon
bool centroidInside; // whether centroid-point calculated must be inside polygon
double dist; // distance from the feature (in mm)
bool distInMapUnits; //true if distance is in map units (otherwise in mm)
QgsMapUnitScale distMapUnitScale;
@@ -4101,6 +4101,13 @@ font-style: italic;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="mCentroidInsideCheckBox">
<property name="text">
<string>Force point inside polygon</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 0fdd3ac

Please sign in to comment.