The R Project SVN R

Rev

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

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