-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgslabelengineconfigdialog.cpp
86 lines (69 loc) · 3.35 KB
/
qgslabelengineconfigdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/***************************************************************************
qgslabelengineconfigdialog.cpp
---------------------
begin : May 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslabelengineconfigdialog.h"
#include "qgspallabeling.h"
#include "qgslabelingengine.h"
#include "qgsproject.h"
#include <pal/pal.h>
#include <QPushButton>
QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QWidget *parent )
: QDialog( parent )
{
setupUi( this );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( onOK() ) );
connect( buttonBox->button( QDialogButtonBox::RestoreDefaults ), SIGNAL( clicked() ),
this, SLOT( setDefaults() ) );
QgsLabelingEngine engine;
engine.readSettingsFromProject( QgsProject::instance() );
// search method
cboSearchMethod->setCurrentIndex( engine.searchMethod() );
// candidate numbers
int candPoint, candLine, candPolygon;
engine.numCandidatePositions( candPoint, candLine, candPolygon );
spinCandPoint->setValue( candPoint );
spinCandLine->setValue( candLine );
spinCandPolygon->setValue( candPolygon );
chkShowCandidates->setChecked( engine.testFlag( QgsLabelingEngine::DrawCandidates ) );
chkShowAllLabels->setChecked( engine.testFlag( QgsLabelingEngine::UseAllLabels ) );
chkShowPartialsLabels->setChecked( engine.testFlag( QgsLabelingEngine::UsePartialCandidates ) );
mDrawOutlinesChkBox->setChecked( engine.testFlag( QgsLabelingEngine::RenderOutlineLabels ) );
}
void QgsLabelEngineConfigDialog::onOK()
{
QgsLabelingEngine engine;
// save
engine.setSearchMethod( ( QgsPalLabeling::Search ) cboSearchMethod->currentIndex() );
engine.setNumCandidatePositions( spinCandPoint->value(),
spinCandLine->value(),
spinCandPolygon->value() );
engine.setFlag( QgsLabelingEngine::DrawCandidates, chkShowCandidates->isChecked() );
engine.setFlag( QgsLabelingEngine::UseAllLabels, chkShowAllLabels->isChecked() );
engine.setFlag( QgsLabelingEngine::UsePartialCandidates, chkShowPartialsLabels->isChecked() );
engine.setFlag( QgsLabelingEngine::RenderOutlineLabels, mDrawOutlinesChkBox->isChecked() );
engine.writeSettingsToProject( QgsProject::instance() );
accept();
}
void QgsLabelEngineConfigDialog::setDefaults()
{
pal::Pal p;
cboSearchMethod->setCurrentIndex( ( int )p.getSearch() );
spinCandPoint->setValue( p.getPointP() );
spinCandLine->setValue( p.getLineP() );
spinCandPolygon->setValue( p.getPolyP() );
chkShowCandidates->setChecked( false );
chkShowAllLabels->setChecked( false );
chkShowPartialsLabels->setChecked( p.getShowPartial() );
mDrawOutlinesChkBox->setChecked( true );
}