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

Linux Cross Reference
Tina6/tina-tools/tinatool/draw/drawTv_show.c

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

  1 /*********
  2  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  3  * University of Manchester, UK.  All rights reserved.
  4  * 
  5  * Redistribution and use in source and binary forms, with or without modification, 
  6  * are permitted provided that the following conditions are met:
  7  * 
  8  *   . Redistributions of source code must retain the above copyright notice, 
  9  *     this list of conditions and the following disclaimer.
 10  *    
 11  *   . Redistributions in binary form must reproduce the above copyright notice,
 12  *     this list of conditions and the following disclaimer in the documentation 
 13  *     and/or other materials provided with the distribution.
 14  * 
 15  *   . Neither the name of the University of Manchester nor the names of its
 16  *     contributors may be used to endorse or promote products derived from this 
 17  *     software without specific prior written permission.
 18  * 
 19  * 
 20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 30  * POSSIBILITY OF SUCH DAMAGE.
 31  *
 32  **********
 33  *
 34  * Program :    TINA
 35  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/draw/drawTv_show.c,v $
 36  * Date    :  $Date: 2007/02/15 01:55:50 $
 37  * Version :  $Revision: 1.3 $
 38  * CVS Id  :  $Id: drawTv_show.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 39  *
 40  * Author  : Legacy TINA
 41  *
 42  * Notes :
 43  * cmap_show: creates a Colormap Tool & fills with colored squares, overprinted
 44  * by the rgb's. Both fill an array with the rgb's then display values in
 45  * that.
 46  *
 47  *********
 48 */
 49 
 50 #include "drawTv_show.h"
 51 
 52 #if HAVE_CONFIG_H
 53   #include <config.h>
 54 #endif
 55 
 56 #include <stdio.h>
 57 #include <string.h>
 58 #include <math.h>
 59 #include <limits.h>
 60 #include <tina/sys/sysDef.h>
 61 #include <tina/sys/sysPro.h>
 62 #include <tina/math/mathDef.h>
 63 #include <tina/geometry/geomDef.h>
 64 #include <tina/geometry/geomPro.h>
 65 #include <tinatool/draw/draw_TvDef.h>
 66 #include <tinatool/draw/draw_TvPro.h>
 67 /* #include <tinatool/gphx/null/gphxNull_cmap.h> */
 68 
 69 /* STATICS */
 70 static int cmap_tool_cmap = 0;
 71 static Tina_color *cmap_tool_tina_colors = NULL;
 72 static int cmap_tool_size = 0;
 73 
 74 /* Show cmap as palette (array of color squares). */
 75 void    cmap_show(Cmap_data_visible * cmap_data_visible, Tv*cmap_tv)
 76 {
 77 /*     extern int     cmap_data_cmap_ncells_get(Cmap_data_visible * cmap_data) ; */
 78     void   *cmap_data_cmap_get();
 79 
 80     if (cmap_data_visible)
 81     {
 82         int     ncells = cmap_data_cmap_ncells_get(cmap_data_visible);
 83         Tina_color *tina_colors = TINA_COLOR_ARRAY_CREATE(ncells);
 84         /*int     cmap = (int) cmap_data_cmap_get(cmap_data_visible);*/
 85         int     cmap = (long int) cmap_data_cmap_get(cmap_data_visible); /*JD, 2015.01.27*/
 86 
 87         /* Set window header */
 88         (void) sprintf (cmap_tv->label, "Colormap: %x.", cmap);
 89         tv_set_header (cmap_tv, cmap_tv->label);
 90 
 91         /* Set redraw function to draw colors */
 92         (void) tv_set_fulldraw (cmap_tv, cmap_tool_redraw);
 93 
 94         /* warning: argument #1 is incompatible with prototype:
 95         prototype: pointer to char : "../../../tinatool/gphx/null/gphxNull_cmap.h", line 64
 96         argument : pointer to struct cmap_data_visible {enum ts_id {ts_last_id(10119), Ts_string_id(10118), Ts_double_id(10117), Ts_float_id(10116), Ts_int_id(10115), User_type_9_id(10114), User_type_8_id(10113), User_type_7_id(10112), User_type_6_id(10111), User_type_5_id(10110), User_type_4_id(10109), User_type_3_id(10108), User_type_2_id(10107), User_type_1_id(10106), User_type_0_id(10105), Windex_id(10104), Vram_id(10103), Viols_node_id(10102), Vector_id(10101), Vec4_id(10100), Vec3_id(10099), Vec2_id(10098), Ucbs3_id(10097), Ucbs2_id(10096), Ucbs_id(10095), Tw_callback_id(10094), Tv_zbuff_id(10093), Tv_screen_id(10092), Tv_picture_id(10091), Tv_pick_id(10090), Tv_patch_id(10089), Tv_mouse_id(10088), Tv_mask_id(10087), Tv_draw_id(10086), Tv_closest_id(10085), Tv_id(10084), Tstring_id(10083), Tree_node_id(10082), Transform3_id(10081), Transform2_id(10080), Transf3_id(10079), Torus_id(10078), Toptool_data_id(10077), Tina_color_id(10076), Terrain_data_id(10075), Support_id(10074), String_match_id(10073), State_id(10072), Snake_id(10071), Scalar_id(10070), Ruled_id(10069), Rindex_id(10068), Rgb_id(10067), Quadric_id(10066), Quad3_id(10065), Pwrte_vec_to_vec_id(10064), Pwrte_point_to_vec_id(10063), Pwrte_point_to_point_id(10062), Pwrte_gen_id(10061), Prop_id(10060), Prof1_id(10059), Pos3_id(10058), Pos2_id(10057), Point3_id(10056), Point2_id(10055), Plane_id(10054), Pl_graph_id(10053), Pl_ctr_id(10052), Pl_axes_id(10051), Parcam_id(10050), Pair_id(10049), Matrix_id(10048), Match_clique_id(10047), Match_cliche_id(10046), Match_id(10045), Mat4_id(10044), Mat3_id(10043), Mat2_id(10042), List_id(10041), Line3_id(10040), Line2_id(10039), Kwsnake_id(10038), Iso_error_id(10037), Ipos_id(10036), Imstack_id(10035), Imregion_id(10034), Imrect_id(10033), Iffhdr_id(10032), Ics2_id(10031), Icarray_id(10030), Graph_node_id(10029), Generic_id(10028), Font_data_id(10027), Field_info_id(10026), Epos_id(10025), Edgel_id(10024), Edge_fp_id(10023), Edge_conn_id(10022), Dpnode_id(10021), Ddlist_id(10020), Cylinder_id(10019), Cvr_voi_id(10018), Cvr_slice_id(10017), Cursor_data_id(10016), Covar_id(10015), Conic_stat_id(10014), Conic3_id(10013), Conic_id(10012), Cone_id(10011), Complex_id(10010), Cmap_data_visible_id(10009), Cmap_data_id(10008), Circ2_id(10007), Camera_id(10006), Blk_stat_id(10005), Bin_node_id(10004), Basis3_id(10003), Basis2_id(10002), Aiffhdr_id(10001), ts_base_id(10000)} ts_id, enum cmap_model {cmap_model_unknown(3), cmap_model_rgb(2), cmap_model_col(1), cmap_model_gs(0)} model, enum cmap_kind {cmap_type_unknown(2), cmap_type_static(1), cmap_type_dynamic(0)} type, int ncells, int nplanes, int base, array[512] of int std_lut, int overlay_mask, int color_bits, array[256] of int color_lut} */
 97         (void) cmap_query_colors(cmap_data_visible, tina_colors, 0, ncells);
 98 
 99         tina_colors_show(cmap, tina_colors, ncells,cmap_tv);
100         rfree((void *) tina_colors);
101     }
102 }
103 
104 /* Repaint cells in a cmap as colored squares in a window on screen,
105  * overprint with rgb's */
106 void    cmap_tool_redraw(Tv * tv)
107 {
108     if (tv && tv->tv_screen)
109     {
110         char    red[3], green[3], blue[3];
111         int     cols = (int) ceil(sqrt((double) cmap_tool_size));
112         int     cell_side = tv_get_width(tv) / cols;
113         int     i;
114         int     lineht = cell_side / 4;
115         int     rows = (int) ceil((double) cmap_tool_size / cols);
116         int     x;
117         int     y;
118 
119         /* Draw colored squares */
120         for (i = 0; i < cmap_tool_size; i++)
121         {
122             x = (i % cols) * cell_side;
123             y = (i / rows) * cell_side;
124             tv_color_reset(tv, cmap_tool_tina_colors[i].pixel);
125             tv_fillrectxy(tv, x, y, x + cell_side, y + cell_side);
126         }
127 
128         /* Overprint with rgb's */
129         tv_color_set(tv, black);
130         for (i = 0; i < cmap_tool_size; i++)
131         {
132             x = (i % cols) * cell_side;
133             y = (i / rows) * cell_side;
134 
135             (void) sprintf(red, "%02x", cmap_tool_tina_colors[i].red >> 8);
136             (void) sprintf(green, "%02x", cmap_tool_tina_colors[i].green >> 8);
137             (void) sprintf(blue, "%02x", cmap_tool_tina_colors[i].blue >> 8);
138             tv_textxy(tv, red, x, y += lineht);
139             tv_textxy(tv, green, x, y += lineht);
140             tv_textxy(tv, blue, x, y += lineht);
141         }
142     }
143 }
144 
145 /* Show the cells in a cmap as colored squares in a window on screen,
146  * overprint with rgb's */
147 void    tina_colors_show(int cmap, Tina_color * tina_colors, int size,Tv*cmap_tv)
148 {
149     int     i;
150 
151     if (cmap_tool_tina_colors)
152     {
153         rfree((void *) cmap_tool_tina_colors);
154     }
155     /* Save cmap & size for use by repaints */
156     cmap_tool_cmap = cmap;
157     cmap_tool_size = size;
158 
159     /* Save rgb & pixel arrays for use by repaints */
160     cmap_tool_tina_colors = TINA_COLOR_ARRAY_CREATE(size);
161     for (i = 0; i < size; i++)
162     {
163         cmap_tool_tina_colors[i] = tina_colors[i];
164     }
165 
166     tv_cmap_install(cmap_tv, (void *) (long int) cmap); /* JD, 2015.01.27 */
167     tv_repaint(cmap_tv);
168 }
169 

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