The R Project SVN R

Rev

Rev 17511 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17511 Rev 26207
Line 4... Line 4...
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.5 2001/12/21 06:55:37 ripley Exp $
20
 *  $Id: rproxy_dev.c,v 1.6 2003/09/13 15:14:09 murdoch 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>
Line 53... Line 53...
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
		      int col, int fill, double gamma, int lty, double lwd,
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);
Line 67... Line 67...
67
static void R_Proxy_Graphics_MetricInfo(int c, int font, double cex, double ps,
67
static void R_Proxy_Graphics_MetricInfo(int c, int font, double cex, double ps,
68
			  double* ascent, double* descent,
68
			  double* ascent, double* descent,
69
			  double* width, NewDevDesc *dd);
69
			  double* width, NewDevDesc *dd);
70
static void R_Proxy_Graphics_Mode(int mode, NewDevDesc *dd);
70
static void R_Proxy_Graphics_Mode(int mode, NewDevDesc *dd);
71
static void R_Proxy_Graphics_NewPage(int fill, double gamma, NewDevDesc *dd);
71
static void R_Proxy_Graphics_NewPage(int fill, double gamma, NewDevDesc *dd);
72
static void R_Proxy_Graphics_Polygon(int n, double *x, double *y, 
72
static void R_Proxy_Graphics_Polygon(int n, double *x, double *y,
73
		       int col, int fill, double gamma, int lty, double lwd,
73
		       int col, int fill, double gamma, int lty, double lwd,
74
		       NewDevDesc *dd);
74
		       NewDevDesc *dd);
75
static void R_Proxy_Graphics_Polyline(int n, double *x, double *y, 
75
static void R_Proxy_Graphics_Polyline(int n, double *x, double *y,
76
			int col, double gamma, int lty, double lwd,
76
			int col, double gamma, int lty, double lwd,
77
			NewDevDesc *dd);
77
			NewDevDesc *dd);
78
static void R_Proxy_Graphics_Rect(double x0, double y0, double x1, double y1,
78
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,
79
		    int col, int fill, double gamma, int lty, double lwd,
80
		    NewDevDesc *dd);
80
		    NewDevDesc *dd);
Line 84... Line 84...
84
#ifdef UNUSED
84
#ifdef UNUSED
85
static void R_Proxy_Graphics_Resize(NewDevDesc *dd);
85
static void R_Proxy_Graphics_Resize(NewDevDesc *dd);
86
#endif
86
#endif
87
static double R_Proxy_Graphics_StrWidth(char *str, int font,
87
static double R_Proxy_Graphics_StrWidth(char *str, int font,
88
			  double cex, double ps, NewDevDesc *dd);
88
			  double cex, double ps, NewDevDesc *dd);
89
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,
90
		    double rot, double hadj, 
90
		    double rot, double hadj,
91
		    int col, double gamma, int font, double cex, double ps,
91
		    int col, double gamma, int font, double cex, double ps,
92
		    NewDevDesc *dd);
92
		    NewDevDesc *dd);
93
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
93
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
94
				       void* pAXD,
94
				       void* pAXD,
95
				       char* pDisplay,
95
				       char* pDisplay,
96
				       double pWidth,
96
				       double pWidth,
97
				       double pHeight,
97
				       double pHeight,
98
				       Rboolean pRecording,
98
				       Rboolean pRecording,
99
				       int pResize);
99
				       int pResize);
100
 
100
 
101
// 00-06-22 | baier | added line type and width
101
/* 00-06-22 | baier | added line type and width */
102
static void R_Proxy_Graphics_Circle (double pX,
102
static void R_Proxy_Graphics_Circle (double pX,
103
				     double pY,
103
				     double pY,
104
				     double pRad,
104
				     double pRad,
105
				     int pCol,
105
				     int pCol,
106
				     int pFill,
106
				     int pFill,
Line 167... Line 167...
167
      return;
167
      return;
168
    }
168
    }
