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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jul 4 20:01:20 EDT 2009


Author: wonder
Date: 2009-07-04 20:01:19 -0400 (Sat, 04 Jul 2009)
New Revision: 11025

Added:
   branches/symbology-ng-branch/src/plugins/labeling/labelpreview.cpp
   branches/symbology-ng-branch/src/plugins/labeling/labelpreview.h
Modified:
   branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt
   branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp
   branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h
   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 scale-based visibility and buffer (mask) around the label


Modified: branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt	2009-07-04 22:49:32 UTC (rev 11024)
+++ branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt	2009-07-05 00:01:19 UTC (rev 11025)
@@ -7,6 +7,7 @@
      labelinggui.cpp
      pallabeling.cpp
      engineconfigdialog.cpp
+     labelpreview.cpp
 )
 
 SET (labeling_UIS labelingguibase.ui engineconfigdialog.ui)
@@ -35,6 +36,7 @@
      ../../core ../../core/raster ../../core/renderer ../../core/symbology
      ../../gui
      ..
+     .
 )
 
 TARGET_LINK_LIBRARIES(labelingplugin

Modified: branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp	2009-07-04 22:49:32 UTC (rev 11024)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp	2009-07-05 00:01:19 UTC (rev 11025)
@@ -30,6 +30,8 @@
 #include <iostream>
 #include <QApplication>
 
+
+
 LabelingGui::LabelingGui( PalLabeling* lbl, QString layerId, QWidget* parent )
     : QDialog( parent ), mLBL( lbl ), mLayerId( layerId )
 {
@@ -37,6 +39,9 @@
 
   connect(btnTextColor, SIGNAL(clicked()), this, SLOT(changeTextColor()) );
   connect(btnChangeFont, SIGNAL(clicked()), this, SLOT(changeTextFont()) );
+  connect(chkBuffer, SIGNAL(toggled(bool)), this, SLOT(updatePreview()) );
+  connect(btnBufferColor, SIGNAL(clicked()), this, SLOT(changeBufferColor()) );
+  connect(spinBufferSize, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()) );
   connect(btnEngineSettings, SIGNAL(clicked()), this, SLOT(showEngineConfigDialog()) );
 
   populatePlacementMethods();
@@ -52,11 +57,25 @@
     sliderPriority->setValue( lyr.priority );
     chkNoObstacle->setChecked( !lyr.obstacle );
     spinDist->setValue( lyr.dist );
+
+    bool scaleBased = (lyr.scaleMin != 0 && lyr.scaleMax != 0);
+    chkScaleBasedVisibility->setChecked(scaleBased);
+    if (scaleBased)
+    {
+      spinScaleMin->setValue(lyr.scaleMin);
+      spinScaleMax->setValue(lyr.scaleMax);
+    }
+
+    bool buffer = (lyr.bufferSize != 0);
+    chkBuffer->setChecked(buffer);
+    if (buffer)
+      spinBufferSize->setValue(lyr.bufferSize);
   }
   else
   {
     // set enabled by default
     chkEnableLabeling->setChecked( true );
+
   }
 
   // feature distance available only for points and lines
@@ -66,7 +85,12 @@
   }
 
   btnTextColor->setColor( lyr.textColor );
-  updateFontPreview( lyr.textFont );
+  btnBufferColor->setColor( lyr.bufferColor );
+  updateFont( lyr.textFont );
+  updateUi();
+
+  connect(chkBuffer, SIGNAL(toggled(bool)), this, SLOT(updateUi()) );
+  connect(chkScaleBasedVisibility, SIGNAL(toggled(bool)), this, SLOT(updateUi()) );
 }
 
 LabelingGui::~LabelingGui()
@@ -93,6 +117,24 @@
   lyr.priority = sliderPriority->value();
   lyr.obstacle = !chkNoObstacle->isChecked();
   lyr.dist = spinDist->value();
+  if (chkScaleBasedVisibility->isChecked())
+  {
+    lyr.scaleMin = spinScaleMin->value();
+    lyr.scaleMax = spinScaleMax->value();
+  }
+  else
+  {
+    lyr.scaleMin = lyr.scaleMax = 0;
+  }
+  if (chkBuffer->isChecked())
+  {
+    lyr.bufferSize = spinBufferSize->value();
+    lyr.bufferColor = btnBufferColor->color();
+  }
+  else
+  {
+    lyr.bufferSize = 0;
+  }
 
   return lyr;
 }
@@ -134,7 +176,7 @@
     return;
 
   btnTextColor->setColor(color);
-  updateFontPreview( lblFontPreview->font() );
+  updatePreview();
 }
 
 void LabelingGui::changeTextFont()
