GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /**************************************************************************** 00003 * 00004 * MODULE: driver 00005 * AUTHOR(S): Glynn Clements <glynn gclements.plus.com> (original contributor) 00006 * Huidae Cho <grass4u gmail.com> 00007 * PURPOSE: 00008 * COPYRIGHT: (C) 2006-2006 by the GRASS Development Team 00009 * 00010 * This program is free software under the GNU General Public 00011 * License (>=v2). Read the file COPYING that comes with GRASS 00012 * for details. 00013 * 00014 *****************************************************************************/ 00015 #include <grass/config.h> 00016 00017 #include <stdio.h> 00018 #include <stdlib.h> 00019 00020 #include <grass/gis.h> 00021 #include <grass/freetypecap.h> 00022 #include "driverlib.h" 00023 #include "driver.h" 00024 #include "pad.h" 00025 00026 const struct driver *driver; 00027 00028 struct GFONT_CAP *ftcap; 00029 00030 int NCOLORS; 00031 00032 int screen_left; 00033 int screen_right; 00034 int screen_bottom; 00035 int screen_top; 00036 00037 int cur_x; 00038 int cur_y; 00039 00040 double text_size_x; 00041 double text_size_y; 00042 double text_rotation; 00043 00044 int mouse_button[3] = { 1, 2, 3 }; 00045 00046 int LIB_init(const struct driver *drv, int argc, char **argv) 00047 { 00048 const char *p; 00049 00050 driver = drv; 00051 ftcap = parse_freetypecap(); 00052 00053 /* initialize graphics */ 00054 00055 p = getenv("GRASS_WIDTH"); 00056 screen_left = 0; 00057 screen_right = (p && atoi(p)) ? atoi(p) : DEF_WIDTH; 00058 00059 p = getenv("GRASS_HEIGHT"); 00060 screen_top = 0; 00061 screen_bottom = (p && atoi(p)) ? atoi(p) : DEF_HEIGHT; 00062 00063 /* read mouse button setting */ 00064 if ((p = getenv("GRASS_MOUSE_BUTTON"))) { 00065 int i; 00066 00067 for (i = 0; i < 3 && p[i]; i++) { 00068 if (p[i] < '1' || p[i] > '3') 00069 break; 00070 } 00071 if (i == 3 && p[0] != p[1] && p[1] != p[2] && p[0] != p[2]) { 00072 for (i = 0; i < 3; i++) 00073 mouse_button[i] = p[i] - '0'; 00074 } 00075 } 00076 00077 if (COM_Graph_set(argc, argv) < 0) 00078 exit(1); 00079 00080 /* initialize the pads */ 00081 create_pad(""); /* scratch pad */ 00082 00083 return 0; 00084 }