169
 
169
 
170
  MessageBox (GetDesktopWindow (),"Hold()","R_Proxy_Graphics",MB_OK);
170
  MessageBox (GetDesktopWindow (),"Hold()","R_Proxy_Graphics",MB_OK);
171
}
171
}
172
// 00-06-22 | baier | added color, line type and width
172
/* 00-06-22 | baier | added color, line type and width */
173
static void R_Proxy_Graphics_Line (double pX0,
173
static void R_Proxy_Graphics_Line (double pX0,
174
				   double pY0,
174
				   double pY0,
175
				   double pX1,
175
				   double pX1,
176
				   double pY1,
176
				   double pY1,
177
				   int pCol,
177
				   int pCol,
Line 189... Line 189...
189
      return;
189
      return;
190
    }
190
    }
191
 
191
 
192
  MessageBox (GetDesktopWindow (),"Line()","R_Proxy_Graphics",MB_OK);
192
  MessageBox (GetDesktopWindow (),"Line()","R_Proxy_Graphics",MB_OK);
193
}
193
}
194
// 01-01-25 | changed return type
194
/* 01-01-25 | changed return type */
195
static Rboolean R_Proxy_Graphics_Locator (double* pX,
195
static Rboolean R_Proxy_Graphics_Locator (double* pX,
196
					  double* pY,
196
					  double* pY,
197
					  NewDevDesc* pDD)
197
					  NewDevDesc* pDD)
198
{
198
{
199
  if (__graphics_device)
199
  if (__graphics_device)
Line 224... Line 224...
224
      return;
224
      return;
225
    }
225
    }
226
 
226
 
227
  MessageBox (GetDesktopWindow (),"NewPage()","R_Proxy_Graphics",MB_OK);
227
  MessageBox (GetDesktopWindow (),"NewPage()","R_Proxy_Graphics",MB_OK);
228
}
228
}
229
// 01-01-25 | baier | added new parameters "recording", "resize"
229
/* 01-01-25 | baier | added new parameters "recording", "resize" */
230
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
230
static Rboolean R_Proxy_Graphics_Open (NewDevDesc* pDD,
231
				       void* pAXD,
231
				       void* pAXD,
232
				       char* pDisplay,
232
				       char* pDisplay,
233
				       double pWidth,
233
				       double pWidth,
234
				       double pHeight,
234
				       double pHeight,
Line 255... Line 255...
255
				      double pLwd,
255
				      double pLwd,
256
				      NewDevDesc* pDD)
256
				      NewDevDesc* pDD)
