Skip to content

Commit

Permalink
Labeling: allowed to set priority for a layer and whether's it should…
Browse files Browse the repository at this point in the history
… 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 committed Jun 5, 2009
1 parent 02d5b93 commit 96a9cba
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 61 deletions.
4 changes: 4 additions & 0 deletions src/plugins/labeling/labelinggui.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
Expand Down
112 changes: 52 additions & 60 deletions src/plugins/labeling/labelingguibase.ui
Expand Up @@ -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">
Expand All @@ -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>
Expand Down Expand Up @@ -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">
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/labeling/pallabeling.cpp
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/labeling/pallabeling.h
Expand Up @@ -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);
Expand Down

0 comments on commit 96a9cba

Please sign in to comment.