GRASS Programmer's Manual  6.4.2(2012)
rem_proto.c
Go to the documentation of this file.
00001 #include <grass/config.h>
00002 
00003 #ifdef HAVE_SOCKET
00004 
00005 #include <stdio.h>
00006 #include <string.h>
00007 
00008 #include <sys/types.h>
00009 #include <sys/stat.h>
00010 #include <fcntl.h>
00011 #include <unistd.h>
00012 
00013 #include <grass/gis.h>
00014 #include <grass/raster.h>
00015 #include <grass/graphics.h>
00016 
00017 #include "transport.h"
00018 
00028 int REM_screen_left(void)
00029 {
00030     int l;
00031 
00032     _send_ident(SCREEN_LEFT);
00033     _get_int(&l);
00034     return l;
00035 }
00036 
00046 int REM_screen_rite(void)
00047 {
00048     int r;
00049 
00050     _send_ident(SCREEN_RITE);
00051     _get_int(&r);
00052     return r;
00053 }
00054 
00055 
00065 int REM_screen_bot(void)
00066 {
00067     int b;
00068 
00069     _send_ident(SCREEN_BOT);
00070     _get_int(&b);
00071     return b;
00072 }
00073 
00074 
00084 int REM_screen_top(void)
00085 {
00086     int t;
00087 
00088     _send_ident(SCREEN_TOP);
00089     _get_int(&t);
00090     return t;
00091 }
00092 
00093 void REM_get_num_colors(int *n)
00094 {
00095     _send_ident(GET_NUM_COLORS);
00096     _get_int(n);
00097 }
00098 
00110 void REM_standard_color(int index)
00111 {
00112     _send_ident(STANDARD_COLOR);
00113     _send_int(&index);
00114 }
00115 
00129 void REM_RGB_color(unsigned char red, unsigned char grn, unsigned char blu)
00130 {
00131     _send_ident(RGB_COLOR);
00132     _send_char(&red);
00133     _send_char(&grn);
00134     _send_char(&blu);
00135 }
00136 
00145 void REM_line_width(int width)
00146 {
00147     _send_ident(LINE_WIDTH);
00148     _send_int(&width);
00149 }
00150 
00159 void REM_erase(void)
00160 {
00161     _send_ident(ERASE);
00162 }
00163 
00174 void REM_move_abs(int x, int y)
00175 {
00176     _send_ident(MOVE_ABS);
00177     _send_int(&x);
00178     _send_int(&y);
00179 }
00180 
00195 void REM_move_rel(int x, int y)
00196 {
00197     _send_ident(MOVE_REL);
00198     _send_int(&x);
00199     _send_int(&y);
00200 }
00201 
00213 void REM_cont_abs(int x, int y)
00214 {
00215     _send_ident(CONT_ABS);
00216     _send_int(&x);
00217     _send_int(&y);
00218 }
00219 
00236 void REM_cont_rel(int x, int y)
00237 {
00238     _send_ident(CONT_REL);
00239     _send_int(&x);
00240     _send_int(&y);
00241 }
00242 
00255 void REM_polydots_abs(const int *xarray, const int *yarray, int number)
00256 {
00257     _send_ident(POLYDOTS_ABS);
00258     _send_int(&number);
00259     _send_int_array(number, xarray);
00260     _send_int_array(number, yarray);
00261 }
00262 
00277 void REM_polydots_rel(const int *xarray, const int *yarray, int number)
00278 {
00279     _send_ident(POLYDOTS_REL);
00280     _send_int(&number);
00281     _send_int_array(number, xarray);
00282     _send_int_array(number, yarray);
00283 }
00284 
00300 void REM_polyline_abs(const int *xarray, const int *yarray, int number)
00301 {
00302     _send_ident(POLYLINE_ABS);
00303     _send_int(&number);
00304     _send_int_array(number, xarray);
00305     _send_int_array(number, yarray);
00306 }
00307 
00324 void REM_polyline_rel(const int *xarray, const int *yarray, int number)
00325 {
00326     _send_ident(POLYLINE_REL);
00327     _send_int(&number);
00328     _send_int_array(number, xarray);
00329     _send_int_array(number, yarray);
00330 }
00331 
00344 void REM_polygon_abs(const int *xarray, const int *yarray, int number)
00345 {
00346     _send_ident(POLYGON_ABS);
00347     _send_int(&number);
00348     _send_int_array(number, xarray);
00349     _send_int_array(number, yarray);
00350 }
00351 
00366 void REM_polygon_rel(const int *xarray, const int *yarray, int number)
00367 {
00368     _send_ident(POLYGON_REL);
00369     _send_int(&number);
00370     _send_int_array(number, xarray);
00371     _send_int_array(number, yarray);
00372 }
00373 
00387 void REM_box_abs(int x1, int y1, int x2, int y2)
00388 {
00389     _send_ident(BOX_ABS);
00390     _send_int(&x1);
00391     _send_int(&y1);
00392     _send_int(&x2);
00393     _send_int(&y2);
00394 }
00395 
00396 
00408 void REM_box_rel(int x, int y)
00409 {
00410     _send_ident(BOX_REL);
00411     _send_int(&x);
00412     _send_int(&y);
00413 }
00414 
00424 void REM_text_size(int width, int height)
00425 {
00426     _send_ident(TEXT_SIZE);
00427     _send_int(&width);
00428     _send_int(&height);
00429 }
00430 
00431 void REM_text_rotation(float rotation)
00432 {
00433     _send_ident(TEXT_ROTATION);
00434     _send_float(&rotation);
00435 }
00436 
00449 void REM_set_window(int t, int b, int l, int r)
00450 {
00451     _send_ident(SET_WINDOW);
00452     _send_int(&t);
00453     _send_int(&b);
00454     _send_int(&l);
00455     _send_int(&r);
00456 }
00457 
00467 void REM_text(const char *sometext)
00468 {
00469     _send_ident(TEXT);
00470     _send_text(sometext);
00471 }
00472 
00489 void REM_get_text_box(const char *sometext, int *t, int *b, int *l, int *r)
00490 {
00491     _send_ident(GET_TEXT_BOX);
00492     _send_text(sometext);
00493     _get_int(t);
00494     _get_int(b);
00495     _get_int(l);
00496     _get_int(r);
00497 }
00498 
00530 void REM_font(const char *name)
00531 {
00532     _send_ident(FONT);
00533     _send_text(name);
00534 }
00535 
00536 void REM_charset(const char *name)
00537 {
00538     _send_ident(CHARSET);
00539     _send_text(name);
00540 }
00541 
00542 static void font_list(char ***list, int *count, int op)
00543 {
00544     char **fonts;
00545     int num_fonts;
00546     int i;
00547 
00548     _send_ident(op);
00549     _get_int(&num_fonts);
00550 
00551     fonts = G_malloc(num_fonts * sizeof(char *));
00552     for (i = 0; i < num_fonts; i++)
00553         fonts[i] = G_store(_get_text_2());
00554 
00555     *list = fonts;
00556     *count = num_fonts;
00557 }
00558 
00559 void REM_font_list(char ***list, int *count)
00560 {
00561     font_list(list, count, FONT_LIST);
00562 }
00563 
00564 void REM_font_info(char ***list, int *count)
00565 {
00566     font_list(list, count, FONT_INFO);
00567 }
00568 
00569 void REM_panel_save(const char *name, int t, int b, int l, int r)
00570 {
00571     close(creat(name, 0666));
00572 
00573     _send_ident(PANEL_SAVE);
00574     _send_text(name);
00575     _send_int(&t);
00576     _send_int(&b);
00577     _send_int(&l);
00578     _send_int(&r);
00579     R_stabilize();
00580 }
00581 
00582 void REM_panel_restore(const char *name)
00583 {
00584     _send_ident(PANEL_RESTORE);
00585     _send_text(name);
00586     R_stabilize();
00587 }
00588 
00589 void REM_panel_delete(const char *name)
00590 {
00591     _send_ident(PANEL_DELETE);
00592     _send_text(name);
00593     R_stabilize();
00594 
00595     unlink(name);
00596 }
00597 
00598 void REM_begin_scaled_raster(int mask, int src[2][2], int dst[2][2])
00599 {
00600     _send_ident(BEGIN_SCALED_RASTER);
00601     _send_int(&mask);
00602     _send_int_array(4, &src[0][0]);
00603     _send_int_array(4, &dst[0][0]);
00604 }
00605 
00606 int REM_scaled_raster(int n, int row,
00607                       const unsigned char *red, const unsigned char *grn,
00608                       const unsigned char *blu, const unsigned char *nul)
00609 {
00610     int z = !!nul;
00611     int t;
00612 
00613     _send_ident(SCALED_RASTER);
00614     _send_int(&n);
00615     _send_int(&row);
00616     _send_char_array(n, red);
00617     _send_char_array(n, grn);
00618     _send_char_array(n, blu);
00619     _send_char_array(n, nul ? nul : red);
00620     _send_int(&z);
00621     _get_int(&t);
00622     return t;
00623 }
00624 
00625 void REM_end_scaled_raster(void)
00626 {
00627     _send_ident(END_SCALED_RASTER);
00628 }
00629 
00630 void REM_bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
00631 {
00632     _send_ident(BITMAP);
00633     _send_int(&ncols);
00634     _send_int(&nrows);
00635     _send_int(&threshold);
00636     _send_char_array(ncols * nrows, buf);
00637 }
00638 
00639 #endif /* HAVE_SOCKET */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines