[QGIS Commit] r11180 - in branches/symbology-ng-branch/src: core/pal plugins/labeling

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jul 26 11:57:32 EDT 2009


Author: wonder
Date: 2009-07-26 11:57:31 -0400 (Sun, 26 Jul 2009)
New Revision: 11180

Modified:
   branches/symbology-ng-branch/src/core/pal/pal.cpp
   branches/symbology-ng-branch/src/core/pal/pal.h
   branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp
   branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui
   branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
   branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
Log:
Added an option to show also colliding labels (in engine configuration)


Modified: branches/symbology-ng-branch/src/core/pal/pal.cpp
===================================================================
--- branches/symbology-ng-branch/src/core/pal/pal.cpp	2009-07-26 11:04:17 UTC (rev 11179)
+++ branches/symbology-ng-branch/src/core/pal/pal.cpp	2009-07-26 15:57:31 UTC (rev 11180)
@@ -956,7 +956,7 @@
     return prob;
   }
 
-  std::list<LabelPosition*>* Pal::solveProblem(Problem* prob)
+  std::list<LabelPosition*>* Pal::solveProblem(Problem* prob, bool displayAll )
   {
     if (prob == NULL)
       return new std::list<LabelPosition*>();
@@ -970,7 +970,7 @@
     else
       prob->popmusic();
 
-    return prob->getSolution( false );
+    return prob->getSolution( displayAll );
   }
 
 

Modified: branches/symbology-ng-branch/src/core/pal/pal.h
===================================================================
--- branches/symbology-ng-branch/src/core/pal/pal.h	2009-07-26 11:04:17 UTC (rev 11179)
+++ branches/symbology-ng-branch/src/core/pal/pal.h	2009-07-26 15:57:31 UTC (rev 11180)
@@ -340,7 +340,7 @@
 
       Problem* extractProblem(double scale, double bbox[4]);
 
-      std::list<LabelPosition*>* solveProblem(Problem* prob);
+      std::list<LabelPosition*>* solveProblem(Problem* prob, bool displayAll);
 
       /**
        * \brief Set map resolution

Modified: branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp	2009-07-26 11:04:17 UTC (rev 11179)
+++ branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp	2009-07-26 15:57:31 UTC (rev 11180)
@@ -20,6 +20,8 @@
   spinCandPolygon->setValue(candPolygon);
 
   chkShowCandidates->setChecked( mLBL->isShowingCandidates() );
+
+  chkShowAllLabels->setChecked( mLBL->isShowingAllLabels() );
 }
 
 
@@ -34,5 +36,7 @@
 
   mLBL->setShowingCandidates( chkShowCandidates->isChecked() );
 
+  mLBL->setShowingAllLabels( chkShowAllLabels->isChecked() );
+
   accept();
 }

Modified: branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui	2009-07-26 11:04:17 UTC (rev 11179)
+++ branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui	2009-07-26 15:57:31 UTC (rev 11180)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>286</width>
-    <height>250</height>
+    <width>316</width>
+    <height>271</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -173,6 +173,13 @@
     </spacer>
    </item>
    <item>
+    <widget class="QCheckBox" name="chkShowAllLabels">
+     <property name="text">
+      <string>Show all labels (i.e. including colliding labels)</string>
+     </property>
+    </widget>
+   </item>
+   <item>
     <widget class="QCheckBox" name="chkShowCandidates">
      <property name="text">
       <string>Show label candidates (for debugging)</string>

Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp	2009-07-26 11:04:17 UTC (rev 11179)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp	2009-07-26 15:57:31 UTC (rev 11180)
@@ -184,6 +184,7 @@
   }
 
   mShowingCandidates = FALSE;
+  mShowingAllLabels = FALSE;
 
   initPal();
 }
@@ -380,7 +381,7 @@
   }
 
   // find the solution
-  labels = mPal->solveProblem( problem );
+  labels = mPal->solveProblem( problem, mShowingAllLabels );
 
   std::cout << "LABELING work:   " << t.elapsed() << "ms  ... labels# " << labels->size() << std::endl;
   t.restart();

Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h	2009-07-26 11:04:17 UTC (rev 11179)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h	2009-07-26 15:57:31 UTC (rev 11180)
@@ -116,6 +116,9 @@
     void setShowingCandidates(bool showing) { mShowingCandidates = showing; }
     const QList<LabelCandidate>& candidates() { return mCandidates; }
 
+    bool isShowingAllLabels() const { return mShowingAllLabels; }
+    void setShowingAllLabels(bool showing) { mShowingAllLabels = showing; }
+
     //! hook called when drawing layer before issuing select()
     static int prepareLayerHook(void* context, void* layerContext, int& attrIndex);
     //! hook called when drawing for every feature in a layer
@@ -143,6 +146,8 @@
     // list of candidates from last labeling
     QList<LabelCandidate> mCandidates;
     bool mShowingCandidates;
+
+    bool mShowingAllLabels; // whether to avoid collisions or not
 };
 
 #endif // PALLABELING_H



More information about the QGIS-commit mailing list