@@ -142,23 +184,50 @@
   bool ok;
   QFont font = QFontDialog::getFont(&ok, lblFontPreview->font(), this);
   if (ok)
-    updateFontPreview( font );
+    updateFont( font );
 }
 
-void LabelingGui::updateFontPreview(QFont font)
+void LabelingGui::updateFont(QFont font)
 {
   lblFontName->setText( QString("%1, %2").arg(font.family()).arg(font.pointSize()) );
   lblFontPreview->setFont(font);
 
-  QPalette palette = lblFontPreview->palette();
-  QBrush brush(btnTextColor->color());
-  palette.setBrush(QPalette::Active, QPalette::WindowText, brush);
-  palette.setBrush(QPalette::Inactive, QPalette::WindowText, brush);
-  lblFontPreview->setPalette(palette);
+  updatePreview();
 }
 
+void LabelingGui::updatePreview()
+{
+  lblFontPreview->setTextColor(btnTextColor->color());
+  if (chkBuffer->isChecked())
+    lblFontPreview->setBuffer(spinBufferSize->value(), btnBufferColor->color());
+  else
+    lblFontPreview->setBuffer(0, Qt::white);
+}
+
 void LabelingGui::showEngineConfigDialog()
 {
   EngineConfigDialog dlg(mLBL, this);
   dlg.exec();
 }
+
+void LabelingGui::updateUi()
+{
+  // enable/disable scale-based, buffer
+  bool buf = chkBuffer->isChecked();
+  spinBufferSize->setEnabled(buf);
+  btnBufferColor->setEnabled(buf);
+
+  bool scale = chkScaleBasedVisibility->isChecked();
+  spinScaleMin->setEnabled(scale);
+  spinScaleMax->setEnabled(scale);
+}
+
+void LabelingGui::changeBufferColor()
+{
+  QColor color = QColorDialog::getColor( btnBufferColor->color(), this);
+  if (!color.isValid())
+    return;
+
+  btnBufferColor->setColor(color);
+  updatePreview();
+}

Modified: branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h	2009-07-04 22:49:32 UTC (rev 11024)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h	2009-07-05 00:01:19 UTC (rev 11025)
@@ -41,11 +41,15 @@
     void changeTextColor();
     void changeTextFont();
     void showEngineConfigDialog();
+    void changeBufferColor();
 
+    void updateUi();
+    void updatePreview();
+
   protected:
     void populatePlacementMethods();
     void populateFieldNames();
-    void updateFontPreview(QFont font);
+    void updateFont(QFont font);
 
     QgsVectorLayer* layer();
 

Modified: branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui	2009-07-04 22:49:32 UTC (rev 11024)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui	2009-07-05 00:01:19 UTC (rev 11025)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>354</width>
-    <height>436</height>
+    <height>608</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -18,7 +18,7 @@
     <normaloff/>
    </iconset>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <widget class="QCheckBox" name="chkEnableLabeling">
      <property name="text">
@@ -119,26 +119,43 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="1" colspan="2">
-       <widget class="QLabel" name="lblFontName">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
-          <horstretch>1</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="text">
-         <string>TextLabel</string>
-        </property>
-       </widget>
+      <item row="0" column="1">
+       <layout class="QHBoxLayout" name="horizontalLayout_5">
+        <item>
+         <widget class="QLabel" name="lblFontName">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+            <horstretch>1</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>TextLabel</string>
+          </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>
+        <item>
+         <widget class="QToolButton" name="btnChangeFont">
+          <property name="text">
+           <string>...</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
-      <item row="0" column="3">
-       <widget class="QToolButton" name="btnChangeFont">
-        <property name="text">
-         <string>...</string>
-        </property>
-       </widget>
-      </item>
       <item row="1" column="0">
        <widget class="QLabel" name="label_3">
         <property name="sizePolicy">
@@ -156,35 +173,106 @@
        </widget>
       </item>
       <item row="1" column="1">
-       <widget class="QgsColorButton" name="btnTextColor">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_6">
+        <item>
+         <widget class="QgsColorButton" name="btnTextColor">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeType">
+           <enum>QSizePolicy::Preferred</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>142</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_10">
         <property name="text">
-         <string/>
+         <string>Buffer</string>
         </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
        </widget>
       </item>
-      <item row="1" column="2" colspan="2">
-       <spacer name="horizontalSpacer">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeType">
-         <enum>QSizePolicy::Preferred</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>142</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
+      <item row="2" column="1">
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <widget class="QCheckBox" name="chkBuffer">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_11">
+          <property name="text">
+           <string>Size</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="spinBufferSize">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_12">
+          <property name="text">
+           <string>Color</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QgsColorButton" name="btnBufferColor">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>...</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
-      <item row="2" column="0">
+      <item row="4" column="0">
        <widget class="QLabel" name="label_7">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -200,13 +288,29 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="1" colspan="3">
