QGIS API Documentation  2.6.0-Brighton
 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  // TODO remove after tests !!!
137  clock_t tmpTime;
138 
139  Units map_unit;
140 
144  int point_p;
145 
149  int line_p;
150 
154  int poly_p;
155 
156  SearchMethod searchMethod;
157 
158  /*
159  * POPMUSIC Tuning
160  */
161  int popmusic_r;
162 
163  int tabuMaxIt;
164  int tabuMinIt;
165 
166  int dpi;
167 
168  int ejChainDeg;
169  int tenure;
170  double candListSize;
171 
175  bool showPartial;
176 
177 
178  typedef bool ( *FnIsCancelled )( void* ctx );
180  FnIsCancelled fnIsCancelled;
182  void* fnIsCancelledContext;
183 
199  Problem* extract( int nbLayers, char **layersName, double *layersFactor,
200  double lambda_min, double phi_min,
201  double lambda_max, double phi_max,
202  double scale, std::ofstream *svgmap );
203 
204 
209  void setPopmusicR( int r );
210 
211 
212 
217  void setMinIt( int min_it );
218 
223  void setMaxIt( int max_it );
224 
229  void setTenure( int tenure );
230 
235  void setEjChainDeg( int degree );
236 
241  void setCandListSize( double fact );
242 
243 
248  int getMinIt();
253  int getMaxIt();
254 
255 
256  public:
257 
261  Pal();
262 
266  ~Pal();
267 
286  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 );
287 
297  Layer *getLayer( const char *lyrName );
298 
304  QList<Layer*> *getLayers();
305 
311  void removeLayer( Layer *layer );
312 
324  std::list<LabelPosition*> *labeller( double scale, double bbox[4], PalStat **stats, bool displayAll );
325 
326 
344  std::list<LabelPosition*> *labeller( int nbLayers,
345  char **layersName,
346  double *layersFactor,
347  double scale, double bbox[4],
348  PalStat **stat,
349  bool displayAll );
350 
352  void registerCancellationCallback( FnIsCancelled fnCancelled, void* context );
353 
355  inline bool isCancelled() { return fnIsCancelled ? fnIsCancelled( fnIsCancelledContext ) : false; }
356 
357  Problem* extractProblem( double scale, double bbox[4] );
358 
359  std::list<LabelPosition*>* solveProblem( Problem* prob, bool displayAll );
360 
366  void setDpi( int dpi );
367 
373  int getDpi();
374 
380  void setShowPartial( bool show );
381 
387  bool getShowPartial();
388 
395  void setPointP( int point_p );
396 
403  void setLineP( int line_p );
404 
411  void setPolyP( int poly_p );
412 
416  int getPointP();
417 
421  int getLineP();
422 
426  int getPolyP();
427 
431  Units getMapUnit();
432 
436  void setMapUnit( Units map_unit );
437 
446  void setSearch( SearchMethod method );
447 
453  SearchMethod getSearch();
454  };
455 } // end namespace pal
456 #endif