The R Project SVN R

Rev

Rev 27236 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27236 Rev 31242
1
/*
1
/*
2
 *  RProxy: Connector implementation between application and R language
2
 *  RProxy: Connector implementation between application and R language
3
 *  Copyright (C) 2000--2001 Thomas Baier
3
 *  Copyright (C) 2000--2001 Thomas Baier
4
 *
4
 *
5
 *  This library is free software; you can redistribute it and/or
5
 *  This library is free software; you can redistribute it and/or
6
 *  modify it under the terms of the GNU Library General Public
6
 *  modify it under the terms of the GNU Library General Public
7
 *  License as published by the Free Software Foundation; either
7
 *  License as published by the Free Software Foundation; either
8
 *  version 2 of the License, or (at your option) any later version.
8
 *  version 2 of the License, or (at your option) any later version.
9
 *
9
 *
10
 *  This library is distributed in the hope that it will be useful,
10
 *  This library is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 *  Library General Public License for more details.
13
 *  Library General Public License for more details.
14
 *
14
 *
15
 *  You should have received a copy of the GNU Library General Public
15
 *  You should have received a copy of the GNU Library General Public
16
 *  License along with this library; if not, write to the Free
16
 *  License along with this library; if not, write to the Free
17
 *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17
 *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18
 *  MA 02111-1307, USA
18
 *  MA 02111-1307, USA
19
 *
19
 *
20
 *  $Id: rproxy_dev.c,v 1.7 2003/11/26 20:50:15 murrell Exp $
20
 *  $Id: rproxy_dev.c,v 1.7 2003/11/26 20:50:15 murrell Exp $
21
 */
21
 */
22
 
22
 
23
/* virtual device size */
23
/* virtual device size */
24
#define DEV_X 500
24
#define DEV_X 500
25
#define DEV_Y 500
25
#define DEV_Y 500
26
 
26
 
27
#ifdef HAVE_CONFIG_H
27
#ifdef HAVE_CONFIG_H
28
#include <Rconfig.h>
28
#include <Rconfig.h>
29
#endif
29
#endif
30
 
30
 
31
#include "Defn.h"
31
#include <Defn.h>
32
#include "Graphics.h"
32
#include <Graphics.h>
-
 
33
#include <Rdevices.h>
33
#include <stdio.h>
34
#include <stdio.h>
34
#include <windows.h>
35
#include <windows.h>
35
 
36
 
36
#include "SC_proxy.h"
37
#include "SC_proxy.h"
37
 
38
 
38
extern SC_GraphicsDevice* __graphics_device;
39
extern SC_GraphicsDevice* __graphics_device;
39
 
40
 
40
static void R_Proxy_Graphics_Activate (NewDevDesc* pDD)
41
static void R_Proxy_Graphics_Activate (NewDevDesc* pDD)
41
{
42
{
42
  if (__graphics_device)
43
  if (__graphics_device)
43
    {
44
    {
44
      __graphics_device->vtbl->activate (__graphics_device);
45
      __graphics_device->vtbl->activate (__graphics_device);
45
      return;
46
      return;
46
    }
47
    }
47
}
48
}
48
 
49
 
49
#ifdef MessageBox
50
#ifdef MessageBox
50
#undef MessageBox
51
#undef MessageBox
51
#endif
52
#endif
52
#define MessageBox(a,b,c,d)
53
#define MessageBox(a,b,c,d)
53
 
54
 
54
static void R_Proxy_Graphics_Activate(NewDevDesc *dd);
55
static void R_Proxy_Graphics_Activate(NewDevDesc *dd);
55
static void R_Proxy_Graphics_Circle(double x, double y, double r,
56
static void R_Proxy_Graphics_Circle(double x, double y, double r,
56
				    R_GE_gcontext *gc,
57
				    R_GE_gcontext *gc,
57
				    NewDevDesc *dd);
58
				    NewDevDesc *dd);
58
static void R_Proxy_Graphics_Clip(double x0, double x1, double y0, double y1,
59
static void R_Proxy_Graphics_Clip(double x0, double x1, double y0, double y1,
59
		     NewDevDesc *dd);
60
		     NewDevDesc *dd);
60
static void R_Proxy_Graphics_Close(NewDevDesc *dd);
61
static void R_Proxy_Graphics_Close(NewDevDesc *dd);
61
static void R_Proxy_Graphics_Deactivate(NewDevDesc *dd);
62
static void R_Proxy_Graphics_Deactivate(NewDevDesc *dd);
62
static void R_Proxy_Graphics_Hold(NewDevDesc *dd);
63
static void R_Proxy_Graphics_Hold(NewDevDesc *dd);
63
static Rboolean R_Proxy_Graphics_Locator(double *x, double *y, NewDevDesc *dd);
64
static Rboolean R_Proxy_Graphics_Locator(double *x, double *y, NewDevDesc *dd);
64
static void R_Proxy_Graphics_Line(double x1, double y1, double x2, double y2,
65
static void R_Proxy_Graphics_Line(double x1, double y1, double x2, double y2,
65
				  R_GE_gcontext *gc,
66
				  R_GE_gcontext *gc,
66
				  NewDevDesc *dd);
67
				  NewDevDesc *dd);
