QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 
34 #ifndef _PAL_H
35 #define _PAL_H
36 
37 
38 #include <QList>
39 #include <iostream>
40 #include <ctime>
41 #include <geos_c.h>
42 
43 // TODO ${MAJOR} ${MINOR} etc instead of 0.2
44 
53 namespace pal
54 {
56  GEOSContextHandle_t geosContext();
57 
58  template <class Type> class LinkedList;
59 
60  class Layer;
61  class LabelPosition;
62  class PalStat;
63  class Problem;
64  class PointSet;
65  class SimpleMutex;
66 
68  enum _Units
69  {
70  PIXEL = 0,
72  FOOT,
74  };
75 
77  typedef enum _Units Units;
78 
81  {
82  CHAIN = 0,
86  FALP = 4
87  };
88 
91 
97  {
98  P_POINT = 0,
104  };
105 
107  typedef enum _arrangement Arrangement;
108 
111  {
116  };
117 
126  class CORE_EXPORT Pal
127  {
128  friend class Problem;
129  friend class FeaturePart;
130  friend class Layer;
131  private:
132  QList<Layer*> *layers;
133 
134  SimpleMutex *lyrsMutex;
135 
136  Units map_unit;
137 
141  int point_p;
142 
146  int line_p;
147 
151  int poly_p;
152 
153  SearchMethod searchMethod;
154 
155  /*
156  * POPMUSIC Tuning
157  */
158  int popmusic_r;
159 
160  int tabuMaxIt;
161  int tabuMinIt;
162 
163  int dpi;
164 
165  int ejChainDeg;
166  int tenure;
167  double candListSize;
168 
172  bool showPartial;
173 
174 
175  typedef bool ( *FnIsCancelled )( void* ctx );
177  FnIsCancelled fnIsCancelled;
179  void* fnIsCancelledContext;
180 
196  Problem* extract( int nbLayers, char **layersName, double *layersFactor,
197  double lambda_min, double phi_min,
198  double lambda_max, double phi_max,
199  double scale, std::ofstream *svgmap );
200 
201 
206  void setPopmusicR( int r );
207 
208 
209 
214  void setMinIt( int min_it );
215 
220  void setMaxIt( int max_it );
221 
226  void setTenure( int tenure );
227 
232  void setEjChainDeg( int degree );
233 
238  void setCandListSize( double fact );
239 
240 
245  int getMinIt();
250  int getMaxIt();
251 
252 
253  public:
254 
258  Pal();
259 
263  ~Pal();
264 
283  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 );
284 
294  Layer *getLayer( const char *lyrName );
295 
301  QList<Layer*> *getLayers();
302 
308  void removeLayer( Layer *layer );
309 
321  std::list<LabelPosition*> *labeller( double scale, double bbox[4], PalStat **stats, bool displayAll );
322 
323 
341  std::list<LabelPosition*> *labeller( int nbLayers,
342  char **layersName,
343  double *layersFactor,
344  double scale, double bbox[4],
345  PalStat **stat,
346  bool displayAll );
347 
349  void registerCancellationCallback( FnIsCancelled fnCancelled, void* context );
350 
352  inline bool isCancelled() { return fnIsCancelled ? fnIsCancelled( fnIsCancelledContext ) : false; }
353 
354  Problem* extractProblem( double scale, double bbox[4] );
355 
356  std::list<LabelPosition*>* solveProblem( Problem* prob, bool displayAll );
357 
363  void setDpi( int dpi );
364 
370  int getDpi();
371 
377  void setShowPartial( bool show );
378 
384  bool getShowPartial();
385 
392  void setPointP( int point_p );
393 
400  void setLineP( int line_p );
401 
408  void setPolyP( int poly_p );
409 
413  int getPointP();
414 
418  int getLineP();
419 
423  int getPolyP();
424 
428  Units getMapUnit();
429 
433  void setMapUnit( Units map_unit );
434 
443  void setSearch( SearchMethod method );
444 
450  SearchMethod getSearch();
451  };
452 } // end namespace pal
453 #endif
foot [ft]
Definition: pal.h:72
A layer of spacial entites.
Definition: layer.h:65
is the best but slowest
Definition: pal.h:83
degree [°]
Definition: pal.h:73
Pal main class.
Definition: pal.h:126
bool isCancelled()
Check whether the job has been cancelled.
Definition: pal.h:352
_arrangement
The way to arrange labels against spatial entities.
Definition: pal.h:96
arranges candidates around a point (centroid for polygon)
Definition: pal.h:98
_Units
Units for label sizes and distlabel.
Definition: pal.h:68
arranges candidates over a point (centroid for polygon)
Definition: pal.h:100
Only for lines, labels along the line.
Definition: pal.h:102
GEOSContextHandle_t geosContext()
Get GEOS context handle to be used in all GEOS library calls with reentrant API.
Definition: pal.cpp:87
Main class to handle feature.
Definition: feature.h:138
pixel [px]
Definition: pal.h:70
LineArrangementFlags
enumeration line arrangement flags.
Definition: pal.h:110
enum _searchMethod SearchMethod
Typedef for _Units enumeration.
Definition: pal.h:90
is slower and best than TABU, worse and faster than TABU_CHAIN
Definition: pal.h:85
enum _arrangement Arrangement
typedef for _arrangement enumeration
Definition: pal.h:107
meter [m]
Definition: pal.h:71
Definition: pal.h:86
_searchMethod
Search method to use.
Definition: pal.h:80
Summury of problem.
Definition: palstat.h:44
Only for polygon, arranges candidates with respect of polygon orientation.
Definition: pal.h:103
Represent a problem.
Definition: problem.h:96
enum _Units Units
Typedef for _Units enumeration.
Definition: pal.h:77
is a little bit better than CHAIN but slower
Definition: pal.h:84
is the worst but fastest method
Definition: pal.h:82