The R Project SVN R

Rev

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

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