67
static void R_Proxy_Graphics_MetricInfo(int c, 
68
static void R_Proxy_Graphics_MetricInfo(int c, 
68
					R_GE_gcontext *gc,
69
					R_GE_gcontext *gc,
69
					double* ascent, double* descent,
70
					double* ascent, double* descent,
70
					double* width, NewDevDesc *dd);
71
					double* width, NewDevDesc *dd);
71
static void R_Proxy_Graphics_Mode(int mode, NewDevDesc *dd);
72
static void R_Proxy_Graphics_Mode(int mode, NewDevDesc *dd);
72
static void R_Proxy_Graphics_NewPage(R_GE_gcontext *gc,
73
static void R_Proxy_Graphics_NewPage(R_GE_gcontext *gc,
73
				     NewDevDesc *dd);
74
				     NewDevDesc *dd);
74
static void R_Proxy_Graphics_Polygon(int n, double *x, double *y,
75
static void R_Proxy_Graphics_Polygon(int n, double *x, double *y,
75
				     R_GE_gcontext *gc,
76
				     R_GE_gcontext *gc,
76
				     NewDevDesc *dd);
77
				     NewDevDesc *dd);
77
static void R_Proxy_Graphics_Polyline(int n, double *x, double *y,
78
static void R_Proxy_Graphics_Polyline(int n, double *x, double *y,
78
				      R_GE_gcontext *gc,
79
				      R_GE_gcontext *gc,
79
				      NewDevDesc *dd);
80
				      NewDevDesc *dd);
80
static void R_Proxy_Graphics_Rect(double x0, double y0, double x1, double y1,
81
static void R_Proxy_Graphics_Rect(double x0, double y0, double x1, double y1,
81
				  R_GE_gcontext *gc,
82
				  R_GE_gcontext *gc,
82
				  NewDevDesc *dd);
83
				  NewDevDesc *dd);
83
static void R_Proxy_Graphics_Size(double *left, double *right,
84
static void R_Proxy_Graphics_Size(double *left, double *right,
84
				  double *bottom, double *top,
85
				  double *bottom, double *top,
85
				  NewDevDesc *dd);
86
				  NewDevDesc *dd);
86
#ifdef UNUSED
87
#ifdef UNUSED
87
static void R_Proxy_Graphics_Resize(NewDevDesc *dd);
88
static void R_Proxy_Graphics_Resize(NewDevDesc *dd);
88
#endif
89
#endif
89
static double R_Proxy_Graphics_StrWidth(char *str, 
90
static double R_Proxy_Graphics_StrWidth(char *str, 
90
					R_GE_gcontext *gc,
91
					R_GE_gcontext *gc,
91
					NewDevDesc *dd);
92
					NewDevDesc *dd);
92
static void R_Proxy_Graphics_Text(double x, double y, char *str,
93
static void R_Proxy_Graphics_Text(double x, double y, char *str,
93
				  double rot, double hadj,
94
				  double rot, double hadj,
94
				  R_GE_gcontext *gc,
95
				  R_GE_gcontext *gc,
95
				  NewDevDesc *dd);
96
				  NewDevDesc *dd);
96
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
97
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
97
				       void* pAXD,
98
				       void* pAXD,
98
				       char* pDisplay,
99
				       char* pDisplay,
99
				       double pWidth,
100
				       double pWidth,
100
				       double pHeight,
101
				       double pHeight,
101
				       Rboolean pRecording,
102
				       Rboolean pRecording,
102
				       int pResize);
103
				       int pResize);
103
 
104
 
104
/* 00-06-22 | baier | added line type and width */
105
/* 00-06-22 | baier | added line type and width */
105
static void R_Proxy_Graphics_Circle (double pX,
106
static void R_Proxy_Graphics_Circle (double pX,
106
				     double pY,
107
				     double pY,
107
				     double pRad,
108
				     double pRad,
108
				     R_GE_gcontext *gc,
109
				     R_GE_gcontext *gc,
109
				     NewDevDesc* pDD)
110
				     NewDevDesc* pDD)
110
{
111
{
-
 
112
/*  OutputDebugString("R_Proxy_Graphics_Circle()\n"); */
111
  if (__graphics_device)
113
  if (__graphics_device)
112
    {
114
    {
113
      __graphics_device->vtbl->circle (__graphics_device,
115
      __graphics_device->vtbl->circle (__graphics_device,
114
				       pX,
116
				       pX,
115
				       pY,
117
				       pY,
116
				       pRad,
118
				       pRad,
117
				       gc->fill,
119
				       gc->fill,
118
				       gc->col,
120
				       gc->col,
119
				       gc->lty,
121
				       gc->lty,
120
				       gc->lwd);
122
				       gc->lwd);
121
      return;
123
      return;
122
    }
124
    }
123
 
125
 
124
  MessageBox (GetDesktopWindow (),"Circle()","R_Proxy_Graphics",MB_OK);
126
  MessageBox (GetDesktopWindow (),"Circle()","R_Proxy_Graphics",MB_OK);
125
}
127
}
126
static void R_Proxy_Graphics_Clip (double pX0,
128
static void R_Proxy_Graphics_Clip (double pX0,
127
				   double pX1,
129
				   double pX1,
128
				   double pY0,
130
				   double pY0,
129
				   double pY1,
131
				   double pY1,
130
				   NewDevDesc* pDD)
132
				   NewDevDesc* pDD)
