-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start of GUI for rule-based labeling
This code has been funded by Tuscany Region (Italy) - SITA (CIG: 63526840AE) and commissioned to Gis3W s.a.s.
- Loading branch information
Showing
10 changed files
with
244 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include "qgslabelingwidget.h" | ||
|
||
#include "qgslabelengineconfigdialog.h" | ||
#include "qgslabelinggui.h" | ||
#include "qgsrulebasedlabelingwidget.h" | ||
#include "qgsvectorlayerlabeling.h" | ||
|
||
QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent ) | ||
: QWidget( parent ) | ||
, mLayer( layer ) | ||
, mCanvas( canvas ) | ||
{ | ||
setupUi( this ); | ||
|
||
connect( mEngineSettingsButton, SIGNAL( clicked() ), this, SLOT( showEngineConfigDialog() ) ); | ||
|
||
mWidgetSimple = new QgsLabelingGui( layer, canvas, this ); | ||
mWidgetRules = new QgsRuleBasedLabelingWidget( layer, canvas, this ); | ||
mStackedWidget->addWidget( mWidgetSimple ); | ||
mStackedWidget->addWidget( mWidgetRules ); | ||
|
||
mStackedWidget->setCurrentIndex( 0 ); | ||
} | ||
|
||
void QgsLabelingWidget::init() | ||
{ | ||
if ( !mLayer->labeling() || mLayer->labeling()->type() == "simple" ) | ||
{ | ||
mStackedWidget->setCurrentIndex( 0 ); | ||
|
||
// load labeling settings from layer | ||
QgsPalLayerSettings lyr; | ||
lyr.readFromLayer( mLayer ); | ||
|
||
// enable/disable main options based upon whether layer is being labeled | ||
if ( !lyr.enabled ) | ||
{ | ||
mLabelModeComboBox->setCurrentIndex( 0 ); | ||
} | ||
else | ||
{ | ||
mLabelModeComboBox->setCurrentIndex( lyr.drawLabels ? 1 : 2 ); | ||
} | ||
|
||
mWidgetSimple->init(); | ||
} | ||
else if ( mLayer->labeling() && mLayer->labeling()->type() == "rule-based" ) | ||
{ | ||
mStackedWidget->setCurrentIndex( 1 ); | ||
mWidgetRules->init(); | ||
} | ||
} | ||
|
||
void QgsLabelingWidget::writeSettingsToLayer() | ||
{ | ||
if ( mLabelModeComboBox->currentIndex() < 3 ) | ||
{ | ||
mWidgetSimple->writeSettingsToLayer(); | ||
} | ||
else | ||
{ | ||
mWidgetRules->writeSettingsToLayer(); | ||
} | ||
} | ||
|
||
|
||
void QgsLabelingWidget::on_mLabelModeComboBox_currentIndexChanged( int index ) | ||
{ | ||
if ( index < 3 ) | ||
{ | ||
mStackedWidget->setCurrentIndex( 0 ); | ||
mWidgetSimple->setLabelMode( ( QgsLabelingGui::LabelMode ) index ); | ||
} | ||
else | ||
{ | ||
// rule-based labeling | ||
mStackedWidget->setCurrentIndex( 1 ); | ||
} | ||
} | ||
|
||
void QgsLabelingWidget::showEngineConfigDialog() | ||
{ | ||
QgsLabelEngineConfigDialog dlg( this ); | ||
dlg.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef QGSLABELINGWIDGET_H | ||
#define QGSLABELINGWIDGET_H | ||
|
||
#include <QWidget> | ||
|
||
#include <ui_qgslabelingwidget.h> | ||
|
||
class QgsLabelingGui; | ||
class QgsMapCanvas; | ||
class QgsRuleBasedLabelingWidget; | ||
class QgsVectorLayer; | ||
|
||
/** | ||
* Master widget for configuration of labeling of a vector layer | ||
*/ | ||
class QgsLabelingWidget : public QWidget, private Ui::QgsLabelingWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent = 0 ); | ||
|
||
//! load config from layer | ||
void init(); | ||
//! save config to layer | ||
void writeSettingsToLayer(); | ||
|
||
signals: | ||
|
||
protected slots: | ||
void on_mLabelModeComboBox_currentIndexChanged( int index ); | ||
void showEngineConfigDialog(); | ||
|
||
protected: | ||
QgsVectorLayer* mLayer; | ||
QgsMapCanvas* mCanvas; | ||
|
||
QgsLabelingGui* mWidgetSimple; | ||
QgsRuleBasedLabelingWidget* mWidgetRules; | ||
}; | ||
|
||
#endif // QGSLABELINGWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "qgsrulebasedlabelingwidget.h" | ||
|
||
QgsRuleBasedLabelingWidget::QgsRuleBasedLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent ) | ||
: QWidget( parent ) | ||
, mLayer( layer ) | ||
, mCanvas( canvas ) | ||
{ | ||
setupUi( this ); | ||
} | ||
|
||
void QgsRuleBasedLabelingWidget::init() | ||
{ | ||
// TODO | ||
} | ||
|
||
void QgsRuleBasedLabelingWidget::writeSettingsToLayer() | ||
{ | ||
// TODO | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef QGSRULEBASEDLABELINGWIDGET_H | ||
#define QGSRULEBASEDLABELINGWIDGET_H | ||
|
||
#include <QWidget> | ||
|
||
#include <ui_qgsrulebasedlabelingwidget.h> | ||
|
||
class QgsMapCanvas; | ||
class QgsVectorLayer; | ||
|
||
class QgsRuleBasedLabelingWidget : public QWidget, private Ui::QgsRuleBasedLabelingWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsRuleBasedLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent = 0 ); | ||
|
||
//! load config from layer | ||
void init(); | ||
//! save config to layer | ||
void writeSettingsToLayer(); | ||
|
||
signals: | ||
|
||
public slots: | ||
|
||
protected: | ||
QgsVectorLayer* mLayer; | ||
QgsMapCanvas* mCanvas; | ||
}; | ||
|
||
#endif // QGSRULEBASEDLABELINGWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.