1 /* 2 * Grace - GRaphing, Advanced Computation and Exploration of data 3 * 4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/ 5 * 6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR 7 * Copyright (c) 1996-2000 Grace Development Team 8 * 9 * Maintained by Evgeny Stambulchik 10 * 11 * 12 * All Rights Reserved 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License as published by 16 * the Free Software Foundation; either version 2 of the License, or 17 * (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 */ 28 29 /* 30 * 31 * declarations for devices 32 * 33 */ 34 #ifndef __DEVICE_H_ 35 #define __DEVICE_H_ 36 37 #include "t1fonts.h" 38 39 /* default dimensions of the canvas */ 40 #define DEFAULT_PAGE_WIDTH 600 41 #define DEFAULT_PAGE_HEIGHT 600 42 43 #define MM_PER_INCH 25.4 44 #define CM_PER_INCH (MM_PER_INCH/10) 45 46 /* hardcopy or terminal device */ 47 /* device output can be redirected to file/printer(both) */ 48 #define DEVICE_TERM 0 49 #define DEVICE_FILE 1 50 #define DEVICE_PRINT 2 51 52 /* Page orientation */ 53 #define PAGE_ORIENT_LANDSCAPE 0 54 #define PAGE_ORIENT_PORTRAIT 1 55 56 /* Standard formats */ 57 typedef enum { 58 PAGE_FORMAT_CUSTOM, 59 PAGE_FORMAT_USLETTER, 60 PAGE_FORMAT_A4 61 } PageFormat; 62 63 typedef struct { 64 unsigned long width; 65 unsigned long height; 66 float dpi; 67 } Page_geometry; 68 69 typedef struct { 70 int type; 71 char *name; /* name of device */ 72 int (*init)(void); /* function to initialize device */ 73 int (*parser)(char *); /* function to parse device-specific commands */ 74 void (*setup)(void); /* function (GUI interface) to setup device */ 75 char *fext; /* filename extension */ 76 int devfonts; /* device has its own fonts */ 77 int fontaa; /* font antialiasing */ 78 Page_geometry pg; /* device defaults */ 79 void *data; /* device private data */ 80 } Device_entry; 81 82 /* device exit */ 83 extern void (*devleavegraphics) (void); 84 85 /* device pixel routine */ 86 extern void (*devdrawpixel) (VPoint vp); 87 /* device polyline routine */ 88 extern void (*devdrawpolyline) (VPoint *vps, int n, int mode); 89 /* device polygon routine */ 90 extern void (*devfillpolygon) (VPoint *vps, int nc); 91 /* device arc routine */ 92 extern void (*devdrawarc) (VPoint vp1, VPoint vp2, int a1, int a2); 93 /* device fill arc routine */ 94 extern void (*devfillarc) (VPoint vp1, VPoint vp2, int a1, int a2, int mode); 95 /* device pixmap drawing */ 96 extern void (*devputpixmap) (VPoint vp, int width, int height, char *databits, 97 int pixmap_bpp, int bitmap_pad, int pixmap_type); 98 /* device text typesetting */ 99 extern void (*devputtext) (VPoint vp, char *s, int len, int font, 100 TextMatrix *tm, int underline, int overline, int kerning); 101 102 /* update color map */ 103 extern void (*devupdatecmap)(void); 104 105 106 int register_device(Device_entry device); 107 int select_device(int dindex); 108 int initgraphics (void); 109 110 Device_entry get_device_props(int device); 111 Device_entry get_curdevice_props(void); 112 113 char *get_device_name(int device); 114 115 void *get_curdevice_data(void); 116 void set_curdevice_data(void *data); 117 118 int set_device_props(int device, Device_entry dev); 119 void set_curdevice_props(Device_entry dev); 120 121 int is_valid_page_geometry(Page_geometry pg); 122 int set_page_geometry(Page_geometry pg); 123 Page_geometry get_page_geometry(void); 124 125 int set_page_dimensions(int wpp, int hpp, int rescale); 126 int get_device_page_dimensions(int dindex, int *wpp, int *hpp); 127 128 int get_device_by_name(char *dname); 129 130 int parse_device_options(int dindex, char *options); 131 132 int set_printer(int device); 133 int set_printer_by_name(char *dname); 134 void set_ptofile(int flag); 135 int get_ptofile(void); 136 137 int number_of_devices(void); 138 139 void get_page_viewport(double *vx, double *vy); 140 141 int terminal_device(void); 142 143 PageFormat get_page_format(int device); 144 145 /* some useful macros */ 146 #define page_dpi ((get_page_geometry()).dpi) 147 148 #define page_width ((get_page_geometry()).width) 149 #define page_height ((get_page_geometry()).height) 150 151 #define page_width_in ((double) page_width/page_dpi) 152 #define page_height_in ((double) page_height/page_dpi) 153 154 #define page_width_mm (MM_PER_INCH*page_width_in) 155 #define page_height_mm (MM_PER_INCH*page_height_in) 156 157 #define page_width_cm (CM_PER_INCH*page_width_in) 158 #define page_height_cm (CM_PER_INCH*page_height_in) 159 160 #define page_width_pp (72*page_width_in) 161 #define page_height_pp (72*page_height_in) 162 163 #endif /* __DEVICE_H_ */ 164