131
{
133
{
132
  if (__graphics_device)
134
  if (__graphics_device)
133
    {
135
    {
134
      __graphics_device->vtbl->clip (__graphics_device,
136
      __graphics_device->vtbl->clip (__graphics_device,
135
				     pX0,pX1,pY0,pY1);
137
				     pX0,pX1,pY0,pY1);
136
      return;
138
      return;
137
    }
139
    }
138
 
140
 
139
  MessageBox (GetDesktopWindow (),"Clip()","R_Proxy_Graphics",MB_OK);
141
  MessageBox (GetDesktopWindow (),"Clip()","R_Proxy_Graphics",MB_OK);
140
}
142
}
141
static void R_Proxy_Graphics_Close (NewDevDesc* pDD)
143
static void R_Proxy_Graphics_Close (NewDevDesc* pDD)
142
{
144
{
143
  if (__graphics_device)
145
  if (__graphics_device)
144
    {
146
    {
145
      __graphics_device->vtbl->close (__graphics_device);
147
      __graphics_device->vtbl->close (__graphics_device);
146
      return;
148
      return;
147
    }
149
    }
148
 
150
 
149
  MessageBox (GetDesktopWindow (),"Close()","R_Proxy_Graphics",MB_OK);
151
  MessageBox (GetDesktopWindow (),"Close()","R_Proxy_Graphics",MB_OK);
150
}
152
}
151
static void R_Proxy_Graphics_Deactivate (NewDevDesc* pDD)
153
static void R_Proxy_Graphics_Deactivate (NewDevDesc* pDD)
152
{
154
{
153
  if (__graphics_device)
155
  if (__graphics_device)
154
    {
156
    {
155
      __graphics_device->vtbl->deactivate (__graphics_device);
157
      __graphics_device->vtbl->deactivate (__graphics_device);
156
      return;
158
      return;
157
    }
159
    }
158
 
160
 
159
  MessageBox (GetDesktopWindow (),"Deactivate()","R_Proxy_Graphics",MB_OK);
161
  MessageBox (GetDesktopWindow (),"Deactivate()","R_Proxy_Graphics",MB_OK);
160
}
162
}
161
static void R_Proxy_Graphics_Hold (NewDevDesc* pDD)
163
static void R_Proxy_Graphics_Hold (NewDevDesc* pDD)
162
{
164
{
163
  if (__graphics_device)
165
  if (__graphics_device)
164
    {
166
    {
165
      __graphics_device->vtbl->hold (__graphics_device);
167
      __graphics_device->vtbl->hold (__graphics_device);
166
      return;
168
      return;
167
    }
169
    }
168
 
170
 
169
  MessageBox (GetDesktopWindow (),"Hold()","R_Proxy_Graphics",MB_OK);
171
  MessageBox (GetDesktopWindow (),"Hold()","R_Proxy_Graphics",MB_OK);
170
}
172
}
171
/* 00-06-22 | baier | added color, line type and width */
173
/* 00-06-22 | baier | added color, line type and width */
172
static void R_Proxy_Graphics_Line (double pX0,
174
static void R_Proxy_Graphics_Line (double pX0,
173
				   double pY0,
175
				   double pY0,
174
				   double pX1,
176
				   double pX1,
175
				   double pY1,
177
				   double pY1,
176
				   R_GE_gcontext *gc,
178
				   R_GE_gcontext *gc,
177
				   NewDevDesc* pDD)
179
				   NewDevDesc* pDD)
178
{
180
{
179
  if (__graphics_device)
181
  if (__graphics_device)
180
    {
182
    {
181
 
183
 
182
      __graphics_device->vtbl->line (__graphics_device,
184
      __graphics_device->vtbl->line (__graphics_device,
183
				     pX0,pY0,pX1,pY1,gc->col,
185
				     pX0,pY0,pX1,pY1,gc->col,
184
				     gc->lty,gc->lwd);
186
				     gc->lty,gc->lwd);
185
      return;
187
      return;
186
    }
188
    }
187
 
189
 
188
  MessageBox (GetDesktopWindow (),"Line()","R_Proxy_Graphics",MB_OK);
190
  MessageBox (GetDesktopWindow (),"Line()","R_Proxy_Graphics",MB_OK);
189
}
191
}
190
/* 01-01-25 | changed return type */
192
/* 01-01-25 | changed return type */
191
static Rboolean R_Proxy_Graphics_Locator (double* pX,
193
static Rboolean R_Proxy_Graphics_Locator (double* pX,
192
					  double* pY,
194
					  double* pY,
193
					  NewDevDesc* pDD)
195
					  NewDevDesc* pDD)