-       <widget class="QLabel" name="lblFontPreview">
+      <item row="4" column="1">
+       <widget class="LabelPreview" name="lblFontPreview">
+        <property name="minimumSize">
+         <size>
+          <width>30</width>
+          <height>30</height>
+         </size>
+        </property>
         <property name="text">
          <string>Lorem Ipsum</string>
         </property>
+        <property name="alignment">
+         <set>Qt::AlignCenter</set>
+        </property>
        </widget>
       </item>
+      <item row="3" column="0" colspan="2">
+       <widget class="Line" name="line">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -253,6 +357,69 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="groupBox_3">
+     <property name="title">
+      <string>Scale-based visibility</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QCheckBox" name="chkScaleBasedVisibility">
+        <property name="text">
+         <string>Enabled</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_7">
+        <item>
+         <widget class="QLabel" name="label_13">
+          <property name="text">
+           <string>Minimum</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="spinScaleMin">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+          <property name="maximum">
+           <number>10000000</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_14">
+          <property name="text">
+           <string>Maximum</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="spinScaleMax">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+          <property name="maximum">
+           <number>10000000</number>
+          </property>
+          <property name="value">
+           <number>10000000</number>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <widget class="QCheckBox" name="chkNoObstacle">
      <property name="enabled">
       <bool>true</bool>
@@ -321,7 +488,30 @@
    <extends>QToolButton</extends>
    <header>qgscolorbutton.h</header>
   </customwidget>
+  <customwidget>
+   <class>LabelPreview</class>
+   <extends>QLabel</extends>
+   <header>labelpreview.h</header>
+  </customwidget>
  </customwidgets>
+ <tabstops>
+  <tabstop>chkEnableLabeling</tabstop>
+  <tabstop>cboPlacement</tabstop>
+  <tabstop>cboFieldName</tabstop>
+  <tabstop>spinDist</tabstop>
+  <tabstop>btnChangeFont</tabstop>
+  <tabstop>btnTextColor</tabstop>
+  <tabstop>chkBuffer</tabstop>
+  <tabstop>spinBufferSize</tabstop>
+  <tabstop>btnBufferColor</tabstop>
+  <tabstop>sliderPriority</tabstop>
+  <tabstop>chkScaleBasedVisibility</tabstop>
+  <tabstop>spinScaleMin</tabstop>
+  <tabstop>spinScaleMax</tabstop>
+  <tabstop>chkNoObstacle</tabstop>
+  <tabstop>btnEngineSettings</tabstop>
+  <tabstop>buttonBox</tabstop>
+ </tabstops>
  <resources/>
  <connections>
   <connection>
@@ -331,8 +521,8 @@
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>360</x>
-     <y>415</y>
+     <x>344</x>
+     <y>575</y>
     </hint>
     <hint type="destinationlabel">
      <x>309</x>
@@ -347,11 +537,11 @@
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>526</x>
-     <y>414</y>
+     <x>344</x>
+     <y>575</y>
     </hint>
     <hint type="destinationlabel">
-     <x>544</x>
+     <x>353</x>
      <y>430</y>
     </hint>
    </hints>

Added: branches/symbology-ng-branch/src/plugins/labeling/labelpreview.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelpreview.cpp	                        (rev 0)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelpreview.cpp	2009-07-05 00:01:19 UTC (rev 11025)
@@ -0,0 +1,37 @@
+#include "labelpreview.h"
+
+#include <QPainter>
+
+#include "pallabeling.h"
+
+LabelPreview::LabelPreview(QWidget* parent)
+ : QLabel(parent)
+{
+}
+
+void LabelPreview::setTextColor(QColor color)
+{
+  mTextColor = color;
+  update();
+}
+
+void LabelPreview::setBuffer(int size, QColor color)
+{
+  mBufferSize = size;
+  mBufferColor = color;
+  update();
+}
+
+void LabelPreview::paintEvent(QPaintEvent* e)
+{
+  QPainter p(this);
+
+  p.setFont(font());
+  p.setPen(mTextColor);
+  p.translate(10, 20); // uhm...
+
+  if (mBufferSize != 0)
+    PalLabeling::drawLabelBuffer(&p, text(), mBufferSize, mBufferColor);
+
+  p.drawText(0,0, text());
+}

