QGIS API Documentation  2.12.0-Lyon
pal.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_H
31 #define _PAL_H
32 
33 #include "qgsgeometry.h"
34 #include <QList>
35 #include <iostream>
36 #include <ctime>
37 #include <QMutex>
38 #include <QStringList>
39 
40 // TODO ${MAJOR} ${MINOR} etc instead of 0.2
41 
43 
52 namespace pal
53 {
55  GEOSContextHandle_t geosContext();
56 
57  class Layer;
58  class LabelPosition;
59  class PalStat;
60  class Problem;
61  class PointSet;
62 
65  {
66  CHAIN = 0,
70  FALP = 4
71  };
72 
78  {
79  P_POINT = 0,
85  };
86 
89  {
94  };
95  Q_DECLARE_FLAGS( LineArrangementFlags, LineArrangementFlag )
96 
98  {
101  };
102 
111  class CORE_EXPORT Pal
112  {
113  friend class Problem;
114  friend class FeaturePart;
115  friend class Layer;
116 
117  public:
118 
122  Pal();
123 
127  ~Pal();
128 
144  Layer* addLayer( QgsAbstractLabelProvider* provider, const QString& layerName, Arrangement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll = false );
145 
151  void removeLayer( Layer *layer );
152 
163  std::list<LabelPosition*> *labeller( double bbox[4], PalStat **stats, bool displayAll );
164 
165  typedef bool ( *FnIsCancelled )( void* ctx );
166 
168  void registerCancellationCallback( FnIsCancelled fnCancelled, void* context );
169 
171  inline bool isCancelled() { return fnIsCancelled ? fnIsCancelled( fnIsCancelledContext ) : false; }
172 
173  Problem* extractProblem( double bbox[4] );
174 
175  std::list<LabelPosition*>* solveProblem( Problem* prob, bool displayAll );
176 
182  void setShowPartial( bool show );
183 
189  bool getShowPartial();
190 
197  void setPointP( int point_p );
198 
205  void setLineP( int line_p );
206 
213  void setPolyP( int poly_p );
214 
218  int getPointP();
219 
223  int getLineP();
224 
228  int getPolyP();
229 
238  void setSearch( SearchMethod method );
239 
245  SearchMethod getSearch();
246 
247  private:
248 
250 
251  QMutex mMutex;
252 
256  int point_p;
257 
261  int line_p;
262 
266  int poly_p;
267 
268  SearchMethod searchMethod;
269 
270  /*
271  * POPMUSIC Tuning
272  */
273  int popmusic_r;
274 
275  int tabuMaxIt;
276  int tabuMinIt;
277 
278  int ejChainDeg;
279  int tenure;
280  double candListSize;
281 
285  bool showPartial;
286 
288  FnIsCancelled fnIsCancelled;
290  void* fnIsCancelledContext;
291 
301  Problem* extract( double lambda_min, double phi_min,
302  double lambda_max, double phi_max );
303 
304 
309  void setPopmusicR( int r );
310 
315  void setMinIt( int min_it );
316 
321  void setMaxIt( int max_it );
322 
327  void setTenure( int tenure );
328 
333  void setEjChainDeg( int degree );
334 
339  void setCandListSize( double fact );
340 
341 
346  int getMinIt();
351  int getMaxIt();
352  };
353 
354 } // end namespace pal
355 
356 Q_DECLARE_OPERATORS_FOR_FLAGS( pal::LineArrangementFlags )
357 
358 #endif
Definition: pal.h:70
arranges candidates around a point (centroid for polygon)
Definition: pal.h:79
A layer of spacial entites.
Definition: layer.h:57
Pal main class.
Definition: pal.h:111
bool isCancelled()
Check whether the job has been cancelled.
Definition: pal.h:171
is slower and best than TABU, worse and faster than TABU_CHAIN
Definition: pal.h:69
Only for polygon, arranges candidates with respect of polygon orientation.
Definition: pal.h:84
is a little bit better than CHAIN but slower
Definition: pal.h:68
is the best but slowest
Definition: pal.h:67
GEOSContextHandle_t geosContext()
Get GEOS context handle to be used in all GEOS library calls with reentrant API.
Definition: pal.cpp:57
Main class to handle feature.
Definition: feature.h:79
The QgsAbstractLabelProvider class is an interface class.
Only for lines, labels along the line.
Definition: pal.h:83
Arrangement
The way to arrange labels against spatial entities.
Definition: pal.h:77
ObstacleType
Definition: pal.h:97
Summury of problem.
Definition: palstat.h:41
Represent a problem.
Definition: problem.h:93
LineArrangementFlag
Enumeration line arrangement flags.
Definition: pal.h:88
SearchMethod
Search method to use.
Definition: pal.h:64
is the worst but fastest method
Definition: pal.h:66
arranges candidates over a point (centroid for polygon)
Definition: pal.h:81