194
{
196
{
195
  if (__graphics_device)
197
  if (__graphics_device)
196
    {
198
    {
197
      return __graphics_device->vtbl->locator (__graphics_device,pX,pY);
199
      return __graphics_device->vtbl->locator (__graphics_device,pX,pY);
198
    }
200
    }
199
 
201
 
200
  MessageBox (GetDesktopWindow (),"Locator()","R_Proxy_Graphics",MB_OK);
202
  MessageBox (GetDesktopWindow (),"Locator()","R_Proxy_Graphics",MB_OK);
201
  return 0;
203
  return 0;
202
}
204
}
203
static void R_Proxy_Graphics_Mode (int pMode, NewDevDesc *dd)
205
static void R_Proxy_Graphics_Mode (int pMode, NewDevDesc *dd)
204
{
206
{
205
  if (__graphics_device)
207
  if (__graphics_device)
206
    {
208
    {
207
      __graphics_device->vtbl->mode (__graphics_device,pMode);
209
      __graphics_device->vtbl->mode (__graphics_device,pMode);
208
      return;
210
      return;
209
    }
211
    }
210
 
212
 
211
  MessageBox (GetDesktopWindow (),"Mode()","R_Proxy_Graphics",MB_OK);
213
  MessageBox (GetDesktopWindow (),"Mode()","R_Proxy_Graphics",MB_OK);
212
}
214
}
213
static void R_Proxy_Graphics_NewPage (R_GE_gcontext *gc,
215
static void R_Proxy_Graphics_NewPage (R_GE_gcontext *gc,
214
				      NewDevDesc* pDD)
216
				      NewDevDesc* pDD)
215
{
217
{
216
  if (__graphics_device)
218
  if (__graphics_device)
217
    {
219
    {
218
      __graphics_device->vtbl->newpage (__graphics_device);
220
      __graphics_device->vtbl->newpage (__graphics_device);
219
      return;
221
      return;
220
    }
222
    }
221
 
223
 
222
  MessageBox (GetDesktopWindow (),"NewPage()","R_Proxy_Graphics",MB_OK);
224
  MessageBox (GetDesktopWindow (),"NewPage()","R_Proxy_Graphics",MB_OK);
223
}
225
}
224
/* 01-01-25 | baier | added new parameters "recording", "resize" */
226
/* 01-01-25 | baier | added new parameters "recording", "resize" */
225
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
227
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
226
				       void* pAXD,
228
				       void* pAXD,
227
				       char* pDisplay,
229
				       char* pDisplay,
228
				       double pWidth,
230
				       double pWidth,
229
				       double pHeight,
231
				       double pHeight,
230
				       Rboolean pRecording,
232
				       Rboolean pRecording,
231
				       int pResize)
233
				       int pResize)
232
{
234
{
233
  if (__graphics_device)
235
  if (__graphics_device)
234
    {
236
    {
235
      return __graphics_device->vtbl->open (__graphics_device,
237
      return __graphics_device->vtbl->open (__graphics_device,
236
					    pDisplay,pWidth,pHeight,0.0,0,0);
238
					    pDisplay,pWidth,pHeight,0.0,0,0);
237
    }
239
    }
238
 
240
 
239
  MessageBox (GetDesktopWindow (),"Open()","R_Proxy_Graphics",MB_OK);
241
  MessageBox (GetDesktopWindow (),"Open()","R_Proxy_Graphics",MB_OK);
240
  return 1;
242
  return 1;
241
}
243
}
242
 
244
 
243
static void R_Proxy_Graphics_Polygon (int pCount,
245
static void R_Proxy_Graphics_Polygon (int pCount,
244
				      double* pX,
246
				      double* pX,
245
				      double* pY,
247
				      double* pY,
246
				      R_GE_gcontext *gc,
248
				      R_GE_gcontext *gc,
247
				      NewDevDesc* pDD)
249
				      NewDevDesc* pDD)
