1 /* libwmf ("ipa/plot/device.h"): library for wmf conversion
2 Copyright (C) 2000 - various; see CREDITS, ChangeLog, and sources
3
4 The libwmf Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The libwmf Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the libwmf Library; see the file COPYING. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19
20 /* This is called by wmf_play() the *first* time the meta file is played
21 */
wmf_plot_device_open(wmfAPI * API)22 static void wmf_plot_device_open (wmfAPI* API)
23 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
24
25 /* plot_t* plot = (plot_t*) ddata->plot_data; */
26
27 WMF_DEBUG (API,"wmf_[plot_]device_open");
28
29
30 }
31
32 /* This is called by wmf_api_destroy()
33 */
wmf_plot_device_close(wmfAPI * API)34 static void wmf_plot_device_close (wmfAPI* API)
35 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
36
37 plot_t* plot = (plot_t*) ddata->plot_data;
38
39 WMF_DEBUG (API,"wmf_[plot_]device_close");
40
41 /* */
42
43 if (plot)
44 { if (plot->params) pl_deleteplparams (plot->params);
45 }
46 }
47
48 /* This is called from the beginning of each play for initial page setup
49 */
wmf_plot_device_begin(wmfAPI * API)50 static void wmf_plot_device_begin (wmfAPI* API)
51 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
52
53 plot_t* plot = (plot_t*) ddata->plot_data;
54
55 WMF_DEBUG (API,"wmf_[plot_]device_begin");
56
57
58 }
59
60 /* This is called from the end of each play for page termination
61 */
wmf_plot_device_end(wmfAPI * API)62 static void wmf_plot_device_end (wmfAPI* API)
63 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
64
65 plot_t* plot = (plot_t*) ddata->plot_data;
66
67 WMF_DEBUG (API,"wmf_[plot_]device_end");
68
69
70 }
71
plot_translate(wmfAPI * API,wmfD_Coord d_pt)72 static plotPoint plot_translate (wmfAPI* API,wmfD_Coord d_pt)
73 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
74
75 plotPoint g_pt;
76
77 double x;
78 double y;
79
80 x = ((double) d_pt.x - (double) ddata->bbox.TL.x);
81 x /= ((double) ddata->bbox.BR.x - (double) ddata->bbox.TL.x);
82 x *= (double) ddata->width;
83
84 y = ((double) d_pt.y - (double) ddata->bbox.TL.y);
85 y /= ((double) ddata->bbox.BR.y - (double) ddata->bbox.TL.y);
86 y *= (double) ddata->height;
87
88 g_pt.x = (int) floor (x);
89 g_pt.y = (int) floor (y);
90
91 return (g_pt);
92 }
93
plot_width(wmfAPI * API,float wmf_width)94 static float plot_width (wmfAPI* API,float wmf_width)
95 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
96
97 double width;
98
99 width = (double) wmf_width * (double) ddata->width;
100 width /= ((double) ddata->bbox.BR.x - (double) ddata->bbox.TL.x);
101
102 return ((float) width);
103 }
104
plot_height(wmfAPI * API,float wmf_height)105 static float plot_height (wmfAPI* API,float wmf_height)
106 { wmf_plot_t* ddata = WMF_PLOT_GetData (API);
107
108 double height;
109
110 height = (double) wmf_height * (double) ddata->height;
111 height /= ((double) ddata->bbox.BR.y - (double) ddata->bbox.TL.y);
112
113 return ((float) height);
114 }
115