QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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