]> mj.ucw.cz Git - leo.git/blob - labeller.h
Labelling: Another bunch of edits
[leo.git] / labeller.h
1 #ifndef _LEO_LABELLER_H
2 #define _LEO_LABELLER_H
3
4 enum label_type
5 {
6   LABEL_POINT,
7   LABEL_LINE,
8   LABEL_AREA,
9 };
10
11 enum request_type
12 {
13   REQUEST_POINT,
14   REQUEST_AREALABEL,
15   REQUEST_LINELABEL,
16   REQUEST_SEGMENT,
17 };
18
19 enum term_cond
20 {
21   TERM_COND_PENALTY,
22   TERM_COND_STAGNATION,
23   TERM_COND_ITERATIONS,
24 };
25
26 struct sym_placement
27 {
28   double x;
29   double y;
30   int variant;
31   struct request *request;
32 };
33
34 struct request
35 {
36   enum request_type type;
37   int ind;
38 };
39
40 struct point_variant
41 {
42   double width;
43   double height;
44   bool *bitmap;
45 };
46
47 struct line_variant
48 {
49   bool *masks;
50 };
51
52 struct request_point
53 {
54   struct request request;
55   struct symbol *sym;
56   struct osm_object *object; // FIXME: Linked also by sym
57   z_index_t zindex;
58   double x;
59   double y;
60   double offset_x;
61   double offset_y;
62   int num_variants;
63   struct point_variant *variants;
64 };
65
66 struct request_segment
67 {
68   struct request request;
69   double x1;
70   double y1;
71   double x2;
72   double y2;
73   double k;
74   struct sym_line *sym;
75   struct point_variant *variant;
76   struct sym_text *text;
77   z_index_t zindex;
78 };
79
80 struct request_line
81 {
82   struct request request;
83   struct symbol *sym;
84   int num_variants;
85   int num_segments;
86   struct line_variant *variants;
87   struct request_segment *segments;
88 };
89
90 struct request_area
91 {
92   struct request request;
93   struct osm_multipolygon *o;
94   struct sym_text *sym;
95   struct point_variant *text_variant;
96   z_index_t zindex;
97 };
98
99 struct buffer_line
100 {
101   struct sym_line *line;
102   z_index_t zindex;
103 };
104
105 struct buffer_linelabel
106 {
107   struct osm_way *way;
108   struct sym_text *text;
109   z_index_t zindex;
110 };
111
112 struct graph_node
113 {
114   osm_id_t id;
115   struct osm_node *o;
116   struct graph_edge **edges;
117   int num;
118 };
119
120 struct graph_edge
121 {
122   osm_id_t id;
123   double length;
124   color_t color;
125   bool visited;
126   struct graph_edge *prev;
127   struct graph_edge *next;
128   struct graph_node *n1;
129   struct graph_node *n2;
130   uns longline;
131   struct sym_text *text;
132   struct sym_line *sym;
133   z_index_t zindex;
134   int dir;
135   struct graph_node *anode;
136   struct graph_node *bnode; // DEBUG PRINT
137   int num; // DEBUG
138 };
139
140 struct longline
141 {
142   uns id;
143   struct graph_edge *first;
144 };
145
146 struct placement
147 {
148   double x;
149   double y;
150   int variant_used;
151   bool processed;
152   struct request *request;
153 };
154
155 struct map_part
156 {
157 };
158
159 struct individual
160 {
161   struct placement *placements;
162   struct map_part **map;
163   int penalty;
164 };
165
166 void labeller_init(void);
167 void labeller_add_point(struct symbol *sym, struct osm_object *object, z_index_t zindex);
168 void labeller_add_line(struct symbol *sym, z_index_t zindex);
169 void labeller_label(void);
170 void labeller_add_linelabel(struct symbol *sym, struct osm_object *o, z_index_t zindex);
171 void labeller_add_arealabel(struct symbol *sym, struct osm_object *o, z_index_t zindex);
172
173 void make_bitmap_icon(struct point_variant *v, struct sym_icon *si);
174 void make_bitmap_point(struct point_variant *v, struct sym_point *sp);
175 void make_bitmap_label(struct point_variant *v, struct sym_text *text);
176
177 void make_graph(void);
178 void label_graph(void);
179 void join_edge(struct graph_edge *e, int dir);
180 void bfs(void);
181 void make_segments(void);
182
183 void make_population(void);
184 bool shall_terminate(void);
185 void breed(void);
186 void mutate(void);
187 void elite(void);
188 void rank_population(void);
189
190 struct individual **perform_crossover(struct individual *parent1, struct individual *parent2);
191 void perform_mutation(struct individual *individual);
192
193 void init_placement(struct placement *p, struct request *r);
194 void init_individual(struct individual *i);
195 void gen_coords_point(struct placement *p);
196 void gen_coords(struct placement *p);
197 struct map_part **get_parts(struct placement *symbol, struct individual *individual);
198
199 int randint(int min, int max);
200
201 struct placement **get_closure(struct placement *placement, struct individual *parent1, struct individual *parent2);
202 void copy_symbols(struct placement **closure, struct individual *parent, struct individual *child);
203 void move_symbol(struct placement *p);
204 void move_symbol_point(struct placement *p);
205
206 struct placement **get_overlapping(struct placement *p);
207 void filter(struct placement **list, bool *pred);
208
209 int flip(int a, int b);
210 double randdouble(void);
211
212 void cleanup(void);
213
214 void copy_individual(struct individual *src, struct individual *dest);
215
216 #endif