[QGIS Commit] r11043 - in branches/symbology-ng-branch/src:
core/pal plugins/labeling
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Jul 11 08:37:28 EDT 2009
Author: wonder
Date: 2009-07-11 08:37:27 -0400 (Sat, 11 Jul 2009)
New Revision: 11043
Modified:
branches/symbology-ng-branch/src/core/pal/feature.cpp
branches/symbology-ng-branch/src/core/pal/feature.h
branches/symbology-ng-branch/src/core/pal/pal.h
branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp
branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui
branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
Log:
Added over point / over centroid placement. Instead of creating candidates around the point it creates candidates "on top" of the point.
Modified: branches/symbology-ng-branch/src/core/pal/feature.cpp
===================================================================
--- branches/symbology-ng-branch/src/core/pal/feature.cpp 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/core/pal/feature.cpp 2009-07-11 12:37:27 UTC (rev 11043)
@@ -151,6 +151,28 @@
return uid;
}
+ int Feature::setPositionOverPoint( double x, double y, double scale, LabelPosition ***lPos, double delta_width )
+ {
+ int nbp = 3;
+ *lPos = new LabelPosition *[nbp];
+
+ double lx = x - label_x / 2;
+ double ly = y - label_y / 2;
+ double cost = 0.0001;
+ int id = 0;
+ double alpha = 0;
+
+ double offset = label_x / 4;
+
+ // at the center
+ ( *lPos )[0] = new LabelPosition( id, lx, ly, label_x, label_y, alpha, cost, this );
+ // shifted to the sides - with higher cost
+ cost = 0.0021;
+ ( *lPos )[1] = new LabelPosition( id, lx+offset, ly, label_x, label_y, alpha, cost, this );
+ ( *lPos )[2] = new LabelPosition( id, lx-offset, ly, label_x, label_y, alpha, cost, this );
+ return nbp;
+ }
+
int Feature::setPositionForPoint( double x, double y, double scale, LabelPosition ***lPos, double delta_width )
{
@@ -793,7 +815,10 @@
{
case GEOS_POINT:
fetchCoordinates();
- nbp = setPositionForPoint( x[0], y[0], scale, lPos, delta );
+ if ( layer->getArrangement() == P_POINT_OVER )
+ nbp = setPositionOverPoint( x[0], y[0], scale, lPos, delta );
+ else
+ nbp = setPositionForPoint( x[0], y[0], scale, lPos, delta );
#ifdef _EXPORT_MAP_
toSVGPath( nbPoints, type, x, y, dpi , scale,
convert2pt( bbox_min[0], scale, dpi ),
@@ -810,9 +835,13 @@
switch ( layer->getArrangement() )
{
case P_POINT:
+ case P_POINT_OVER:
double cx, cy;
mapShape->getCentroid( cx, cy );
- nbp = setPositionForPoint( cx, cy, scale, lPos, delta );
+ if (P_POINT_OVER)
+ nbp = setPositionOverPoint( cx, cy, scale, lPos, delta );
+ else
+ nbp = setPositionForPoint( cx, cy, scale, lPos, delta );
break;
case P_LINE:
case P_LINE_AROUND:
Modified: branches/symbology-ng-branch/src/core/pal/feature.h
===================================================================
--- branches/symbology-ng-branch/src/core/pal/feature.h 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/core/pal/feature.h 2009-07-11 12:37:27 UTC (rev 11043)
@@ -108,6 +108,11 @@
int setPositionForPoint( double x, double y, double scale, LabelPosition ***lPos, double delta_width );
/**
+ * generate one candidate over specified point
+ */
+ int setPositionOverPoint( double x, double y, double scale, LabelPosition ***lPos, double delta_width );
+
+ /**
* \brief generate candidates for line feature
* Generate candidates for line features
* \param scale map scale is 1:scale
Modified: branches/symbology-ng-branch/src/core/pal/pal.h
===================================================================
--- branches/symbology-ng-branch/src/core/pal/pal.h 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/core/pal/pal.h 2009-07-11 12:37:27 UTC (rev 11043)
@@ -98,6 +98,7 @@
enum _arrangement
{
P_POINT = 0, /**< arranges candidates around a point (centroid for polygon)*/
+ P_POINT_OVER, /** arranges candidates over a point (centroid for polygon)*/
P_LINE, /**< Only for lines and polygons, arranges candidates over the line or the polygon perimeter */
P_HORIZ, /**< Only for polygon, arranges candidates horizontaly */
P_FREE, /**< Only for polygon, arranges candidates with respect of polygon orientation */
Modified: branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp 2009-07-11 12:37:27 UTC (rev 11043)
@@ -76,6 +76,10 @@
spinDistPoint->setValue(lyr.dist);
//spinAngle->setValue(lyr.angle);
break;
+ case LayerSettings::OverPoint:
+ radOverPoint->setChecked(true);
+ radOverCentroid->setChecked(true);
+ break;
case LayerSettings::AroundLine:
case LayerSettings::OnLine:
radLineParallel->setChecked(true);
@@ -170,6 +174,11 @@
lyr.dist = spinDistPoint->value();
//lyr.angle = spinAngle->value();
}
+ else if ( (stackedPlacement->currentWidget() == pagePoint && radOverPoint->isChecked())
+ || (stackedPlacement->currentWidget() == pagePolygon && radOverCentroid->isChecked()) )
+ {
+ lyr.placement = LayerSettings::OverPoint;
+ }
else if ( (stackedPlacement->currentWidget() == pageLine && radLineParallel->isChecked())
|| (stackedPlacement->currentWidget() == pagePolygon && radPolygonPerimeter->isChecked()) )
{
Modified: branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui 2009-07-11 12:37:27 UTC (rev 11043)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>454</width>
- <height>474</height>
+ <height>514</height>
</rect>
</property>
<property name="windowTitle">
@@ -77,7 +77,7 @@
<item>
<widget class="QStackedWidget" name="stackedPlacement">
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="pagePoint">
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -93,9 +93,6 @@
</item>
<item>
<widget class="QRadioButton" name="radOverPoint">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>over point</string>
</property>
@@ -130,9 +127,9 @@
<widget class="QWidget" name="pagePolygon">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
- <widget class="QRadioButton" name="radAroundCentroid">
+ <widget class="QRadioButton" name="radOverCentroid">
<property name="text">
- <string>around centroid</string>
+ <string>over centroid</string>
</property>
<property name="checked">
<bool>true</bool>
@@ -140,6 +137,13 @@
</widget>
</item>
<item>
+ <widget class="QRadioButton" name="radAroundCentroid">
+ <property name="text">
+ <string>around centroid</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QRadioButton" name="radPolygonHorizontal">
<property name="text">
<string>horizontal (slow)</string>
Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp 2009-07-11 12:37:27 UTC (rev 11043)
@@ -239,6 +239,7 @@
switch (lyr->placement)
{
case LayerSettings::AroundPoint: arrangement = P_POINT; break;
+ case LayerSettings::OverPoint: arrangement = P_POINT_OVER; break;
case LayerSettings::OnLine: arrangement = P_LINE; break;
case LayerSettings::AroundLine: arrangement = P_LINE_AROUND; break;
case LayerSettings::Horizontal: arrangement = P_HORIZ; break;
Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h 2009-07-11 10:08:12 UTC (rev 11042)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h 2009-07-11 12:37:27 UTC (rev 11043)
@@ -34,6 +34,7 @@
enum Placement
{
AroundPoint, // Point / Polygon
+ OverPoint, // Point / Polygon
OnLine, // Line / Polygon
AroundLine, // Line / Polygon
Horizontal, // Polygon
More information about the QGIS-commit
mailing list