248
{
250
{
249
  if (__graphics_device)
251
  if (__graphics_device)
250
    {
252
    {
251
      /* convert coordinates here: don't use alloca() -> overflow? */
253
      /* convert coordinates here: don't use alloca() -> overflow? */
252
      double* lX = (double*) malloc (pCount * sizeof (double));
254
      double* lX = (double*) malloc (pCount * sizeof (double));
253
      double* lY = (double*) malloc (pCount * sizeof (double));
255
      double* lY = (double*) malloc (pCount * sizeof (double));
254
      int i = 0;
256
      int i = 0;
255
 
257
 
256
      /* could use memcpy() for speed */
258
      /* could use memcpy() for speed */
257
      for (i = 0;i < pCount;i++)
259
      for (i = 0;i < pCount;i++)
258
	{
260
	{
259
	  lX[i] = pX[i];
261
	  lX[i] = pX[i];
260
	  lY[i] = pY[i];
262
	  lY[i] = pY[i];
261
 
263
 
262
	}
264
	}
263
 
265
 
264
      /*      sprintf (x,"device::Polygon: bg is %08x, fg is %08x\n",fill,col); */
266
      /*      sprintf (x,"device::Polygon: bg is %08x, fg is %08x\n",fill,col); */
265
      /*      OutputDebugString (x); */
267
      /*      OutputDebugString (x); */
266
      __graphics_device->vtbl->polygon (__graphics_device,
268
      __graphics_device->vtbl->polygon (__graphics_device,
267
					pCount,lX,lY,gc->fill,gc->col);
269
					pCount,lX,lY,gc->fill,gc->col);
268
 
270
 
269
      free (lX);
271
      free (lX);
270
      free (lY);
272
      free (lY);
271
 
273
 
272
      return;
274
      return;
273
    }
275
    }
274
 
276
 
275
  MessageBox (GetDesktopWindow (),"Polygon()","R_Proxy_Graphics",MB_OK);
277
  MessageBox (GetDesktopWindow (),"Polygon()","R_Proxy_Graphics",MB_OK);
276
}
278
}
277
/* 01-01-23 | baier | added "col" parameter */
279
/* 01-01-23 | baier | added "col" parameter */
278
static void R_Proxy_Graphics_Polyline (int pCount,
280
static void R_Proxy_Graphics_Polyline (int pCount,
279
				       double* pX,
281
				       double* pX,
280
				       double* pY,
282
				       double* pY,
281
				       R_GE_gcontext *gc,
283
				       R_GE_gcontext *gc,
282
				       NewDevDesc* pDD)
284
				       NewDevDesc* pDD)
283
{
285
{
284
  if (__graphics_device)
286
  if (__graphics_device)
285
    {
287
    {
286
      /* convert coordinates here: don't use alloca() -> overflow? */
288
      /* convert coordinates here: don't use alloca() -> overflow? */
287
      double* lX = (double*) malloc (pCount * sizeof (double));
289
      double* lX = (double*) malloc (pCount * sizeof (double));
288
      double* lY = (double*) malloc (pCount * sizeof (double));
290
      double* lY = (double*) malloc (pCount * sizeof (double));
289
      int i = 0;
291
      int i = 0;
290
 
292
 
291
      /* could use memcpy() for speed */
293
      /* could use memcpy() for speed */
292
      for (i = 0;i < pCount;i++)
294
      for (i = 0;i < pCount;i++)
293
	{
295
	{
294
	  char x[1000];
296
	  char x[1000];
295
	  lX[i] = pX[i];
297
	  lX[i] = pX[i];
296
	  lY[i] = pY[i];
298
	  lY[i] = pY[i];
297
 
299
 
298
	  sprintf (x,"Polyline: coord %d is %f/%f (was %f/%f)\n",
300
	  sprintf (x,"Polyline: coord %d is %f/%f (was %f/%f)\n",
299
		   i,lX[i],lY[i],pX[i],pY[i]);
301
		   i,lX[i],lY[i],pX[i],pY[i]);
300
	  /*	  OutputDebugString (x); */
302
	  /*	  OutputDebugString (x); */
301
 
303
 
302
	}
304
	}
303
 
305
 
304
      __graphics_device->vtbl->polyline (__graphics_device,
306
      __graphics_device->vtbl->polyline (__graphics_device,
305
					 pCount,lX,lY,gc->col);
307
					 pCount,lX,lY,gc->col);
306
 
308
 
307
      free (lX);
309
      free (lX);
308
      free (lY);
310
      free (lY);
309
 
311
 
310
      return;
312
      return;
311
    }
313
    }
312
 
314
 
313
  MessageBox (GetDesktopWindow (),"Polyline()","R_Proxy_Graphics",MB_OK);
315
  MessageBox (GetDesktopWindow (),"Polyline()","R_Proxy_Graphics",MB_OK);
314
}
316
}
315
/* 00-06-22 | baier | added line type and width */
317
/* 00-06-22 | baier | added line type and width */
316
static void R_Proxy_Graphics_Rect (double pX0,
318
static void R_Proxy_Graphics_Rect (double pX0,
317
				   double pY0,
319
				   double pY0,
318
				   double pX1,
320
				   double pX1,
319
				   double pY1,
321
				   double pY1,
320
				   R_GE_gcontext *gc,
322
				   R_GE_gcontext *gc,
321
				   NewDevDesc* pDD)
323
				   NewDevDesc* pDD)
