GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
raster2.c
Go to the documentation of this file.
1 
2 /********************************************************************
3  * code in this file is designed to send raster data to the graphics
4  * driver. It handles raster->color lookup translation, as well as
5  * loading appropriate colormaps into the driver and the sending of
6  * raster data to the plotter. The loading of colors is designed to
7  * never send more colors than the hardware can support - even though
8  * the GRASS drivers will allocate virtual colormaps to pretend there are more
9  * This code effectively disables that driver feature/mistake.
10  *
11  * To simply plot raster data:
12  *
13  * to specify if overlay mode is to be used
14  * D_set_overlay_mode(flag)
15  * int flag; /1=yes,0=no/
16  *
17  * to select a raster color for line drawing
18  * D_color (cat, colors)
19  * CELL cat
20  * struct Colors *colors; /color info/
21  *
22  * D_color_of_type(raster, colors, data_type);
23  * void *raster;
24  * struct Colors *colors; /color info/
25  * RASTER_MAP_TYPE data_type;
26  *
27  * Note: the same Colors structure must be passed to all routines.
28  *
29  */
30 #include <stdlib.h>
31 #include <grass/gis.h>
32 #include <grass/display.h>
33 #include <grass/raster.h>
34 
35 int D__overlay_mode = 0; /* external for now, but to be fixed later */
36 
37 
51 {
52  D__overlay_mode = (n != 0);
53 
54  return 0;
55 }
56 
57 
58 /* this routine modifies the hardware colormap
59  * provided that we are not using fixed mode colors.
60  * For use by programs such as d.colors
61  *
62  * returns:
63  * 0 error - in fixed mode,
64  * or cat not in min:max color range
65  * 1 ok
66  */
67 
68 int D_color(CELL cat, struct Colors *colors)
69 {
70  return D_c_color(cat, colors);
71 }
72 
73 /* select color for line drawing */
74 int D_c_color(CELL cat, struct Colors *colors)
75 {
76  return D_color_of_type(&cat, colors, CELL_TYPE);
77 }
78 
79 /* select color for line drawing */
80 
93 int D_d_color(DCELL val, struct Colors *colors)
94 {
95  return D_color_of_type(&val, colors, DCELL_TYPE);
96 }
97 
98 /* select color for line drawing */
99 
112 int D_f_color(FCELL val, struct Colors *colors)
113 {
114  return D_color_of_type(&val, colors, FCELL_TYPE);
115 }
116 
117 
134 int D_color_of_type(const void *raster,
135  struct Colors *colors, RASTER_MAP_TYPE data_type)
136 {
137  int r, g, b;
138 
139  G_get_raster_color(raster, &r, &g, &b, colors, data_type);
140  R_RGB_color((unsigned char)r, (unsigned char)g, (unsigned char)b);
141 
142  return 0;
143 }
int D_c_color(CELL cat, struct Colors *colors)
Definition: raster2.c:74
float b
Definition: named_colr.c:8
int D_color_of_type(const void *raster, struct Colors *colors, RASTER_MAP_TYPE data_type)
If the data_type is CELL_TYPE, calls D_color((CELL *value, colors); If the data_type is FCELL_TYPE...
Definition: raster2.c:134
float r
Definition: named_colr.c:8
int G_get_raster_color(const void *rast, int *red, int *grn, int *blu, struct Colors *colors, RASTER_MAP_TYPE map_type)
Gets color from raster.
Definition: color_get.c:67
int D_f_color(FCELL val, struct Colors *colors)
Same functionality as D_color() except that the value is type FCELL. This implies that the floating-p...
Definition: raster2.c:112
int D_set_overlay_mode(int n)
configure raster overlay mode
Definition: raster2.c:50
float g
Definition: named_colr.c:8
int D_d_color(DCELL val, struct Colors *colors)
Same functionality as D_color() except that the value is type DCELL. This implies that the floating-p...
Definition: raster2.c:93
int D_color(CELL cat, struct Colors *colors)
Definition: raster2.c:68
int D__overlay_mode
Definition: raster2.c:35
CELL cat
Definition: g3dcats.c:90
void R_RGB_color(unsigned char red, unsigned char grn, unsigned char blu)
select color
Definition: com_proto.c:109
int n
Definition: dataquad.c:291