GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 #include <grass/config.h> 00003 00004 #include <errno.h> 00005 #include <signal.h> 00006 #include <stdio.h> 00007 #include <stdlib.h> 00008 #include <string.h> 00009 #include <unistd.h> 00010 00011 #include <grass/gis.h> 00012 #include <grass/glocale.h> 00013 #include <grass/raster.h> 00014 #include <grass/graphics.h> 00015 00016 #include "driver.h" 00017 #include "transport.h" 00018 #include "open.h" 00019 #include "pad.h" 00020 00021 extern const struct driver *PNG_Driver(void); 00022 extern const struct driver *PS_Driver(void); 00023 00024 static void LOC_init(void) 00025 { 00026 const char *name = "full_screen"; 00027 const char *fenc = getenv("GRASS_ENCODING"); 00028 const char *font = getenv("GRASS_FONT"); 00029 int t = R_screen_top(); 00030 int b = R_screen_bot(); 00031 int l = R_screen_left(); 00032 int r = R_screen_rite(); 00033 char buff[256]; 00034 00035 R_font(font ? font : "romans"); 00036 00037 if (fenc) 00038 R_charset(fenc); 00039 00040 R_pad_select(""); 00041 R_pad_set_item("time", "1"); 00042 R_pad_set_item("cur_w", name); 00043 00044 R_pad_create(name); 00045 R_pad_select(name); 00046 R_pad_set_item("time", "1"); 00047 00048 sprintf(buff, "%d %d %d %d", t, b, l, r); 00049 R_pad_set_item("d_win", buff); 00050 00051 R_set_window(t, b, l, r); 00052 } 00053 00054 int LOC_open_driver(void) 00055 { 00056 const char *p = getenv("GRASS_RENDER_IMMEDIATE"); 00057 const struct driver *drv = (p && G_strcasecmp(p, "PS") == 0) 00058 ? PS_Driver() 00059 : PNG_Driver(); 00060 00061 LIB_init(drv, 0, NULL); 00062 00063 LOC_init(); 00064 00065 COM_Client_Open(); 00066 00067 return OK; 00068 } 00069 00070 int LOC__open_quiet(void) 00071 { 00072 return 0; 00073 } 00074 00075 void LOC_stabilize(void) 00076 { 00077 COM_Respond(); 00078 } 00079 00080 void LOC_kill_driver(void) 00081 { 00082 COM_Graph_close(); 00083 } 00084 00085 void LOC_close_driver(void) 00086 { 00087 LOC_stabilize(); 00088 COM_Client_Close(); 00089 LOC_kill_driver(); 00090 } 00091 00092 void LOC_release_driver(void) 00093 { 00094 LOC_stabilize(); 00095 COM_Client_Close(); 00096 }