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

Linux Cross Reference
Tina4/src/tools/terrain/trn_tool.c

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

  1 #include <stdio.h>
  2 #include <tina/sys.h>
  3 #include <tina/sysfuncs.h>
  4 #include <tina/math.h>
  5 #include <tina/vision.h>
  6 #include <tina/tv.h>
  7 #include <tina/tvfuncs.h>
  8 #include <tina/toolsfuncs.h>
  9 #include <tina/tw_Xfuncs.h>
 10 
 11 /* EXTERNS  */
 12 extern void tw_show_tool();
 13 extern void *tw_tool();
 14 extern void *tw_ivalue();
 15 
 16 static Tv *tv;
 17 static int max_count = 20;
 18 
 19 static void tv_proc(void)
 20 {
 21     Tv     *terrain_tv();
 22 
 23     tv = terrain_tv();
 24     tv_set_next(tv);
 25 }
 26 
 27 static void tv_choice_proc(int value)
 28 {
 29     switch (value)
 30     {
 31         case 0:
 32         tv_set_next(tv);
 33     }
 34 }
 35 
 36 static void surf_check_proc(int value)
 37 {
 38     Bool    bot, top;
 39 
 40     top = (value & 0x1) ? true : false;
 41     bot = (value & 0x2) ? true : false;
 42     terr_show(top, bot);
 43 }
 44 
 45 /** param dialog box  **/
 46 
 47 static void param_dialog(void)
 48 {
 49     static void *dialog = NULL;
 50 
 51     if (dialog)
 52     {
 53         tw_show_dialog(dialog);
 54         return;
 55     }
 56     (void) tw_dialog("Terrain Params");
 57 
 58     (void) tw_ivalue("X interval:", terr_samplex_get, terr_samplex_set, 16);
 59     tw_newrow();
 60     (void) tw_ivalue("Y interval:", terr_sampley_get, terr_sampley_set, 16);
 61     tw_newrow();
 62     (void) tw_fvalue("Z scale:   ", terr_scalez_get, terr_scalez_set, 16);
 63     tw_newrow();
 64     tw_iglobal("Grimson iterations: ", &max_count, 10);
 65 
 66     tw_end_dialog();
 67 }
 68 
 69 static void push_proc(void)
 70 {
 71   Imrect *im;
 72     
 73   if (terr_im_get()==NULL) return;
 74 
 75   im = im_copy(terr_im_get());
 76   stack_push((void *)im, IMRECT, im_free);
 77   if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
 78   if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
 79   image_choice_reset();
 80 }
 81 
 82 static void pop_proc(void)
 83 {
 84     void   *data;
 85     int     type;
 86 
 87     data = stack_inspect(&type);
 88     switch (type)
 89     {
 90     case IMRECT:
 91         /** BUG result of stack_pop discarded.  Shouldn't it be:
 92          *  terr_im_set((Imrect *) stack_pop(&type));
 93          * break;
 94          */
 95         terr_im_set((Imrect *) data);
 96         stack_pop(&type);
 97         break;
 98     case TERRAIN:
 99         /** BUG result of stack_pop discarded. Shouldn't it be:
100          * terr_terrain_set((Terrain_data *) stack_pop(&type));
101          * break;
102          */
103         terr_terrain_set((Terrain_data *) data);
104         stack_pop(&type);
105         break;
106     default:
107         error("pop_proc: wrong type on stack", non_fatal);
108     }
109   if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
110   if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
111   image_choice_reset();
112 }
113 
114 static void terrain_proc(void)
115 {
116     terrain_from_image();
117 }
118 
119 static void fill_image_choice_proc(int value)
120 {
121     terr_fill_set(value);
122 }
123 
124 static void lines_choice_proc(int value)
125 {
126     terr_show_lines_set((Bool) value);
127 }
128 
129 static void fill_choice_proc(int value)
130 {
131     terr_show_fill_set((Bool) value);
132 }
133 
134 static void all_choice_proc(int value)
135 {
136     terr_show_all_set((Bool) value);
137 }
138 
139 extern Imrect *grimson_proc(Imrect *im, int max_count);
140 
141 static void grimson_but_proc(int value)
142 {
143     if (terr_im_get() == NULL)
144       return;
145 
146     terr_im_set(grimson_proc(terr_im_get(), max_count));
147 }
148 
149 /*
150 static void triangle_IM_proc(void)
151 {
152   triangulate_IM(terr_im_get());
153 }
154 
155 static void triangle_geom_proc(void)
156 {
157   List *geomlist = threed_geom_get();
158 
159   geomlist = triangulate_geom(geomlist);
160 
161   threed_geom_null();
162   threed_geom_set(geomlist);
163 }
164 */
165 
166 void    terrain_tool(int x, int y)
167 {
168     static void *tv_screen = NULL;
169 
170     if (tv_screen)
171     {
172         tw_show_tool(tv_screen);
173         return;
174     }
175     tv_screen = tw_tool("Terrain Tool", x, y);
176 
177     tv_proc();
178     /* terr_line_col_set(black); */
179 
180     tw_choice("Tv:", tv_choice_proc, 0, "terrain", NULL);
181     tw_label("                       ");
182     tw_help_button("terrain_tool");
183 
184     tw_newrow();
185     tw_check("Visible Surface:", surf_check_proc, 1, "Top", "Bot", NULL);
186     tw_choice(" ", all_choice_proc, 0, "all off", "all on", NULL);
187     tw_newrow();
188     tw_choice("Display:", lines_choice_proc, 1, "lines off", "lines on", NULL);
189     tw_choice("", fill_choice_proc, 0, "fill off", "fill on", NULL);
190     tw_newrow();
191     tw_choice("Fill Type:", fill_image_choice_proc, 0, "image", "shade", "mean", NULL);
192     tw_button("Terrain Params", param_dialog, NULL);
193     tw_newrow();
194     tw_label("Interpolation: ");
195     tw_button("surface", terrain_proc, NULL);
196     tw_button("Grimson", grimson_but_proc, NULL);
197     /*
198     tw_button("Triangle", triangle_IM_proc, NULL);
199     tw_newrow();
200     tw_label("3D Geom: ");
201     tw_button("Triangulate", triangle_geom_proc, NULL);
202     */
203     tw_newrow();
204     tw_button("push", push_proc, NULL);
205     tw_button("pop", pop_proc, NULL);
206     tw_end_tool();
207 }
208 

~ [ 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.