257
{
257
{
258
  if (__graphics_device)
258
  if (__graphics_device)
259
    {
259
    {
260
      // convert coordinates here: don't use alloca() -> overflow?
260
      /* convert coordinates here: don't use alloca() -> overflow? */
261
      double* lX = (double*) malloc (pCount * sizeof (double));
261
      double* lX = (double*) malloc (pCount * sizeof (double));
262
      double* lY = (double*) malloc (pCount * sizeof (double));
262
      double* lY = (double*) malloc (pCount * sizeof (double));
263
      int i = 0;
263
      int i = 0;
264
 
264
 
265
      // could use memcpy() for speed
265
      /* could use memcpy() for speed */
266
      for (i = 0;i < pCount;i++)
266
      for (i = 0;i < pCount;i++)
267
	{
267
	{
268
	  lX[i] = pX[i];
268
	  lX[i] = pX[i];
269
	  lY[i] = pY[i];
269
	  lY[i] = pY[i];
270
 
270
 
271
	}
271
	}
272
 
272
 
273
      //      sprintf (x,"device::Polygon: bg is %08x, fg is %08x\n",pFill,pCol);
273
      /*      sprintf (x,"device::Polygon: bg is %08x, fg is %08x\n",pFill,pCol); */
274
      //      OutputDebugString (x);
274
      /*      OutputDebugString (x); */
275
      __graphics_device->vtbl->polygon (__graphics_device,
275
      __graphics_device->vtbl->polygon (__graphics_device,
276
					pCount,lX,lY,pFill,pCol);
276
					pCount,lX,lY,pFill,pCol);
277
 
277
 
278
      free (lX);
278
      free (lX);
279
      free (lY);
279
      free (lY);
Line 281... Line 281...
281
      return;
281
      return;
282
    }
282
    }
283
 
283
 
284
  MessageBox (GetDesktopWindow (),"Polygon()","R_Proxy_Graphics",MB_OK);
284
  MessageBox (GetDesktopWindow (),"Polygon()","R_Proxy_Graphics",MB_OK);
285
}
285
}
286
// 01-01-23 | baier | added "col" parameter
286
/* 01-01-23 | baier | added "col" parameter */
287
static void R_Proxy_Graphics_Polyline (int pCount,
287
static void R_Proxy_Graphics_Polyline (int pCount,
288
				       double* pX,
288
				       double* pX,
289
				       double* pY,
289
				       double* pY,
290
				       int pCol,
290
				       int pCol,
291
				       double pGamma,
291
				       double pGamma,
Line 293... Line 293...
293
				       double pLwd,
293
				       double pLwd,
294
				       NewDevDesc* pDD)
294
				       NewDevDesc* pDD)
295
{
295
{
296
  if (__graphics_device)
296
  if (__graphics_device)
297
    {
297
    {
298
      // convert coordinates here: don't use alloca() -> overflow?
298
      /* convert coordinates here: don't use alloca() -> overflow? */
299
      double* lX = (double*) malloc (pCount * sizeof (double));
299
      double* lX = (double*) malloc (pCount * sizeof (double));
300
      double* lY = (double*) malloc (pCount * sizeof (double));
300
      double* lY = (double*) malloc (pCount * sizeof (double));
301
      int i = 0;
301
      int i = 0;
302
 
302
 
303
      // could use memcpy() for speed
303
      /* could use memcpy() for speed */
304
      for (i = 0;i < pCount;i++)
304
      for (i = 0;i < pCount;i++)
305
	{
305
	{
306
	  char x[1000];
306
	  char x[1000];
307
	  lX[i] = pX[i];
307
	  lX[i] = pX[i];
308
	  lY[i] = pY[i];
308
	  lY[i] = pY[i];
309
 
309
 
310
	  sprintf (x,"Polyline: coord %d is %f/%f (was %f/%f)\n",
310
	  sprintf (x,"Polyline: coord %d is %f/%f (was %f/%f)\n",
311
		   i,lX[i],lY[i],pX[i],pY[i]);
311
		   i,lX[i],lY[i],pX[i],pY[i]);
312
	  //	  OutputDebugString (x);
312
	  /*	  OutputDebugString (x); */
313
 
313
 
314
	}
314
	}
315
 
315
 
316
      __graphics_device->vtbl->polyline (__graphics_device,
316
      __graphics_device->vtbl->polyline (__graphics_device,
317
					 pCount,lX,lY,pCol);
317
					 pCount,lX,lY,pCol);
Line 322... Line 322...
322
      return;
322
      return;
323
    }
323
    }
324
 
324
 
325
  MessageBox (GetDesktopWindow (),"Polyline()","R_Proxy_Graphics",MB_OK);
325
  MessageBox (GetDesktopWindow (),"Polyline()","R_Proxy_Graphics",MB_OK);
326
}
326
}
327
// 00-06-22 | baier | added line type and width
327
/* 00-06-22 | baier | added line type and width */
328
static void R_Proxy_Graphics_Rect (double pX0,
328
static void R_Proxy_Graphics_Rect (double pX0,
329
				   double pY0,
329
				   double pY0,
330
				   double pX1,
330
				   double pX1,
331
				   double pY1,
331
				   double pY1,
332
				   int pCol,
332
				   int pCol,
Line 368... Line 368...
368
 
368
 
369
  MessageBox (GetDesktopWindow (),"Resize()","R_Proxy_Graphics",MB_OK);
369
  MessageBox (GetDesktopWindow (),"Resize()","R_Proxy_Graphics",MB_OK);
370
}
370
}
371
#endif
371
#endif
372
 
