The R Project SVN R

Rev

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

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