Skip to content
Permalink
Browse files

Labeling: allowed to set priority for a layer and whether's it should…

… be considered as an obstacle.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10889 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jun 5, 2009
1 parent 02d5b93 commit 96a9cbab22bd3a8683f49867802bfd14754de2cd
@@ -49,6 +49,8 @@ LabelingGui::LabelingGui( PalLabeling* lbl, QString layerId, QWidget* parent )
cboPlacement->setCurrentIndex( cboPlacement->findData( QVariant( (int)lyr.placement ) ) );
cboFieldName->setCurrentIndex( cboFieldName->findText(lyr.fieldName) );
chkEnableLabeling->setChecked( lyr.enabled );
sliderPriority->setValue( lyr.priority );
chkNoObstacle->setChecked( !lyr.obstacle );
}
else
{
@@ -81,6 +83,8 @@ PalLabeling::LayerSettings LabelingGui::layerSettings()
lyr.textColor = btnTextColor->color();
lyr.textFont = lblFontPreview->font();
lyr.enabled = chkEnableLabeling->isChecked();
lyr.priority = sliderPriority->value();
lyr.obstacle = !chkNoObstacle->isChecked();

return lyr;
}
@@ -182,6 +182,58 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Priority</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Low</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="sliderPriority">
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>High</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkNoObstacle">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>not an obstacle</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
@@ -195,53 +247,6 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Priority</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinPriority">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="chkNoObstacle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>not an obstacle</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -269,19 +274,6 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@@ -141,7 +141,8 @@ int PalLabeling::prepareLayer(Pal& pal, const LayerSettings& lyr)
}

// create the pal layer
Layer* l = pal.addLayer(lyr.layerId.toLocal8Bit().data(), -1, -1, arrangement, METER, 0, true, true, true);
double priority = 1 - lyr.priority/10.0; // convert 0..10 --> 1..0
Layer* l = pal.addLayer(lyr.layerId.toLocal8Bit().data(), -1, -1, arrangement, METER, priority, lyr.obstacle, true, true);

QFontMetrics fm(lyr.textFont);

@@ -36,6 +36,8 @@ class PalLabeling
QFont textFont;
QColor textColor;
bool enabled;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
};

void doLabeling(QPainter* painter);

0 comments on commit 96a9cba

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