Added: branches/symbology-ng-branch/src/plugins/labeling/labelpreview.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelpreview.h	                        (rev 0)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelpreview.h	2009-07-05 00:01:19 UTC (rev 11025)
@@ -0,0 +1,23 @@
+#ifndef LABELPREVIEW_H
+#define LABELPREVIEW_H
+
+#include <QLabel>
+
+class LabelPreview : public QLabel
+{
+public:
+  LabelPreview(QWidget* parent = NULL);
+
+  void setTextColor(QColor color);
+
+  void setBuffer(int size, QColor color);
+
+  void paintEvent(QPaintEvent* e);
+
+private:
+  int mBufferSize;
+  QColor mBufferColor;
+  QColor mTextColor;
+};
+
+#endif // LABELPREVIEW_H

Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp	2009-07-04 22:49:32 UTC (rev 11024)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp	2009-07-05 00:01:19 UTC (rev 11025)
@@ -68,6 +68,7 @@
 LayerSettings::LayerSettings()
   : palLayer(NULL), fontMetrics(NULL), ct(NULL)
 {
+  bufferColor = Qt::white;
 }
 
 LayerSettings::LayerSettings(const LayerSettings& s)
@@ -82,6 +83,10 @@
   priority = s.priority;
   obstacle = s.obstacle;
   dist = s.dist;
+  scaleMin = s.scaleMin;
+  scaleMax = s.scaleMax;
+  bufferSize = s.bufferSize;
+  bufferColor = s.bufferColor;
 
   fontMetrics = NULL;
   ct = NULL;
@@ -241,8 +246,15 @@
 
   // create the pal layer
   double priority = 1 - lyr->priority/10.0; // convert 0..10 --> 1..0
-  Layer* l = thisClass->mPal->addLayer(lyr->layerId.toLocal8Bit().data(), -1, -1, arrangement, METER, priority, lyr->obstacle, true, true);
+  double min_scale = -1, max_scale = -1;
+  if (lyr->scaleMin != 0 && lyr->scaleMax != 0)
+  {
+    min_scale = lyr->scaleMin;
+    max_scale = lyr->scaleMax;
+  }
 
+  Layer* l = thisClass->mPal->addLayer(lyr->layerId.toLocal8Bit().data(), min_scale, max_scale, arrangement, METER, priority, lyr->obstacle, true, true);
+
   // save the pal layer to our layer context (with some additional info)
   lyr->palLayer = l;
   lyr->fieldIndex = fldIndex;
@@ -300,7 +312,7 @@
   t.start();
 
   // do the labeling itself
-  double scale = 1; // scale denominator
+  double scale = mMapRenderer->scale(); // scale denominator
   QgsRectangle r = extent;
   double bbox[] = { r.xMinimum(), r.yMinimum(), r.xMaximum(), r.yMaximum() };
 
@@ -366,13 +378,19 @@
     // TODO: optimize access :)
     const LayerSettings& lyr = layer(label->getLayerName());
 
+    QString text = ((MyLabel*)label->getGeometry())->text();
+
     // shift by one as we have 2px border
     painter->save();
-    painter->setPen( lyr.textColor );
-    painter->setFont( lyr.textFont );
     painter->translate( QPointF(outPt.x()+1, outPt.y()-1-lyr.fontBaseline) );
     painter->rotate(-label->getRotation() * 180 / M_PI );
-    painter->drawText(0,0, ((MyLabel*)label->getGeometry())->text());
+    painter->setFont( lyr.textFont );
+
+    if (lyr.bufferSize != 0)
+      drawLabelBuffer(painter, text, lyr.bufferSize, lyr.bufferColor);
+
+    painter->setPen( lyr.textColor );
+    painter->drawText(0,0, text);
     painter->restore();
 
     delete label;
@@ -419,3 +437,13 @@
 {
   return mSearch;
 }
+
+void PalLabeling::drawLabelBuffer(QPainter* p, QString text, int size, QColor color)
+{
+  p->save();
+  p->setPen(color);
+  for (int x = -size; x <= size; x++)
+    for (int y = -size; y <= size; y++)
+      p->drawText(x,y, text);
+  p->restore();
+}

Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h	2009-07-04 22:49:32 UTC (rev 11024)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h	2009-07-05 00:01:19 UTC (rev 11025)
@@ -49,6 +49,9 @@
   int priority; // 0 = low, 10 = high
   bool obstacle; // whether it's an obstacle
   double dist; // distance from the feature (in pixels)
+  int scaleMin, scaleMax; // disabled if both are zero
+  int bufferSize;
+  QColor bufferColor;
 
   // called from register feature hook
   void calculateLabelSize(QString text, double& labelX, double& labelY);
@@ -107,6 +110,9 @@
     //! hook called when drawing for every feature in a layer
     static void registerFeatureHook(QgsFeature& f, void* layerContext);
 
+
+    static void drawLabelBuffer(QPainter* p, QString text, int size, QColor color);
+
 protected:
 
     void initPal();



More information about the QGIS-commit mailing list