372
 
373
// 00-06-22 | baier | added font and size parameters
373
/* 00-06-22 | baier | added font and size parameters */
374
static double R_Proxy_Graphics_StrWidth (char* pString,
374
static double R_Proxy_Graphics_StrWidth (char* pString,
375
					 int pFont,
375
					 int pFont,
376
					 double pCex,
376
					 double pCex,
377
					 double pPs,
377
					 double pPs,
378
					 NewDevDesc* pDD)
378
					 NewDevDesc* pDD)
Line 388... Line 388...
388
 
388
 
389
  MessageBox (GetDesktopWindow (),"StrWidth()","R_Proxy_Graphics",MB_OK);
389
  MessageBox (GetDesktopWindow (),"StrWidth()","R_Proxy_Graphics",MB_OK);
390
  return 0.0;
390
  return 0.0;
391
}
391
}
392
 
392
 
393
// 00-06-22 | baier | added color, font and size
393
/* 00-06-22 | baier | added color, font and size */
394
static void R_Proxy_Graphics_Text (double pX,
394
static void R_Proxy_Graphics_Text (double pX,
395
				   double pY,
395
				   double pY,
396
				   char* pString,
396
				   char* pString,
397
				   double pRot,
397
				   double pRot,
398
				   double pHadj,
398
				   double pHadj,
Line 414... Line 414...
414
    }
414
    }
415
 
415
 
416
  MessageBox (GetDesktopWindow (),"Text()","R_Proxy_Graphics",MB_OK);
416
  MessageBox (GetDesktopWindow (),"Text()","R_Proxy_Graphics",MB_OK);
417
}
417
}
418
 
418
 
419
// 00-06-22 | baier | added font and size parameters
419
/* 00-06-22 | baier | added font and size parameters */
420
static void R_Proxy_Graphics_MetricInfo(int c, int font, double cex, double ps,
420
static void R_Proxy_Graphics_MetricInfo(int c, int font, double cex, double ps,
421
			  double* ascent, double* descent,
421
			  double* ascent, double* descent,
422
			  double* width, NewDevDesc *dd);
422
			  double* width, NewDevDesc *dd);
423
static void R_Proxy_Graphics_MetricInfo (int pC,
423
static void R_Proxy_Graphics_MetricInfo (int pC,
424
					 int pFont, 
424
					 int pFont,
425
					 double pCex,
425
					 double pCex,
426
					 double pPs,
426
					 double pPs,
427
					 double* pAscent,
427
					 double* pAscent,
428
					 double* pDescent,
428
					 double* pDescent,
429
					 double* pWidth,
429
					 double* pWidth,
Line 443... Line 443...
443
    }
443
    }
444
 
444
 
445
  MessageBox (GetDesktopWindow (),"MetricInfo()","R_Proxy_Graphics",MB_OK);
445
  MessageBox (GetDesktopWindow (),"MetricInfo()","R_Proxy_Graphics",MB_OK);
446
}
446
}
447
 
447
 
448
// 01-01-25 | baier | new paramters
448
/* 01-01-25 | baier | new paramters */
449
int R_Proxy_Graphics_Driver (NewDevDesc* pDD,
449
int R_Proxy_Graphics_Driver (NewDevDesc* pDD,
450
			     char* pDisplay,
450
			     char* pDisplay,
451
			     double pWidth,
451
			     double pWidth,
452
			     double pHeight,
452
			     double pHeight,
453
			     double pPointSize,
453
			     double pPointSize,