322
{
324
{
323
  if (__graphics_device)
325
  if (__graphics_device)
324
    {
326
    {
325
 
327
 
326
      __graphics_device->vtbl->rect (__graphics_device,
328
      __graphics_device->vtbl->rect (__graphics_device,
327
				     pX0,pY0,pX1,pY1,gc->fill,gc->col,
329
				     pX0,pY0,pX1,pY1,gc->fill,gc->col,
328
				     gc->lty,gc->lwd);
330
				     gc->lty,gc->lwd);
329
      return;
331
      return;
330
    }
332
    }
331
 
333
 
332
  MessageBox (GetDesktopWindow (),"Rect()","R_Proxy_Graphics",MB_OK);
334
  MessageBox (GetDesktopWindow (),"Rect()","R_Proxy_Graphics",MB_OK);
333
}
335
}
334
static void R_Proxy_Graphics_Size(double *left, double *right,
336
static void R_Proxy_Graphics_Size(double *left, double *right,
335
				  double *bottom, double *top,
337
				  double *bottom, double *top,
336
				  NewDevDesc *pDD)
338
				  NewDevDesc *pDD)
337
{
339
{
338
    *left = pDD->left;
340
    *left = pDD->left;
339
    *right = pDD->right;
341
    *right = pDD->right;
340
    *bottom = pDD->bottom;
342
    *bottom = pDD->bottom;
341
    *top = pDD->top;
343
    *top = pDD->top;
342
}
344
}
343
 
345
 
344
#ifdef UNUSED
346
#ifdef UNUSED
345
static void R_Proxy_Graphics_Resize (NewDevDesc* pDD)
347
static void R_Proxy_Graphics_Resize (NewDevDesc* pDD)
346
{
348
{
347
  if (__graphics_device)
349
  if (__graphics_device)
348
    {
350
    {
349
      __graphics_device->vtbl->resize (__graphics_device);
351
      __graphics_device->vtbl->resize (__graphics_device);
350
      return;
352
      return;
351
    }
353
    }
352
 
354
 
353
  MessageBox (GetDesktopWindow (),"Resize()","R_Proxy_Graphics",MB_OK);
355
  MessageBox (GetDesktopWindow (),"Resize()","R_Proxy_Graphics",MB_OK);
354
}
356
}
355
#endif
357
#endif
356
 
358
 
357
/* 00-06-22 | baier | added font and size parameters */
359
/* 00-06-22 | baier | added font and size parameters */
358
static double R_Proxy_Graphics_StrWidth (char* pString,
360
static double R_Proxy_Graphics_StrWidth (char* pString,
359
					 R_GE_gcontext *gc,
361
					 R_GE_gcontext *gc,
360
					 NewDevDesc* pDD)
362
					 NewDevDesc* pDD)
361
{
363
{
362
  if (__graphics_device)
364
  if (__graphics_device)
363
    {
365
    {
364
      int lSize = gc->cex * gc->ps + 0.5;
366
      int lSize = gc->cex * gc->ps + 0.5;
365
      return __graphics_device->vtbl->strwidth (__graphics_device,
367
      return __graphics_device->vtbl->strwidth (__graphics_device,
366
						pString,
368
						pString,
367
						gc->fontface,
369
						gc->fontface,
368
						lSize);
370
						lSize);
369
    }
371
    }
370
 
372
 
371
  MessageBox (GetDesktopWindow (),"StrWidth()","R_Proxy_Graphics",MB_OK);
373
  MessageBox (GetDesktopWindow (),"StrWidth()","R_Proxy_Graphics",MB_OK);
372
  return 0.0;
374
  return 0.0;
373
}
375
}
374
 
376
 
375
/* 00-06-22 | baier | added color, font and size */
377
/* 00-06-22 | baier | added color, font and size */
376
static void R_Proxy_Graphics_Text (double pX,
378
static void R_Proxy_Graphics_Text (double pX,
377
				   double pY,
379
				   double pY,
378
				   char* pString,
380
				   char* pString,
379
				   double pRot,
381
				   double pRot,
380
				   double pHadj,
382
				   double pHadj,
381
				   R_GE_gcontext *gc,
383
				   R_GE_gcontext *gc,
382
				   NewDevDesc* pDD)
384
				   NewDevDesc* pDD)
383
{
385
{
384
  if (__graphics_device)
386
  if (__graphics_device)
385
    {
387
    {
386
      int lSize = gc->cex * gc->ps + 0.5;
388
      int lSize = gc->cex * gc->ps + 0.5;
387
 
389
 
388
      __graphics_device->vtbl->text (__graphics_device,
390
      __graphics_device->vtbl->text (__graphics_device,
389
				     pX,pY,pString,pRot,pHadj,
391
				     pX,pY,pString,pRot,pHadj,
390
				     gc->col,gc->fontface,lSize);
392
				     gc->col,gc->fontface,lSize);
391
      return;
393
      return;
392
    }
394
    }
393
 
395
 
394
  MessageBox (GetDesktopWindow (),"Text()","R_Proxy_Graphics",MB_OK);
396
  MessageBox (GetDesktopWindow (),"Text()","R_Proxy_Graphics",MB_OK);
395
}
397
}
396
 
398
 
