~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/gstat/gstat_tool.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <math.h>
  5 #include <tina/sys.h>
  6 #include <tina/sysfuncs.h>
  7 #include <tina/math.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 #include <tina/file.h>
 11 #include <tina/filefuncs.h>
 12 #include <tina/tv.h>
 13 #include <tina/tvfuncs.h>
 14 #include <tina/toolsfuncs.h>
 15 #include <tina/tw_Xfuncs.h>
 16 
 17 /* EXTERNS  */
 18 extern void tw_show_tool();
 19 extern void *tw_tool();
 20 
 21 static char base_name[32] = "";
 22 static char directory_name[64] = "";
 23 Tv     *gstat_tv();
 24 State  *state_get();
 25 void    docorrect_set();
 26 void    kalman_verbose_set();
 27 
 28 static void make_filename(char *fname, char *type)
 29 {
 30     (void) string_append(fname, directory_name, "/", base_name, type, NULL);
 31 }
 32 
 33 static void file_input_proc(void)
 34 {
 35     char    fname[256];
 36     List   *lines;
 37     State  *state = gstat_get();
 38     State  *state_make();
 39     double  accuracy = 0.005;
 40 
 41     if (state != NULL)
 42     {
 43         state_free(state);
 44         gstat_set((State *) NULL);
 45     }
 46     make_filename(fname, ".poly");
 47     gstat_set(state_make(lines = geom3_read(fname, RIGHT), accuracy));
 48     list_rm(lines, line3_free);
 49 }
 50 
 51 static void threed_input_proc(void)
 52 {
 53     List   *lines;
 54     State  *state = gstat_get();
 55     State  *state_make();
 56     double  accuracy = 0.005;
 57 
 58     if (state != NULL)
 59     {
 60         state_free(state);
 61         gstat_set((State *) NULL);
 62     }
 63     lines = reclist_list_flat(threed_geom_get(), geom_update_copy, LINE3,
 64                               NULL);
 65     gstat_set(state_make(lines, accuracy));
 66     list_rm(lines, line3_free);
 67 }
 68 
 69 static void tv_proc(void)
 70 {
 71     gstat_tv_set(gstat_tv_make());
 72     tv_set_next(gstat_tv());
 73 }
 74 
 75 static void tv_choice_proc(int value)
 76 {
 77     switch (value)
 78     {
 79         case 0:
 80         tv_set_next(gstat_tv());
 81         break;
 82     }
 83 }
 84 
 85 static void gstat_pick_edit_proc(int value)
 86 {
 87     Tv     *tv = gstat_tv();
 88 
 89     switch (value)
 90     {
 91     case 0:
 92         tv_set_pick(tv, null_pick());
 93         break;
 94     case 1:
 95         tv_set_pick(tv, gstat_pick_delete());
 96         break;
 97     case 2:
 98         tv_set_pick(tv, gstat_pick_choose());
 99         break;
100     }
101     (void) tv_set_activity(tv, PICK);
102 }
103 
104 static void gstat_pick_constraint_proc(int value)
105 {
106     Tv     *tv = gstat_tv();
107 
108     switch (value)
109     {
110     case 0:
111         tv_set_pick(tv, null_pick());
112         break;
113     case 1:
114         tv_set_pick(tv, gstat_pick_equal());
115         break;
116     case 2:
117         tv_set_pick(tv, gstat_pick_on());
118         break;
119     case 3:
120         tv_set_pick(tv, gstat_pick_orth());
121         break;
122     case 4:
123         tv_set_pick(tv, gstat_pick_par());
124         break;
125     }
126     (void) tv_set_activity(tv, PICK);
127 }
128 
129 static void gstat_pick_batch_proc(int value)
130 {
131     Tv     *tv = gstat_tv();
132 
133     switch (value)
134     {
135     case 0:
136         tv_set_pick(tv, null_pick());
137         break;
138     case 1:
139         tv_set_pick(tv, gstat_pick_vertex());
140         break;
141     case 2:
142         tv_set_pick(tv, gstat_pick_face());
143         break;
144     case 3:
145         tv_set_pick(tv, gstat_pick_batch_orth());
146         break;
147     case 4:
148         tv_set_pick(tv, gstat_pick_batch_par());
149         break;
150     }
151     (void) tv_set_activity(tv, PICK);
152 }
153 
154 static void gstat_pick_add_proc(int value)
155 {
156     Tv     *tv = gstat_tv();
157 
158     switch (value)
159     {
160     case 0:
161         tv_set_pick(tv, null_pick());
162         break;
163     case 1:
164         tv_set_pick(tv, gstat_pick_add_intersect());
165         break;
166     case 2:
167         tv_set_pick(tv, gstat_pick_add_join());
168         break;
169     }
170     (void) tv_set_activity(tv, PICK);
171 }
172 
173 static void gstat_pick_cosmetic_proc(int value)
174 {
175     Tv     *tv = gstat_tv();
176 
177     switch (value)
178     {
179     case 0:
180         tv_set_pick(tv, null_pick());
181         break;
182     case 1:
183         tv_set_pick(tv, gstat_pick_extend());
184         break;
185     }
186     (void) tv_set_activity(tv, PICK);
187 }
188 
189 void    gstat_correct(void)
190 {
191     State  *state = gstat_get();
192     Tv     *tv = gstat_tv();
193 
194     if (state == NULL)
195         return;
196     state_correct(state);
197     tv_repaint(tv);
198 }
199 
200 static void gstat_pick_print_geom_proc(int value)
201 {
202     Tv     *tv = gstat_tv();
203 
204     switch (value)
205     {
206     case 0:
207         tv_set_pick(tv, null_pick());
208         break;
209     case 1:
210         tv_set_pick(tv, gstat_pick_print_geom());
211         break;
212     case 2:
213         tv_set_pick(tv, gstat_pick_print_basis());
214         break;
215     }
216     (void) tv_set_activity(tv, PICK);
217 }
218 
219 static void gstat_pick_print_stats_proc(int value)
220 {
221     Tv     *tv = gstat_tv();
222 
223     switch (value)
224     {
225     case 0:
226         tv_set_pick(tv, null_pick());
227         break;
228     case 1:
229         tv_set_pick(tv, gstat_pick_print_x());
230         break;
231     case 2:
232         tv_set_pick(tv, gstat_pick_print_m());
233         break;
234     case 3:
235         tv_set_pick(tv, gstat_pick_print_cov());
236         break;
237     case 4:
238         tv_set_pick(tv, gstat_pick_print_corr());
239         break;
240     }
241     (void) tv_set_activity(tv, PICK);
242 }
243 
244 static void gstat_pick_geometry_proc(int value)
245 {
246     Tv     *tv = gstat_tv();
247 
248     switch (value)
249     {
250     case 0:
251         tv_set_pick(tv, null_pick());
252         break;
253     case 1:
254         tv_set_pick(tv, gstat_pick_angle());
255         break;
256     case 2:
257         tv_set_pick(tv, gstat_pick_dist());
258         break;
259     }
260     (void) tv_set_activity(tv, PICK);
261 }
262 
263 void    gstat_tool(int x, int y)
264 {
265     static void *tv_screen = NULL;
266 
267     if (tv_screen)
268     {                           /** already have geomstat tv_screen, just show it **/
269         tw_show_tool(tv_screen);
270         return;
271     }
272     tv_proc();
273     tv_screen = tw_tool("Geomstat Tool", x, y);
274 
275     tw_menubar("Pick :",
276                "Edit",
277                "other", gstat_pick_edit_proc, 0,
278                "delete", gstat_pick_edit_proc, 1,
279                "choose", gstat_pick_edit_proc, 2,
280                NULL,
281                "Add",
282                "other", gstat_pick_add_proc, 0,
283                "intersect", gstat_pick_add_proc, 1,
284                "join ", gstat_pick_add_proc, 2,
285                NULL,
286                "Impose",
287                "other", gstat_pick_constraint_proc, 0,
288                "equal", gstat_pick_constraint_proc, 1,
289                "on", gstat_pick_constraint_proc, 2,
290                "orth", gstat_pick_constraint_proc, 3,
291                "par", gstat_pick_constraint_proc, 4,
292                NULL,
293                "Cosmetic",
294                "other", gstat_pick_cosmetic_proc, 0,
295                "extend", gstat_pick_cosmetic_proc, 1,
296                NULL,
297 #ifndef lint                    /* lint fails on > 49 args */
298                "Batch",
299                "other",
300                gstat_pick_batch_proc, 0,
301                "vertex", gstat_pick_batch_proc, 1,
302                "face", gstat_pick_batch_proc, 2,
303                "orth", gstat_pick_batch_proc, 3,
304                "par", gstat_pick_batch_proc, 4,
305                NULL,
306 #endif                          /* lint */
307                NULL);
308 
309     tw_newrow();
310     tw_menubar("Pick",
311                "Geom",
312                "other", gstat_pick_print_geom_proc, 0,
313                "geom", gstat_pick_print_geom_proc, 1,
314                "basis", gstat_pick_print_geom_proc, 2,
315                NULL,
316                "Print",
317                "other", gstat_pick_print_stats_proc, 0,
318                "x", gstat_pick_print_stats_proc, 1,
319                "m", gstat_pick_print_stats_proc, 2,
320                "cov", gstat_pick_print_stats_proc, 3,
321                "corr", gstat_pick_print_stats_proc, 4,
322                NULL,
323                "Metric",
324                "other", gstat_pick_geometry_proc, 0,
325                "angle", gstat_pick_geometry_proc, 1,
326                "dist", gstat_pick_geometry_proc, 2,
327                NULL,
328                NULL);
329 
330     tw_newrow();
331     tw_toggle("Verbose", kalman_verbose_set, false);
332     tw_toggle("Do correct", docorrect_set, true);
333     tw_button("correct", gstat_correct, NULL);
334     tw_newrow();
335     (void) tw_sglobal("Directory Name:", directory_name, 32);
336     tw_newrow();
337     (void) tw_sglobal("Directory Name:", base_name, 32);
338 
339     tw_newrow();
340     tw_button("file input", file_input_proc, NULL);
341     tw_button("threed input", threed_input_proc, NULL);
342 
343     tw_choice("Tv list:", tv_choice_proc, 0, "state", NULL);
344     tw_end_tool();
345 }
346 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.