[QGIS Commit] r10907 - branches/symbology-ng-branch/src/plugins/labeling

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Jun 12 08:35:40 EDT 2009


Author: wonder
Date: 2009-06-12 08:35:40 -0400 (Fri, 12 Jun 2009)
New Revision: 10907

Modified:
   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:
Option to set distance from label to the feature. Available for points and lines.


Modified: branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp	2009-06-12 11:45:20 UTC (rev 10906)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp	2009-06-12 12:35:40 UTC (rev 10907)
@@ -51,6 +51,7 @@
     chkEnableLabeling->setChecked( lyr.enabled );
     sliderPriority->setValue( lyr.priority );
     chkNoObstacle->setChecked( !lyr.obstacle );
+    spinDist->setValue( lyr.dist );
   }
   else
   {
@@ -58,6 +59,12 @@
     chkEnableLabeling->setChecked( true );
   }
 
+  // feature distance available only for points and lines
+  if (layer()->geometryType() == QGis::Polygon)
+  {
+    spinDist->setEnabled( false );
+  }
+
   btnTextColor->setColor( lyr.textColor );
   updateFontPreview( lyr.textFont );
 }
@@ -85,6 +92,7 @@
   lyr.enabled = chkEnableLabeling->isChecked();
   lyr.priority = sliderPriority->value();
   lyr.obstacle = !chkNoObstacle->isChecked();
+  lyr.dist = spinDist->value();
 
   return lyr;
 }

Modified: branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui	2009-06-12 11:45:20 UTC (rev 10906)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui	2009-06-12 12:35:40 UTC (rev 10907)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>354</width>
-    <height>435</height>
+    <height>436</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -67,6 +67,34 @@
      <item row="1" column="1">
       <widget class="QComboBox" name="cboFieldName"/>
      </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="label_8">
+       <property name="text">
+        <string>Label distance</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <layout class="QHBoxLayout" name="horizontalLayout_3">
+       <item>
+        <widget class="QDoubleSpinBox" name="spinDist">
+         <property name="decimals">
+          <number>0</number>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="label_9">
+         <property name="text">
+          <string>pixels</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
     </layout>
    </item>
    <item>

Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp	2009-06-12 11:45:20 UTC (rev 10906)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp	2009-06-12 12:35:40 UTC (rev 10907)
@@ -94,6 +94,10 @@
 
   // register feature to the layer
   palLayer->registerFeature(lbl->strId(), lbl, labelX, labelY);
+
+  // TODO: allow layer-wide feature dist in PAL...?
+  if (dist != 0)
+    palLayer->setFeatureDistlabel(lbl->strId(), dist);
 }
 
 
@@ -176,6 +180,9 @@
   PalLabeling* thisClass = (PalLabeling*) context;
   LayerSettings* lyr = (LayerSettings*) layerContext;
 
+  if (!lyr->enabled)
+    return 0;
+
   QgsVectorLayer* vlayer = (QgsVectorLayer*) QgsMapLayerRegistry::instance()->mapLayer(lyr->layerId);
   if (vlayer == NULL)
     return 0;

Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h	2009-06-12 11:45:20 UTC (rev 10906)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h	2009-06-12 12:35:40 UTC (rev 10907)
@@ -42,6 +42,7 @@
   bool enabled;
   int priority; // 0 = low, 10 = high
   bool obstacle; // whether it's an obstacle
+  double dist; // distance from the feature
 
   // called from register feature hook
   void calculateLabelSize(QString text, double& labelX, double& labelY);



More information about the QGIS-commit mailing list