QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 <QList>
34 #include <iostream>
35 #include <ctime>
36 #include <geos_c.h>
37 #include <QMutex>
38 
39 // TODO ${MAJOR} ${MINOR} etc instead of 0.2
40 
49 namespace pal
50 {
52  GEOSContextHandle_t geosContext();
53 
54  template <class Type> class LinkedList;
55 
56  class Layer;
57  class LabelPosition;
58  class PalStat;
59  class Problem;
60  class PointSet;
61 
63  enum _Units
64  {
65  PIXEL = 0,
67  FOOT,
69  };
70 
72  typedef enum _Units Units;
73 
76  {
77  CHAIN = 0,
81  FALP = 4
82  };
83 
86 
92  {
93  P_POINT = 0,
99  };
100 
102  typedef enum _arrangement Arrangement;
103 
106  {
111  };
112 
121  class CORE_EXPORT Pal
122  {
123  friend class Problem;
124  friend class FeaturePart;
125  friend class Layer;
126 
127  public:
128 
132  Pal();
133 
137  ~Pal();
138 
157  Layer * addLayer( const char *lyrName, double min_scale, double max_scale, Arrangement arrangement, Units label_unit, double defaultPriority, bool obstacle, bool active, bool toLabel, bool displayAll = false );
158 
168  Layer *getLayer( const char *lyrName );
169 
175  QList<Layer*> *getLayers();
176 
182  void removeLayer( Layer *layer );
183 
195  std::list<LabelPosition*> *labeller( double scale, double bbox[4], PalStat **stats, bool displayAll );
196 
214  std::list<LabelPosition*> *labeller( int nbLayers,
215  char **layersName,
216  double *layersFactor,
217  double scale, double bbox[4],
218  PalStat **stat,
219  bool displayAll );
220 
221  typedef bool ( *FnIsCancelled )( void* ctx );
222 
224  void registerCancellationCallback( FnIsCancelled fnCancelled, void* context );
225 
227  inline bool isCancelled() { return fnIsCancelled ? fnIsCancelled( fnIsCancelledContext ) : false; }
228 
229  Problem* extractProblem( double scale, double bbox[4] );
230 
231  std::list<LabelPosition*>* solveProblem( Problem* prob, bool displayAll );
232 
238  void setDpi( int dpi );
239 
245  int getDpi();
246 
252  void setShowPartial( bool show );
253 
259  bool getShowPartial();
260 
267  void setPointP( int point_p );
268 
275  void setLineP( int line_p );
276 
283  void setPolyP( int poly_p );
284 
288  int getPointP();
289 
293  int getLineP();
294 
298  int getPolyP();
299 
303  Units getMapUnit();
304 
308  void setMapUnit( Units map_unit );
309 
318  void setSearch( SearchMethod method );
319 
325  SearchMethod getSearch();
326 
327  private:
328  QList<Layer*> *layers;
329 
330  QMutex mMutex;
331 
332  Units map_unit;
333 
337  int point_p;
338 
342  int line_p;
343 
347  int poly_p;
348 
349  SearchMethod searchMethod;
350 
351  /*
352  * POPMUSIC Tuning
353  */
354  int popmusic_r;
355 
356  int tabuMaxIt;
357  int tabuMinIt;
358 
359  int dpi;
360 
361  int ejChainDeg;
362  int tenure;
363  double candListSize;
364 
368  bool showPartial;
369 
371  FnIsCancelled fnIsCancelled;
373  void* fnIsCancelledContext;
374 
389  Problem* extract( int nbLayers, char **layersName, double *layersFactor,
390  double lambda_min, double phi_min,
391  double lambda_max, double phi_max,
392  double scale );
393 
394 
399  void setPopmusicR( int r );
400 
401 
402 
407  void setMinIt( int min_it );
408 
413  void setMaxIt( int max_it );
414 
419  void setTenure( int tenure );
420 
425  void setEjChainDeg( int degree );
426 
431  void setCandListSize( double fact );
432 
433 
438  int getMinIt();
443  int getMaxIt();
444  };
445 } // end namespace pal
446 #endif
foot [ft]
Definition: pal.h:67
A layer of spacial entites.
Definition: layer.h:60
is the best but slowest
Definition: pal.h:78
degree [°]
Definition: pal.h:68
Pal main class.
Definition: pal.h:121
bool isCancelled()
Check whether the job has been cancelled.
Definition: pal.h:227
_arrangement
The way to arrange labels against spatial entities.
Definition: pal.h:91
arranges candidates around a point (centroid for polygon)
Definition: pal.h:93
_Units
Units for label sizes and distlabel.
Definition: pal.h:63
arranges candidates over a point (centroid for polygon)
Definition: pal.h:95
Only for lines, labels along the line.
Definition: pal.h:97
GEOSContextHandle_t geosContext()
Get GEOS context handle to be used in all GEOS library calls with reentrant API.
Definition: pal.cpp:79
Main class to handle feature.
Definition: feature.h:133
pixel [px]
Definition: pal.h:65
LineArrangementFlags
Enumeration line arrangement flags.
Definition: pal.h:105
enum _searchMethod SearchMethod
Typedef for _Units enumeration.
Definition: pal.h:85
is slower and best than TABU, worse and faster than TABU_CHAIN
Definition: pal.h:80
enum _arrangement Arrangement
Typedef for _arrangement enumeration.
Definition: pal.h:102
meter [m]
Definition: pal.h:66
Definition: pal.h:81
_searchMethod
Search method to use.
Definition: pal.h:75
Summury of problem.
Definition: palstat.h:40
Only for polygon, arranges candidates with respect of polygon orientation.
Definition: pal.h:98
Represent a problem.
Definition: problem.h:92
enum _Units Units
Typedef for _Units enumeration.
Definition: pal.h:72
is a little bit better than CHAIN but slower
Definition: pal.h:79
is the worst but fastest method
Definition: pal.h:77