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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlvision/tlvisTrn_tool.c

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

  1 /**********
  2 *
  3 *
  4  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  5  * University of Manchester, UK.  All rights reserved.
  6  * 
  7  * Redistribution and use in source and binary forms, with or without modification, 
  8  * are permitted provided that the following conditions are met:
  9  * 
 10  *   . Redistributions of source code must retain the above copyright notice, 
 11  *     this list of conditions and the following disclaimer.
 12  *    
 13  *   . Redistributions in binary form must reproduce the above copyright notice,
 14  *     this list of conditions and the following disclaimer in the documentation 
 15  *     and/or other materials provided with the distribution.
 16  * 
 17  *   . Neither the name of the University of Manchester nor the names of its
 18  *     contributors may be used to endorse or promote products derived from this 
 19  *     software without specific prior written permission.
 20  * 
 21  * 
 22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 32  * POSSIBILITY OF SUCH DAMAGE.
 33 **********
 34 *
 35 * Program :   TINA
 36 * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlvision/tlvisTrn_tool.c,v $
 37 * Date    :  $Date: 2005/02/07 23:29:19 $
 38 * Version :  $Revision: 1.3 $
 39 * CVS Id  :  $Id: tlvisTrn_tool.c,v 1.3 2005/02/07 23:29:19 paul Exp $
 40 *
 41 * Notes   :
 42 *
 43 *
 44 *
 45 *********
 46 */
 47 
 48 #include "tlvisTrn_tool.h"
 49 
 50 #if HAVE_CONFIG_H
 51   #include <config.h>
 52 #endif
 53 
 54 #include <tina/sys/sysDef.h>
 55 #include <tina/image/imgDef.h>
 56 #include <tina/image/imgPro.h>
 57 #include <tinatool/wdgts/wdgtsDef.h>
 58 #include <tinatool/wdgts/wdgtsPro.h>
 59 #include <tinatool/draw/drawDef.h>
 60 #include <tinatool/draw/drawPro.h>
 61 #include <tinatool/tlbase/tlbasePro.h>
 62 #include <tinatool/tlvision/tlvisTrn_procs.h>
 63 
 64 static Tv *tv;
 65 static int max_count = 20;
 66 
 67 static void tv_proc(void)
 68 {
 69     Tv     *terrain_tv();
 70 
 71     tv = terrain_tv();
 72     tv_set_next(tv);
 73 }
 74 
 75 static void tv_choice_proc(int value)
 76 {
 77     switch (value)
 78     {
 79         case 0:
 80         tv_set_next(tv);
 81     }
 82 }
 83 
 84 static void surf_check_proc(int value)
 85 {
 86     Bool    bot, top;
 87 
 88     top = (value & 0x1) ? true : false;
 89     bot = (value & 0x2) ? true : false;
 90     terr_show(top, bot);
 91 }
 92 
 93 /** param dialog box  **/
 94 
 95 static void param_dialog(void)
 96 {
 97     static void *dialog = NULL;
 98 
 99     if (dialog)
100     {
101         tw_show_dialog(dialog);
102         return;
103     }
104     (void) tw_dialog("Terrain Params");
105 
106     (void) tw_ivalue("X interval:", terr_samplex_get, terr_samplex_set, 16);
107     tw_newrow();
108     (void) tw_ivalue("Y interval:", terr_sampley_get, terr_sampley_set, 16);
109     tw_newrow();
110     (void) tw_fvalue("Z scale:   ", terr_scalez_get, terr_scalez_set, 16);
111     tw_newrow();
112     tw_iglobal("Grimson iterations: ", &max_count, 10);
113 
114     tw_end_dialog();
115 }
116 
117 static void push_proc(void)
118 {
119   Imrect *im;
120     
121   if (terr_im_get()==NULL) return;
122 
123   im = im_copy(terr_im_get());
124   stack_push((void *)im, IMRECT, im_free);
125   if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
126   if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
127   image_choice_reset();
128 }
129 
130 static void pop_proc(void)
131 {
132     void   *data;
133     int     type;
134 
135     data = stack_inspect(&type);
136     switch (type)
137     {
138     case IMRECT:
139         /** BUG result of stack_pop discarded.  Shouldn't it be:
140          *  terr_im_set((Imrect *) stack_pop(&type));
141          * break;
142          */
143         terr_im_set((Imrect *) data);
144         stack_pop(&type);
145         break;
146     case TERRAIN:
147         /** BUG result of stack_pop discarded. Shouldn't it be:
148          * terr_terrain_set((Terrain_data *) stack_pop(&type));
149          * break;
150          */
151         terr_terrain_set((Terrain_data *) data);
152         stack_pop(&type);
153         break;
154     default:
155         error("pop_proc: wrong type on stack", non_fatal);
156     }
157   if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
158   if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
159   image_choice_reset();
160 }
161 
162 static void terrain_proc(void)
163 {
164     terrain_from_image();
165 }
166 
167 static void fill_image_choice_proc(int value)
168 {
169     terr_fill_set(value);
170 }
171 
172 static void lines_choice_proc(int value)
173 {
174     terr_show_lines_set((Bool) value);
175 }
176 
177 static void fill_choice_proc(int value)
178 {
179     terr_show_fill_set((Bool) value);
180 }
181 
182 static void all_choice_proc(int value)
183 {
184     terr_show_all_set((Bool) value);
185 }
186 
187 extern Imrect *grimson_proc(Imrect *im, int max_count);
188 
189 static void grimson_but_proc(int value)
190 {
191     if (terr_im_get() == NULL)
192       return;
193 
194     terr_im_set(grimson_proc(terr_im_get(), max_count));
195 }
196 
197 /*
198 static void triangle_IM_proc(void)
199 {
200   triangulate_IM(terr_im_get());
201 }
202 
203 static void triangle_geom_proc(void)
204 {
205   List *geomlist = threed_geom_get();
206 
207   geomlist = triangulate_geom(geomlist);
208 
209   threed_geom_null();
210   threed_geom_set(geomlist);
211 }
212 */
213 
214 void    terrain_tool(int x, int y)
215 {
216     static void *tv_screen = NULL;
217 
218     if (tv_screen)
219     {
220         tw_show_tool(tv_screen);
221         return;
222     }
223     tv_screen = tw_tool("Terrain Tool", x, y);
224 
225     tv_proc();
226     /* terr_line_col_set(black); */
227 
228     tw_choice("Tv:", tv_choice_proc, 0, "terrain", NULL);
229     tw_label("                       ");
230     tw_help_button("terrain_tool");
231 
232     tw_newrow();
233     tw_check("Visible Surface:", surf_check_proc, 1, "Top", "Bot", NULL);
234     tw_choice(" ", all_choice_proc, 0, "all off", "all on", NULL);
235     tw_newrow();
236     tw_choice("Display:", lines_choice_proc, 1, "lines off", "lines on", NULL);
237     tw_choice("", fill_choice_proc, 0, "fill off", "fill on", NULL);
238     tw_newrow();
239     tw_choice("Fill Type:", fill_image_choice_proc, 0, "image", "shade", "mean", NULL);
240     tw_button("Terrain Params", param_dialog, NULL);
241     tw_newrow();
242     tw_label("Interpolation: ");
243     tw_button("surface", terrain_proc, NULL);
244     tw_button("Grimson", grimson_but_proc, NULL);
245     /*
246     tw_button("Triangle", triangle_IM_proc, NULL);
247     tw_newrow();
248     tw_label("3D Geom: ");
249     tw_button("Triangulate", triangle_geom_proc, NULL);
250     */
251     tw_newrow();
252     tw_button("push", push_proc, NULL);
253     tw_button("pop", pop_proc, NULL);
254     tw_end_tool();
255 }
256 

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