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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlbase/tlbaseSeq_view.c

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlbase/tlbaseSeq_view.c,v $
 37  * Date    :  $Date: 2003/10/01 16:02:47 $
 38  * Version :  $Revision: 1.4 $
 39  * CVS Id  :  $Id: tlbaseSeq_view.c,v 1.4 2003/10/01 16:02:47 tony Exp $
 40  *
 41  * Notes :
 42  *
 43  *********
 44 */
 45 
 46 #include "tlbaseSeq_view.h"
 47 
 48 
 49 #if HAVE_CONFIG_H
 50 #   include <config.h>
 51 #endif
 52 
 53 #include <stdio.h>
 54 #include <tina/sys/sysDef.h>
 55 #include <tina/sys/sysPro.h>
 56 #include <tina/image/imgDef.h>
 57 #include <tina/image/imgPro.h>
 58 #include <tina/geometry/geomDef.h>
 59 #include <tina/geometry/geomPro.h>
 60 #include <tinatool/draw/drawDef.h>
 61 #include <tinatool/draw/drawPro.h>
 62 #include <tinatool/tlbase/tlbase_SeqDef.h>
 63 #include <tinatool/tlbase/tlbaseSeq_image.h>
 64 #include <tinatool/tlbase/tlbaseSeq_tv.h>
 65 
 66 
 67 #define TRFEATURE_C     yellow
 68 #define TRCP_C          red
 69 #define TRCV_C          green
 70 #define TRCA_C          blue
 71 #define TRMOD_C         violet
 72 
 73 
 74 static Bool      image_on;
 75 static Bool      edges_on;
 76 static Bool      corners_on;
 77 static Bool      text_on;
 78 /*static Bool      bmroi_on;
 79   static Bool      kalm_on;*/
 80 
 81 
 82 /* sets image stuff on */
 83 void    seq_image_on(Bool on)
 84 {
 85   image_on = on;
 86 }
 87 
 88 
 89 void    seq_edges_on(Bool on)
 90 {
 91   edges_on = on;
 92 }
 93 
 94 
 95 void    seq_corners_on(Bool on)
 96 {
 97   corners_on = on;
 98 }
 99 
100 
101 void    seq_text_on(Bool on)
102 {
103   text_on = on;
104 }
105 
106 /*
107   static void     label_to_text(int a, int b, char *st)
108   {
109    if (b < 0)
110   sprintf(st, "%d", a);
111    else
112   sprintf(st, "%d:%d", a, b);
113   }
114 */
115 
116 /* show text on a frame */  
117 /*static void     seq_show_text(Tv *tv)
118 {
119   Imrect   *im = (Imrect *)seq_image_get();
120   char      mssg[512];
121   Ipos      pos;
122   
123   if (im == NULL)
124     return;
125   
126   pos = ipos(10, 10);
127   tv_set_color(tv, red);
128   
129   sprintf(mssg, "Frame: %d", seq_get_frame_no(im));
130   tv_text(tv, mssg, pos);
131 }
132 */
133 
134 
135 static void       seq_show_corners(Tv *tv)
136 {
137   Imrect        *im = (Imrect *)seq_image_get();
138   Imrect        *imc = NULL;
139 
140   if (im == NULL)
141     return;
142 
143   if ((imc = (Imrect *)prop_get(im->props, TMPCNR_TYPE)) == NULL)
144     {
145       seq_corners_set(NULL);
146       return;
147     }
148 
149   seq_corners_set(imc);
150 
151 }
152 
153 
154 static void      seq_show_edges(Tv *tv)
155 {
156   Imrect        *im = (Imrect *)seq_image_get();
157   Imrect        *ime = NULL;
158 
159   if (im == NULL)
160     return;
161 
162   if ((ime = (Imrect *)prop_get(im->props, TMPEDG_TYPE)) == NULL)
163     {
164           seq_edges_set(NULL);
165           return;
166     }
167 
168   seq_edges_set(ime);
169 
170 }
171 
172 
173 
174 void         seq_show_bits()
175 {
176   Tv    *tv = (Tv *)seq_tv_get();
177 
178   if (tv == NULL)
179     return;
180   /*
181     if (text_on)
182     seq_show_text(tv);
183   */
184   if (corners_on)
185     seq_show_corners(tv);
186 
187   if (edges_on)
188     seq_show_edges(tv);
189 
190 }
191 
192 /* Draw functions: basically the same as before, but using my functions */
193 
194 void        seq_backdraw(Tv *tv)
195 {
196   Imrect    *im = (Imrect *)seq_image_get();
197  
198   if (image_on && (im != NULL))
199   {
200      im = (Imrect *)imf_scale(im, 0.0, 255.0);
201      tv_imrect2(tv, im);
202      im_free(im);
203   }
204 
205 }
206 
207  
208 void         seq_fulldraw(Tv *tv)
209 {
210   Imrect     *er = (Imrect *)seq_edges_get();
211   Imrect     *cnr = (Imrect *)seq_corners_get();
212  
213   if (edges_on && (er != NULL))
214     tv_edges_conn(tv, er);
215   if (corners_on && (cnr != NULL))
216     tv_edges_conn(tv, cnr);
217 }
218 
219 
220 
221 void          seq_skeldraw(Tv *tv)
222 {
223   Imrect     *im = (Imrect *)seq_image_get();
224   Imrect     *er = (Imrect *)seq_edges();
225  
226   tv_set_overlay(tv);
227   if (image_on && (im != NULL))
228     tv_imrect_skel(tv, im);
229   else if ((edges_on) && (er != NULL))
230     tv_imrect_skel(tv, er);
231   tv_reset_draw(tv);
232 }
233 
234 
235 static void            view_init(Tv *tv)
236 {
237   Imrect      *im = (Imrect *)seq_image_get();
238   Imrect      *er = (Imrect *)seq_edges();
239  
240   if (im != NULL)
241     tv_camera2_image(tv, im->width, im->height);
242   else if (er != NULL)
243     tv_camera2_image(tv, er->width, er->height);
244   seq_show_bits();
245 }
246 
247 
248 
249 Tv            *seq_tv_make(void)
250 {
251   Tv    *tvseq = NULL;
252 
253   tvseq = (Tv *)tv_create("sequence");
254   tv_set_backdraw(tvseq, seq_backdraw);
255   tv_set_fulldraw(tvseq, seq_fulldraw);
256   tv_set_skeldraw(tvseq, seq_skeldraw);
257   tv_set_zoomlevel(tvseq, IMZOOM);
258   tv_set_init(tvseq, view_init);
259 
260   return (tvseq);
261 }
262 
263 
264 
265 
266 
267 
268 
269 

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