GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
com_io.c
Go to the documentation of this file.
1 
2 #include <grass/config.h>
3 
4 #include <errno.h>
5 #include <signal.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 
11 #include <grass/gis.h>
12 #include <grass/glocale.h>
13 #include <grass/raster.h>
14 #include <grass/graphics.h>
15 
16 #include "driver.h"
17 #include "transport.h"
18 
19 struct transport loc_trans = {
34  LOC_erase,
50  LOC_text,
52  LOC_font,
62  LOC_bitmap,
77 };
78 
79 #ifdef HAVE_SOCKET
80 
81 struct transport rem_trans = {
96  REM_erase,
100  REM_cont_rel,
107  REM_box_abs,
108  REM_box_rel,
112  REM_text,
114  REM_font,
115  REM_charset,
124  REM_bitmap,
132  REM_pad_list,
139 };
140 
141 #endif
142 
143 const struct transport *trans;
144 
145 static const struct transport *get_trans(void)
146 {
147 #ifndef HAVE_SOCKET
148  return &loc_trans;
149 #else
150  const char *p = getenv("GRASS_RENDER_IMMEDIATE");
151 
152  if (!p)
153  return &rem_trans;
154 
155  if (G_strcasecmp(p, "TRUE") == 0)
156  return &loc_trans;
157 
158  if (G_strcasecmp(p, "FALSE") == 0)
159  return &rem_trans;
160 
161  if (G_strcasecmp(p, "PNG") == 0)
162  return &loc_trans;
163 
164  if (G_strcasecmp(p, "PS") == 0)
165  return &loc_trans;
166 
167  G_warning("Unrecognised GRASS_RENDER_IMMEDIATE setting: %s", p);
168 
169  return &rem_trans;
170 #endif
171 }
172 
173 static void init_transport(void)
174 {
175  if (trans)
176  return;
177 
178  trans = get_trans();
179 }
180 
181 int R_open_driver(void)
182 {
183  init_transport();
184  return trans->open_driver();
185 }
186 
187 void R__open_quiet(void)
188 {
189  init_transport();
190  trans->open_quiet();
191 }
192 
193 void R_stabilize(void)
194 {
195  trans->stabilize();
196 }
197 
198 void R_kill_driver(void)
199 {
200  trans->kill_driver();
201 }
202 
203 void R_close_driver(void)
204 {
205  trans->close_driver();
206 }
207 
209 {
210  trans->release_driver();
211 }
int LOC_open_driver(void)
Definition: loc_io.c:54
int R_open_driver(void)
Definition: com_io.c:181
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
Definition: strings.c:192
void REM_standard_color(int index)
void LOC_stabilize(void)
Definition: loc_io.c:75
void REM_set_window(int t, int b, int l, int r)
void REM_polygon_abs(const int *xarray, const int *yarray, int number)
int LOC_screen_rite(void)
screen right edge
Definition: loc_proto.c:43
int REM_screen_left(void)
void R_release_driver(void)
Definition: com_io.c:208
void LOC_polygon_abs(const int *xarray, const int *yarray, int number)
draw a closed polygon
Definition: loc_proto.c:327
void LOC_panel_delete(const char *name)
Definition: loc_proto.c:530
int REM__open_quiet(void)
void LOC_panel_save(const char *name, int t, int b, int l, int r)
Definition: loc_proto.c:516
void REM_polyline_rel(const int *xarray, const int *yarray, int number)
int REM_screen_top(void)
void LOC_cont_abs(int x, int y)
draw line
Definition: loc_proto.c:206
void LOC_charset(const char *name)
Definition: loc_proto.c:501
int LOC_pad_current(char *name)
Definition: loc_pad.c:35
int REM_screen_bot(void)
void R_stabilize(void)
Definition: com_io.c:193
void REM_get_location_with_pointer(int *wx, int *wy, int *button)
void LOC_move_rel(int x, int y)
move current location
Definition: loc_proto.c:189
void LOC_font_info(char ***list, int *count)
Definition: loc_proto.c:511
void REM_get_num_colors(int *n)
void REM_line_width(int width)
struct transport * trans
Definition: com_io.c:143
int LOC_pad_delete(void)
Definition: loc_pad.c:47
void REM_font(const char *name)
void LOC_release_driver(void)
Definition: loc_io.c:92
void REM_text(const char *text)
void REM_cont_rel(int x, int y)
int REM_pad_delete_item(const char *name)
void REM_panel_restore(const char *name)
void LOC_polydots_rel(const int *xarray, const int *yarray, int number)
draw a series of dots
Definition: loc_proto.c:266
struct transport loc_trans
Definition: com_io.c:19
void REM_move_rel(int x, int y)
void R_close_driver(void)
Definition: com_io.c:203
void LOC_polyline_rel(const int *xarray, const int *yarray, int number)
draw an open polygon
Definition: loc_proto.c:309
void REM_font_info(char ***list, int *count)
void REM_font_list(char ***list, int *count)
int REM_pad_set_item(const char *name, const char *value)
void LOC_box_rel(int x, int y)
fill a box
Definition: loc_proto.c:384
void REM_get_location_with_box(int cx, int cy, int *wx, int *wy, int *button)
void LOC_standard_color(int index)
select standard color
Definition: loc_proto.c:106
void LOC_line_width(int width)
change the width of line
Definition: loc_proto.c:139
void REM_polyline_abs(const int *xarray, const int *yarray, int number)
void R_kill_driver(void)
Definition: com_io.c:198
void REM_RGB_color(unsigned char red, unsigned char grn, unsigned char blu)
int REM_pad_select(const char *pad)
void(* close_driver)(void)
Definition: transport.h:153
void REM_begin_scaled_raster(int mask, int src[2][2], int dst[2][2])
int LOC_pad_delete_item(const char *name)
Definition: loc_pad.c:108
void(* release_driver)(void)
Definition: transport.h:154
void LOC_get_location_with_pointer(int *wx, int *wy, int *button)
Definition: loc_get.c:16
void REM_cont_abs(int x, int y)
char * getenv()
void REM_get_location_with_line(int cx, int cy, int *wx, int *wy, int *button)
int LOC_screen_left(void)
screen left edge
Definition: loc_proto.c:25
void REM_panel_delete(const char *name)
int LOC_screen_bot(void)
bottom of screen
Definition: loc_proto.c:61
void REM_text_size(int width, int height)
void LOC_get_text_box(const char *text, int *t, int *b, int *l, int *r)
get text extents
Definition: loc_proto.c:459
void LOC_end_scaled_raster(void)
Definition: loc_proto.c:550
void LOC_polydots_abs(const int *xarray, const int *yarray, int number)
draw a series of dots
Definition: loc_proto.c:246
void LOC_panel_restore(const char *name)
Definition: loc_proto.c:524
void LOC_begin_scaled_raster(int mask, int src[2][2], int dst[2][2])
Definition: loc_proto.c:538
int LOC_pad_set_item(const char *name, const char *value)
Definition: loc_pad.c:167
void LOC_get_location_with_line(int cx, int cy, int *wx, int *wy, int *button)
Definition: loc_get.c:12
void REM_move_abs(int x, int y)
void REM_close_driver(void)
void LOC_move_abs(int x, int y)
move current location
Definition: loc_proto.c:169
void REM_bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
int REM_pad_get_item(const char *name, char ***list, int *count)
void LOC_polygon_rel(const int *xarray, const int *yarray, int number)
draw a closed polygon
Definition: loc_proto.c:347
void R__open_quiet(void)
Definition: com_io.c:187
void REM_box_rel(int x, int y)
int REM_screen_rite(void)
int LOC_pad_select(const char *pad)
Definition: loc_pad.c:87
int(* open_driver)(void)
Definition: transport.h:149
void LOC_get_num_colors(int *n)
Definition: loc_proto.c:89
int LOC_pad_list_items(char ***list, int *count)
Definition: loc_pad.c:145
int LOC_pad_get_item(const char *name, char ***list, int *count)
Definition: loc_pad.c:117
int LOC_pad_list(char ***list, int *count)
Definition: loc_pad.c:67
void REM_box_abs(int x1, int y1, int x2, int y2)
int REM_open_driver(void)
void LOC_font(const char *name)
choose font
Definition: loc_proto.c:496
void LOC_set_window(int t, int b, int l, int r)
set text clipping frame
Definition: loc_proto.c:422
void LOC_cont_rel(int x, int y)
draw line
Definition: loc_proto.c:228
int REM_pad_invent(char *pad)
int(* open_quiet)(void)
Definition: transport.h:150
int LOC_pad_append_item(const char *item, const char *value, int replace)
Definition: loc_pad.c:97
void REM_polydots_abs(const int *xarray, const int *yarray, int number)
void LOC_text_size(int width, int height)
set text size
Definition: loc_proto.c:399
void REM_charset(const char *name)
int LOC_screen_top(void)
top of screen
Definition: loc_proto.c:80
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int REM_pad_delete(void)
int REM_pad_list_items(char ***list, int *count)
void LOC_erase(void)
erase screen
Definition: loc_proto.c:153
int LOC_pad_invent(char *pad)
Definition: loc_pad.c:60
void(* kill_driver)(void)
Definition: transport.h:152
void LOC_font_list(char ***list, int *count)
Definition: loc_proto.c:506
int REM_pad_current(char *name)
void REM_polygon_rel(const int *xarray, const int *yarray, int number)
void REM_kill_driver(void)
void(* stabilize)(void)
Definition: transport.h:151
void REM_end_scaled_raster(void)
void REM_text_rotation(float rotation)
void LOC_bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
Definition: loc_proto.c:555
void LOC_kill_driver(void)
Definition: loc_io.c:80
void REM_polydots_rel(const int *xarray, const int *yarray, int number)
int LOC_scaled_raster(int n, int row, const unsigned char *red, const unsigned char *grn, const unsigned char *blu, const unsigned char *nul)
Definition: loc_proto.c:543
void LOC_text(const char *text)
write text
Definition: loc_proto.c:437
void LOC_get_location_with_box(int cx, int cy, int *wx, int *wy, int *button)
Definition: loc_get.c:8
int REM_pad_list(char ***list, int *count)
void LOC_text_rotation(float rotation)
Definition: loc_proto.c:404
int REM_scaled_raster(int n, int row, const unsigned char *red, const unsigned char *grn, const unsigned char *blu, const unsigned char *nul)
void REM_stabilize(void)
int REM_pad_create(const char *pad)
int LOC_pad_create(const char *pad)
Definition: loc_pad.c:23
int LOC__open_quiet(void)
Definition: loc_io.c:70
void REM_get_text_box(const char *text, int *t, int *b, int *l, int *r)
int REM_pad_append_item(const char *item, const char *value, int replace)
void LOC_polyline_abs(const int *xarray, const int *yarray, int number)
draw an open polygon
Definition: loc_proto.c:287
void REM_release_driver(void)
void LOC_close_driver(void)
Definition: loc_io.c:85
void REM_erase(void)
void REM_panel_save(const char *name, int t, int b, int l, int r)
void LOC_box_abs(int x1, int y1, int x2, int y2)
fill a box
Definition: loc_proto.c:366
void LOC_RGB_color(unsigned char red, unsigned char grn, unsigned char blu)
select color
Definition: loc_proto.c:125