397
/* 00-06-22 | baier | added font and size parameters */
399
/* 00-06-22 | baier | added font and size parameters */
398
static void R_Proxy_Graphics_MetricInfo(int c, 
400
static void R_Proxy_Graphics_MetricInfo(int c, 
399
					R_GE_gcontext *gc,
401
					R_GE_gcontext *gc,
400
					double* ascent, double* descent,
402
					double* ascent, double* descent,
401
					double* width, NewDevDesc *dd);
403
					double* width, NewDevDesc *dd);
402
static void R_Proxy_Graphics_MetricInfo (int pC,
404
static void R_Proxy_Graphics_MetricInfo (int pC,
403
					 R_GE_gcontext *gc,
405
					 R_GE_gcontext *gc,
404
					 double* pAscent,
406
					 double* pAscent,
405
					 double* pDescent,
407
					 double* pDescent,
406
					 double* pWidth,
408
					 double* pWidth,
407
					 NewDevDesc* pDD)
409
					 NewDevDesc* pDD)
408
{
410
{
409
  if (__graphics_device)
411
  if (__graphics_device)
410
    {
412
    {
411
      int lSize = gc->cex * gc->ps + 0.5;
413
      int lSize = gc->cex * gc->ps + 0.5;
412
      __graphics_device->vtbl->metricinfo (__graphics_device,
414
      __graphics_device->vtbl->metricinfo (__graphics_device,
413
					   pC,
415
					   pC,
414
					   pAscent,
416
					   pAscent,
415
					   pDescent,
417
					   pDescent,
416
					   pWidth,
418
					   pWidth,
417
					   gc->fontface,
419
					   gc->fontface,
418
					   lSize);
420
					   lSize);
419
      return;
421
      return;
420
    }
422
    }
421
 
423
 
422
  MessageBox (GetDesktopWindow (),"MetricInfo()","R_Proxy_Graphics",MB_OK);
424
  MessageBox (GetDesktopWindow (),"MetricInfo()","R_Proxy_Graphics",MB_OK);
423
}
425
}
424
 
426
 
425
/* 01-01-25 | baier | new paramters */
427
/* 01-01-25 | baier | new paramters */
-
 
428
/* 04-09-27 | baier | startcol, startfill */
426
int R_Proxy_Graphics_Driver (NewDevDesc* pDD,
429
int R_Proxy_Graphics_Driver (NewDevDesc* pDD,
427
			     char* pDisplay,
430
			     char* pDisplay,
428
			     double pWidth,
431
			     double pWidth,
429
			     double pHeight,
432
			     double pHeight,
430
			     double pPointSize,
433
			     double pPointSize,
431
			     Rboolean pRecording,
434
			     Rboolean pRecording,
432
			     int pResize,
435
			     int pResize,
433
			     struct _SC_GraphicsDevice* pDevice)
436
			     struct _SC_GraphicsDevice* pDevice)
