[QGIS Commit] r10888 -
branches/symbology-ng-branch/src/plugins/labeling
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Jun 5 18:55:30 EDT 2009
Author: wonder
Date: 2009-06-05 18:55:30 -0400 (Fri, 05 Jun 2009)
New Revision: 10888
Added:
branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp
branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.h
branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui
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 engine configuration dialog. It's possible to set number of candidate labels that will be generated for every feature and the search method.
Modified: branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt 2009-06-05 20:08:15 UTC (rev 10887)
+++ branches/symbology-ng-branch/src/plugins/labeling/CMakeLists.txt 2009-06-05 22:55:30 UTC (rev 10888)
@@ -6,13 +6,15 @@
labeling.cpp
labelinggui.cpp
pallabeling.cpp
+ engineconfigdialog.cpp
)
-SET (labeling_UIS labelingguibase.ui)
+SET (labeling_UIS labelingguibase.ui engineconfigdialog.ui)
SET (labeling_MOC_HDRS
labeling.h
labelinggui.h
+ engineconfigdialog.h
)
SET (labeling_RCCS labeling.qrc)
Added: branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp (rev 0)
+++ branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.cpp 2009-06-05 22:55:30 UTC (rev 10888)
@@ -0,0 +1,34 @@
+#include "engineconfigdialog.h"
+
+#include "pallabeling.h"
+
+EngineConfigDialog::EngineConfigDialog(PalLabeling* lbl, QWidget* parent)
+ : QDialog(parent), mLBL(lbl)
+{
+ setupUi(this);
+
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(onOK()) );
+
+ // search method
+ cboSearchMethod->setCurrentIndex( mLBL->searchMethod() );
+
+ // candidate numbers
+ int candPoint, candLine, candPolygon;
+ mLBL->numCandidatePositions(candPoint, candLine, candPolygon);
+ spinCandPoint->setValue(candPoint);
+ spinCandLine->setValue(candLine);
+ spinCandPolygon->setValue(candPolygon);
+}
+
+
+void EngineConfigDialog::onOK()
+{
+ // save
+ mLBL->setSearchMethod( (PalLabeling::Search) cboSearchMethod->currentIndex() );
+
+ mLBL->setNumCandidatePositions(spinCandPoint->value(),
+ spinCandLine->value(),
+ spinCandPolygon->value());
+
+ accept();
+}
Added: branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.h (rev 0)
+++ branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.h 2009-06-05 22:55:30 UTC (rev 10888)
@@ -0,0 +1,23 @@
+#ifndef ENGINECONFIGDIALOG_H
+#define ENGINECONFIGDIALOG_H
+
+#include <QDialog>
+
+#include "ui_engineconfigdialog.h"
+
+class PalLabeling;
+
+class EngineConfigDialog : public QDialog, private Ui::EngineConfigDialog
+{
+ Q_OBJECT
+public:
+ EngineConfigDialog(PalLabeling* lbl, QWidget* parent = NULL);
+
+public slots:
+ void onOK();
+
+protected:
+ PalLabeling* mLBL;
+};
+
+#endif // ENGINECONFIGDIALOG_H
Added: branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui (rev 0)
+++ branches/symbology-ng-branch/src/plugins/labeling/engineconfigdialog.ui 2009-06-05 22:55:30 UTC (rev 10888)
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EngineConfigDialog</class>
+ <widget class="QDialog" name="EngineConfigDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>286</width>
+ <height>250</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Search method</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cboSearchMethod">
+ <item>
+ <property name="text">
+ <string>Chain (fastest)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Popmusic Tabu</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Popmusic Chain</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Popmusic Tabu Chain</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <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>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Number of candidates</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Point</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="spinCandPoint">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Line</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="spinCandLine">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Polygon</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="spinCandPolygon">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Preferred</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </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>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>EngineConfigDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Modified: branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp 2009-06-05 20:08:15 UTC (rev 10887)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelinggui.cpp 2009-06-05 22:55:30 UTC (rev 10888)
@@ -22,6 +22,7 @@
#include <qgsmaplayerregistry.h>
#include "pallabeling.h"
+#include "engineconfigdialog.h"
#include <QColorDialog>
#include <QFontDialog>
@@ -36,6 +37,7 @@
connect(btnTextColor, SIGNAL(clicked()), this, SLOT(changeTextColor()) );
connect(btnChangeFont, SIGNAL(clicked()), this, SLOT(changeTextFont()) );
+ connect(btnEngineSettings, SIGNAL(clicked()), this, SLOT(showEngineConfigDialog()) );
populatePlacementMethods();
populateFieldNames();
@@ -142,3 +144,9 @@
palette.setBrush(QPalette::Inactive, QPalette::WindowText, brush);
lblFontPreview->setPalette(palette);
}
+
+void LabelingGui::showEngineConfigDialog()
+{
+ EngineConfigDialog dlg(mLBL, this);
+ dlg.exec();
+}
Modified: branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h 2009-06-05 20:08:15 UTC (rev 10887)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelinggui.h 2009-06-05 22:55:30 UTC (rev 10888)
@@ -40,6 +40,7 @@
public slots:
void changeTextColor();
void changeTextFont();
+ void showEngineConfigDialog();
protected:
void populatePlacementMethods();
Modified: branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui 2009-06-05 20:08:15 UTC (rev 10887)
+++ branches/symbology-ng-branch/src/plugins/labeling/labelingguibase.ui 2009-06-05 22:55:30 UTC (rev 10888)
@@ -247,7 +247,7 @@
<item>
<widget class="QPushButton" name="btnEngineSettings">
<property name="enabled">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="text">
<string>Engine settings</string>
Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp 2009-06-05 20:08:15 UTC (rev 10887)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.cpp 2009-06-05 22:55:30 UTC (rev 10888)
@@ -66,6 +66,19 @@
PalLabeling::PalLabeling(QgsMapCanvas* mapCanvas)
: mMapCanvas(mapCanvas)
{
+ // find out engine defaults
+ Pal p;
+ mCandPoint = p.getPointP();
+ mCandLine = p.getLineP();
+ mCandPolygon = p.getPolyP();
+
+ switch (p.getSearch())
+ {
+ case CHAIN: mSearch = Chain; break;
+ case POPMUSIC_TABU: mSearch = Popmusic_Tabu; break;
+ case POPMUSIC_CHAIN: mSearch = Popmusic_Chain; break;
+ case POPMUSIC_TABU_CHAIN: mSearch = Popmusic_Tabu_Chain; break;
+ }
}
void PalLabeling::addLayer(LayerSettings layerSettings)
@@ -162,6 +175,22 @@
void PalLabeling::doLabeling(QPainter* painter)
{
Pal p;
+
+ SearchMethod s;
+ switch (mSearch)
+ {
+ case Chain: s = CHAIN; break;
+ case Popmusic_Tabu: s = POPMUSIC_TABU; break;
+ case Popmusic_Chain: s = POPMUSIC_CHAIN; break;
+ case Popmusic_Tabu_Chain: s = POPMUSIC_TABU_CHAIN; break;
+ }
+ p.setSearch(s);
+
+ // set number of candidates generated per feature
+ p.setPointP(mCandPoint);
+ p.setLineP(mCandLine);
+ p.setPolyP(mCandPolygon);
+
//p.setSearch(POPMUSIC_TABU_CHAIN);// this is really slow! // default is CHAIN (worst, fastest)
// TODO: API 0.2 - no mention about changing map units!
// pal map units = METER by default ... change setMapUnit
@@ -234,3 +263,27 @@
delete labels;
}
+
+void PalLabeling::numCandidatePositions(int& candPoint, int& candLine, int& candPolygon)
+{
+ candPoint = mCandPoint;
+ candLine = mCandLine;
+ candPolygon = mCandPolygon;
+}
+
+void PalLabeling::setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
+{
+ mCandPoint = candPoint;
+ mCandLine = candLine;
+ mCandPolygon = candPolygon;
+}
+
+void PalLabeling::setSearchMethod(PalLabeling::Search s)
+{
+ mSearch = s;
+}
+
+PalLabeling::Search PalLabeling::searchMethod() const
+{
+ return mSearch;
+}
Modified: branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h
===================================================================
--- branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h 2009-06-05 20:08:15 UTC (rev 10887)
+++ branches/symbology-ng-branch/src/plugins/labeling/pallabeling.h 2009-06-05 22:55:30 UTC (rev 10888)
@@ -46,12 +46,22 @@
LayerSettings layer(QString layerId);
+ void numCandidatePositions(int& candPoint, int& candLine, int& candPolygon);
+ void setNumCandidatePositions(int candPoint, int candLine, int candPolygon);
+
+ enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain };
+
+ void setSearchMethod(Search s);
+ Search searchMethod() const;
+
protected:
int prepareLayer(pal::Pal& pal, const LayerSettings& lyr);
protected:
QList<LayerSettings> mLayers;
QgsMapCanvas* mMapCanvas;
+ int mCandPoint, mCandLine, mCandPolygon;
+ Search mSearch;
};
#endif // PALLABELING_H
More information about the QGIS-commit
mailing list