QGIS API Documentation
4.3.0-Master (0ad0cdb9438)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
pal
problem.h
Go to the documentation of this file.
1
/*
2
* libpal - Automated Placement of Labels Library
3
*
4
* Copyright (C) 2008 Maxence Laurent, MIS-TIC, HEIG-VD
5
* University of Applied Sciences, Western Switzerland
6
* http://www.hes-so.ch
7
*
8
* Contact:
9
* maxence.laurent <at> heig-vd <dot> ch
10
* or
11
* eric.taillard <at> heig-vd <dot> ch
12
*
13
* This file is part of libpal.
14
*
15
* libpal is free software: you can redistribute it and/or modify
16
* it under the terms of the GNU General Public License as published by
17
* the Free Software Foundation, either version 3 of the License, or
18
* (at your option) any later version.
19
*
20
* libpal is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU General Public License for more details.
24
*
25
* You should have received a copy of the GNU General Public License
26
* along with libpal. If not, see <http://www.gnu.org/licenses/>.
27
*
28
*/
29
30
#ifndef PAL_PROBLEM_H
31
#define PAL_PROBLEM_H
32
33
34
#include <list>
35
#include <memory>
36
#include <vector>
37
38
#include "
palrtree.h
"
39
#include "qgis_core.h"
40
#include "
qgsrendercontext.h
"
41
42
#include <QList>
43
44
#define SIP_NO_FILE
45
46
namespace
pal
47
{
48
49
class
LabelPosition;
50
class
Label;
51
class
PriorityQueue;
52
59
60
struct
Chain
61
{
62
int
degree
;
63
double
delta
;
64
std::vector< int >
feat
;
65
std::vector< int >
label
;
66
};
67
74
class
CORE_EXPORT
Problem
75
{
76
friend
class
Pal
;
77
78
public
:
84
Problem
(
const
QgsRectangle
&extent );
85
86
//Problem(char *lorena_file, bool displayAll);
87
88
~Problem
();
89
90
Problem
(
const
Problem
&other ) =
delete
;
91
Problem
&
operator=
(
const
Problem
&other ) =
delete
;
92
97
void
addCandidatePosition
( std::unique_ptr< LabelPosition > position );
98
102
std::size_t
featureCount
()
const
{
return
mFeatureCount; }
103
107
int
featureCandidateCount
(
int
feature )
const
{
return
mCandidateCountForFeature[feature]; }
108
112
LabelPosition
*
featureCandidate
(
int
feature,
int
candidate )
const
{
return
mLabelPositions[mFirstCandidateIndexForFeature[feature] + candidate].get(); }
113
117
void
reduce();
118
122
void
chainSearch(
QgsRenderContext
&context );
123
136
QList<LabelPosition *> getSolution(
bool
returnInactive, QList<LabelPosition *> *unlabeled =
nullptr
);
137
138
/* useful only for postscript post-conversion*/
139
//void toFile(char *label_file);
140
141
void
init_sol_falp();
142
149
std::vector< std::unique_ptr< LabelPosition > > *
positionsWithNoCandidates
() {
return
&mPositionsWithNoCandidates; }
150
154
PalRtree< LabelPosition >
&
allCandidatesIndex
() {
return
mAllCandidatesIndex; }
155
156
private
:
160
bool
candidatesAreConflicting(
const
LabelPosition
*lp1,
const
LabelPosition
*lp2 )
const
;
161
165
int
mLayerCount = 0;
166
170
QStringList labelledLayersName;
171
175
int
mTotalCandidates = 0;
176
180
int
mAllNblp = 0;
181
185
std::size_t mFeatureCount = 0;
186
190
bool
mDisplayAll =
false
;
191
195
double
mMapExtentBounds[4] = { 0, 0, 0, 0 };
196
197
std::vector< std::unique_ptr< LabelPosition > > mLabelPositions;
198
199
PalRtree<LabelPosition>
mAllCandidatesIndex;
200
PalRtree<LabelPosition>
mActiveCandidatesIndex;
201
202
std::vector< std::unique_ptr< LabelPosition > > mPositionsWithNoCandidates;
203
205
std::vector< int > mFirstCandidateIndexForFeature;
207
std::vector< int > mCandidateCountForFeature;
209
std::vector< double > mUnlabeledCostForFeature;
210
211
class
Sol
212
{
213
public
:
215
std::vector< int > activeLabelIds;
216
217
void
init( std::size_t featureCount ) { activeLabelIds.resize( featureCount, -1 ); }
218
};
219
220
Sol mSol;
221
double
mNbOverlap = 0.0;
222
223
// seed is actually a feature ID, maybe it should be renamed?
224
std::unique_ptr< Chain > chain(
int
seed );
225
226
Pal *pal =
nullptr
;
227
228
void
solution_cost();
229
void
ignoreLabel(
const
LabelPosition *lp, pal::PriorityQueue &list, PalRtree<LabelPosition> &candidatesIndex );
230
};
231
232
}
//namespace pal
233
234
#endif
PalRtree
A rtree spatial index for use in the pal labeling engine.
Definition
palrtree.h:37
QgsRectangle
A rectangle specified with double values.
Definition
qgsrectangle.h:47
QgsRenderContext
Contains information about the context of a rendering operation.
Definition
qgsrendercontext.h:63
pal::LabelPosition
LabelPosition is a candidate feature label position.
Definition
labelposition.h:57
pal::Problem::Pal
friend class Pal
Definition
problem.h:76
pal::Problem::addCandidatePosition
void addCandidatePosition(std::unique_ptr< LabelPosition > position)
Adds a candidate label position to the problem.
Definition
problem.cpp:51
pal::Problem::featureCandidate
LabelPosition * featureCandidate(int feature, int candidate) const
Returns the candidate corresponding to the specified feature and candidate index.
Definition
problem.h:112
pal::Problem::~Problem
~Problem()
pal::Problem::featureCandidateCount
int featureCandidateCount(int feature) const
Returns the number of candidates generated for the feature at the specified index.
Definition
problem.h:107
pal::Problem::Problem
Problem(const QgsRectangle &extent)
Constructor for Problem.
Definition
problem.cpp:46
pal::Problem::featureCount
std::size_t featureCount() const
Returns the total number of features considered during the labeling problem.
Definition
problem.h:102
pal::Problem::allCandidatesIndex
PalRtree< LabelPosition > & allCandidatesIndex()
Returns the index containing all label candidates.
Definition
problem.h:154
pal::Problem::operator=
Problem & operator=(const Problem &other)=delete
pal::Problem::Problem
Problem(const Problem &other)=delete
pal::Problem::positionsWithNoCandidates
std::vector< std::unique_ptr< LabelPosition > > * positionsWithNoCandidates()
Returns a reference to the list of label positions which correspond to features with no candidates.
Definition
problem.h:149
Sol
Chain solution parameters.
pal
Definition
qgsdiagramrenderer.h:51
palrtree.h
qgsrendercontext.h
pal::Chain
Definition
problem.h:61
pal::Chain::feat
std::vector< int > feat
Definition
problem.h:64
pal::Chain::delta
double delta
Definition
problem.h:63
pal::Chain::label
std::vector< int > label
Definition
problem.h:65
pal::Chain::degree
int degree
Definition
problem.h:62
Generated on
for QGIS API Documentation by
1.17.0