1 /*****************************************************************************
2 ** Copyright (C) 1998-2001 Ljubomir Milanovic & Horst Wagner
3 ** This file is part of the g2 library
4 **
5 ** This library is free software; you can redistribute it and/or
6 ** modify it under the terms of the GNU Lesser General Public
7 ** License as published by the Free Software Foundation; either
8 ** version 2.1 of the License, or (at your option) any later version.
9 **
10 ** This library is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ** Lesser General Public License for more details.
14 **
15 ** You should have received a copy of the GNU Lesser General Public
16 ** License along with this library; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ******************************************************************************/
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include "g2_physical_device.h"
22 #include "g2_funix.h"
23 #include "g2_util.h"
24
25
g2_create_physical_device(int pid,void * pdp,g2_coor ct,const g2_funix_fun * ff,double a11,double a22,double b1,double b2)26 g2_physical_device *g2_create_physical_device(int pid,
27 void *pdp,
28 g2_coor ct,
29 const g2_funix_fun *ff,
30 double a11, double a22,
31 double b1, double b2)
32 {
33 g2_physical_device *rd;
34 int i, j;
35
36 rd=g2_malloc(sizeof(g2_physical_device));
37
38 rd->pid=pid; /* physical device id (handled by driver) */
39 rd->pdp=pdp; /* pointer to something */
40 rd->coor_type=ct; /* coord. type */
41 rd->a11=a11; /* device->physical device transformation */
42 rd->a22=a22;
43 rd->b1=b1;
44 rd->b2=b2;
45
46 rd->x_origin=0.0; /* User coordinates specification */
47 rd->y_origin=0.0;
48 rd->x_mul=1.0;
49 rd->y_mul=1.0;
50
51 rd->ff=g2_malloc(G2_N_FUNIX*sizeof(g2_funix_fun));
52
53 for(i=0;i<G2_N_FUNIX;i++) {
54 rd->ff[i].fx=i;
55 rd->ff[i].fun=NULL;
56 for(j=0;ff[j].fx!=g2_FUNIX_NULL;j++)
57 if(ff[j].fx==i) {
58 rd->ff[i].fun = ff[j].fun;
59 break;
60 }
61 }
62
63 return rd;
64 }
65
66
67 /*
68 *
69 * Destroy physical device
70 *
71 */
g2_destroy_physical_device(g2_physical_device * pd)72 void g2_destroy_physical_device(g2_physical_device *pd)
73 {
74 g2_free(pd->ff);
75 g2_free(pd);
76 }
77
78
79