434
{
437
{
435
  pDD->startfont = 1;
438
  pDD->startfont = 1;
436
  pDD->startps = pPointSize;
439
  pDD->startps = pPointSize;
437
  pDD->startcol = 0;
440
  pDD->startcol = R_RGB(0, 0, 0);
438
  pDD->startfill = NA_INTEGER;
441
  pDD->startfill = R_TRANWHITE;
439
  pDD->startlty = LTY_SOLID;
442
  pDD->startlty = LTY_SOLID;
440
  pDD->startgamma = 1;
443
  pDD->startgamma = 1;
441
 
444
 
442
  /* init the device-specific functionality here */
445
  /* init the device-specific functionality here */
443
  pDD->deviceSpecific = (void *) NULL;
446
  pDD->deviceSpecific = (void *) NULL;
444
 
447
 
445
  /* Start the Device Driver and Hardcopy.  */
448
  /* Start the Device Driver and Hardcopy.  */
446
  if (!R_Proxy_Graphics_Open (pDD,
449
  if (!R_Proxy_Graphics_Open (pDD,
447
			      NULL,
450
			      NULL,
448
			      pDisplay,
451
			      pDisplay,
449
			      pWidth,
452
			      pWidth,
450
			      pHeight,
453
			      pHeight,
451
			      pRecording,
454
			      pRecording,
452
			      pResize)) {
455
			      pResize)) {
453
    return 0;
456
    return 0;
454
  }
457
  }
455
  /* Set up Data Structures  */
458
  /* Set up Data Structures  */
456
 
459
 
457
  pDD->newDevStruct = 1;
460
  pDD->newDevStruct = 1;
458
 
461
 
459
  pDD->open = R_Proxy_Graphics_Open;
462
  pDD->open = R_Proxy_Graphics_Open;
460
  pDD->close = R_Proxy_Graphics_Close;
463
  pDD->close = R_Proxy_Graphics_Close;
461
  pDD->activate = R_Proxy_Graphics_Activate;
464
  pDD->activate = R_Proxy_Graphics_Activate;
462
  pDD->deactivate = R_Proxy_Graphics_Deactivate;
465
  pDD->deactivate = R_Proxy_Graphics_Deactivate;
463
  pDD->size = R_Proxy_Graphics_Size;
466
  pDD->size = R_Proxy_Graphics_Size;
464
  pDD->newPage = R_Proxy_Graphics_NewPage;
467
  pDD->newPage = R_Proxy_Graphics_NewPage;
465
  pDD->clip = R_Proxy_Graphics_Clip;
468
  pDD->clip = R_Proxy_Graphics_Clip;
466
  pDD->strWidth = R_Proxy_Graphics_StrWidth;
469
  pDD->strWidth = R_Proxy_Graphics_StrWidth;
467
  pDD->text = R_Proxy_Graphics_Text;
470
  pDD->text = R_Proxy_Graphics_Text;
468
  pDD->rect = R_Proxy_Graphics_Rect;
471
  pDD->rect = R_Proxy_Graphics_Rect;
469
  pDD->circle = R_Proxy_Graphics_Circle;
472
  pDD->circle = R_Proxy_Graphics_Circle;
470
  pDD->line = R_Proxy_Graphics_Line;
473
  pDD->line = R_Proxy_Graphics_Line;
471
  pDD->polyline = R_Proxy_Graphics_Polyline;
474
  pDD->polyline = R_Proxy_Graphics_Polyline;
472
  pDD->polygon = R_Proxy_Graphics_Polygon;
475
  pDD->polygon = R_Proxy_Graphics_Polygon;
473
  pDD->locator = R_Proxy_Graphics_Locator;
476
  pDD->locator = R_Proxy_Graphics_Locator;
474
  pDD->mode = R_Proxy_Graphics_Mode;
477
  pDD->mode = R_Proxy_Graphics_Mode;
475
  pDD->hold = R_Proxy_Graphics_Hold;
478
  pDD->hold = R_Proxy_Graphics_Hold;
476
  pDD->metricInfo = R_Proxy_Graphics_MetricInfo;
479
  pDD->metricInfo = R_Proxy_Graphics_MetricInfo;
477
 
480
 
478
    /* set graphics parameters that must be set by device driver */
481
    /* set graphics parameters that must be set by device driver */
479
    /* Window Dimensions in Pixels */
482
    /* Window Dimensions in Pixels */
480
  pDD->left = 0;	/* left */
483
  pDD->left = 0;	/* left */
481
  pDD->right = DEV_X;	/* right */
484
  pDD->right = DEV_X;	/* right */
482
  pDD->top = 0;	/* top */
485
  pDD->top = 0;	/* top */
483
  pDD->bottom = DEV_Y;	/* bottom */
486
  pDD->bottom = DEV_Y;	/* bottom */
484
 
487
 
485
 
488
 
486
  /* Nominal Character Sizes in Pixels */
489
  /* Nominal Character Sizes in Pixels */
487
  pDD->cra[0] = 10;
490
  pDD->cra[0] = 10;
488
  pDD->cra[1] = 10;
491
  pDD->cra[1] = 10;
489
  /* Character Addressing Offsets */
492
  /* Character Addressing Offsets */
490
  /* These are used to plot a single plotting character */
493
  /* These are used to plot a single plotting character */
491
  /* so that it is exactly over the plotting point */
494
  /* so that it is exactly over the plotting point */
492
 
495
 
493
  pDD->xCharOffset = 0.50;
496
  pDD->xCharOffset = 0.50;
494
  pDD->yCharOffset = 0.40;
497
  pDD->yCharOffset = 0.40;
495
  pDD->yLineBias = 0.1;
498
  pDD->yLineBias = 0.1;
496
 
499
 
497
  /* Inches per raster unit */
500
  /* Inches per raster unit */
498
 
501
 
499
  pDD->ipr[0] = 1.0 / 72.0;
502
  pDD->ipr[0] = 1.0 / 72.0;
500
  pDD->ipr[1] = 1.0 / 72.0;
503
  pDD->ipr[1] = 1.0 / 72.0;
501
 
504
 
502
    /* Device capabilities */
505
    /* Device capabilities */
503
    /* Clipping is problematic for X11 */
506
    /* Clipping is problematic for X11 */
504
    /* Graphics is clipped, text is not */
507
    /* Graphics is clipped, text is not */
505
 
508
 
506
  pDD->canResizePlot = 1;
509
  pDD->canResizePlot = 1;
507
  pDD->canChangeFont = 0;
510
  pDD->canChangeFont = 0;
508
  pDD->canRotateText = 1;
511
  pDD->canRotateText = 1;
509
  pDD->canResizeText = 1;
512
  pDD->canResizeText = 1;
510
  pDD->canClip = 1;
513
  pDD->canClip = 1;
-
 
514
  pDD->displayListOn = 1;
511
 
515
 
512
  /* initialise x11 device description (most of the work */
516
  /* initialise x11 device description (most of the work */
513
  /* has been done in X11_Open) */
517
  /* has been done in X11_Open) */
514
 
518
 
515
  pDD->displayListOn = 1;
-
 
516
  return 1;
519
  return 1;
517
}
520
}