The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
hpgl.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file hpgl.c
5 
6  \version V2.2
7  \date 07.07.14
8  \brief HPGL plotting functions
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1991-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 25.03.91 Original
50 - V1.1 28.05.92 ANSIed
51 - V2.0 25.06.92 Modified for AMPlot2; floats->doubles
52 - V2.1 27.07.93 Changed some missed float->double
53 - V2.2 07.07.14 Use bl prefix for functions By: CTP
54 
55 *************************************************************************/
56 /* Doxygen
57  -------
58  #GROUP Graphics
59  #SUBGROUP HPGL
60  #FUNCTION blHPGLInit()
61  Initialise an HPGL plot. The parameters specify the unprintable margins
62  on the output device.
63 
64  #FUNCTION blHPGLPen()
65  Select a Pen
66 
67  #FUNCTION blHPGLMove()
68  Move on HPGL plot
69 
70  #FUNCTION blHPGLDraw()
71  Draw on HPGL plot
72 
73  #FUNCTION blHPGLSetDash()
74  Set the line style (may be printer dependent):
75 
76  #FUNCTION blHPGLFont()
77  Set font for HPGL plot
78 
79  #FUNCTION blHPGLLText()
80  Write left justified text on HPGL plot
81 
82  #FUNCTION blHPGLCBText()
83  Write centre-bottom justified text in HPGL
84 
85  #FUNCTION blHPGLROffText()
86  Print right-justified text to HPGL
87 
88  #FUNCTION blHPGLLCText()
89  Print left-centre justified text
90 
91  #FUNCTION blHPGLCTText()
92  Center Top justify text at x,y with y-offset in pts.
93 
94  #FUNCTION blHPGLVText()
95  Write vertical text centred on x,y offset back along x by the size of
96  label and by xoff in pts
97 
98  #FUNCTION blHPGLEnd()
99  Close the HPGL plot file
100 
101  #FUNCTION blHPGLShowText()
102  Displays the text, raising or lowering as appropriate and selecting
103  alternate font where required. Used by the various ...Text() routines.
104 */
105 /************************************************************************/
106 /* Includes
107 */
108 #include <math.h>
109 #include <string.h>
110 #include <stdio.h>
111 
112 #include "MathType.h"
113 #include "SysDefs.h"
114 #include "plotting.h"
115 
116 /************************************************************************/
117 /* Defines and macros
118 */
119 
120 #define FIXVERT /* This is used to fix the dimensions of
121  vertical text. Not sure if this is a bug in
122  the PLT: HPGL interpreter or is standard HPGL.
123  Used by HPGLVText().
124  Define it if it imroves your output.
125  */
126 #define MAXBUFF 160
127 
128 /************************************************************************/
129 /* Globals
130 */
131 static int sFontHeight, /* Font size in plotter units */
132  sFontWidth;
133 static REAL sFontHcm, /* Font size in cm */
134  sFontWcm;
135 static FILE *sHPGLFile = NULL; /* Plot file */
136 
137 /************************************************************************/
138 /* Prototypes
139 */
140 
141 /************************************************************************/
142 /*>BOOL blHPGLInit(char *filename, char *AltFont,
143  REAL xmargin, REAL ymargin)
144  ----------------------------------------------
145 *//**
146 
147  \param[in] *filename HPGL file name
148  \param[in] *AltFont Alternative font used for Greek characters
149  \param[in] xmargin Unprintable x margin
150  \param[in] ymargin Unprintable y margin
151  \return Success
152 
153  Initialise an HPGL plot. The parameters specify the unprintable margins
154  on the output device.
155 
156  The plot is also affected by global variables:
157 
158 
159  PSxpicsize X picture size
160  PSypicsize Y picture size
161  PSxoffset X offset
162  PSyoffset Y offset
163 
164 
165 - 25.06.92 Taken from MoG. Changed to support offsets. Added parameters.
166 - 29.06.92 Added initialisation of alternate font.
167 - 06.07.93 Added AltFont parameter
168 - 07.07.14 Use bl prefix for functions By: CTP
169 */
170 BOOL blHPGLInit(char *filename,
171  char *AltFont,
172  REAL xmargin,
173  REAL ymargin)
174 {
175  char buffer[80];
176  int xoff,
177  yoff,
178  HPGLAltFont;
179 
180  if((sHPGLFile = fopen(filename,"w")) == NULL) return(FALSE);
181 
182  HPGLAltFont = blPS2HPGLFont(AltFont);
183 
184  xoff = (int)((PSxoffset - xmargin) * 1024);
185  yoff = (int)((PSyoffset - ymargin) * 1024);
186 
187  sprintf(buffer,"IN; IP%d,%d,%d,%d;\n",xoff,yoff,
188  (int)(PSxpicsize*1024)+xoff,
189  (int)(PSypicsize*1024)+yoff);
190  fputs(buffer,sHPGLFile);
191 
192  sprintf(buffer,"SC0,10000,0,10000;DT\\;\n");
193  fputs(buffer,sHPGLFile);
194 
195  sprintf(buffer,"CA%d;SS;\n",HPGLAltFont);
196  fputs(buffer,sHPGLFile);
197 
198  return(TRUE);
199 }
200 
201 /************************************************************************/
202 /*>void blHPGLPen(int num)
203  -----------------------
204 *//**
205 
206  \param[in] num Pen number
207 
208  Select a Pen
209 
210 - 25.06.92 Taken from MoG
211 - 08.09.92 Changed to store pen first (having seen IntroCAD output)
212 - 07.07.14 Use bl prefix for functions By: CTP
213 */
214 void blHPGLPen(int num)
215 {
216  char buffer[80];
217 
218  sprintf(buffer,"SP;PU;SP%1d;\n",num);
219  fputs(buffer,sHPGLFile);
220 }
221 
222 /************************************************************************/
223 /*>void blHPGLMove(REAL x, REAL y)
224  -------------------------------
225 *//**
226 
227  \param[in] x X position (0.0--1.0)
228  \param[in] y Y position (0.0--1.0)
229 
230  Move on HPGL plot
231 
232 - 25.06.92 Taken from MoG
233 - 07.07.14 Use bl prefix for functions By: CTP
234 */
236  REAL y)
237 {
238  char buffer[80];
239 
240  sprintf(buffer,"PU;PA%d, %d;\n", (int)(10000*x),(int)(10000*y));
241  fputs(buffer,sHPGLFile);
242 }
243 
244 /************************************************************************/
245 /*>void blHPGLDraw(REAL x, REAL y)
246  -------------------------------
247 *//**
248 
249  \param[in] x X position (0.0--1.0)
250  \param[in] y Y position (0.0--1.0)
251 
252  Draw on HPGL plot
253 
254 - 25.06.92 Taken from MoG
255 - 07.07.14 Use bl prefix for functions By: CTP
256 */
258  REAL y)
259 {
260  char buffer[80];
261 
262  sprintf(buffer,"PD;PA%d, %d;\n",(int)(10000*x),(int)(10000*y));
263  fputs(buffer,sHPGLFile);
264 }
265 
266 /************************************************************************/
267 /*>void blHPGLSetDash(int style)
268  -----------------------------
269 *//**
270 
271  \param[in] style Line style
272 
273  Set the line style (may be printer dependent):
274 
275  0 Solid line
276  1 ............
277  2 -.-.-.-.-.-.
278  3 ------------
279  4 -..-..-..-..
280  5 --.--.--.--.
281 
282 - 25.06.92 Framework
283 - 26.06.92 Original
284 - 07.07.14 Use bl prefix for functions By: CTP
285 */
286 void blHPGLSetDash(int style)
287 {
288  switch(style)
289  {
290  case 0: /* Solid line */
291  fputs("LT;\n",sHPGLFile);
292  break;
293  case 1: /* ............ */
294  fputs("LT1,2;\n",sHPGLFile);
295  break;
296  case 2: /* -.-.-.-.-.-. */
297  fputs("LT4,3;\n",sHPGLFile);
298  break;
299  case 3: /* ------------ */
300  fputs("LT2,3;\n",sHPGLFile);
301  break;
302  case 4: /* -..-..-..-.. */
303  fputs("LT6,3;\n",sHPGLFile);
304  break;
305  case 5: /* --.--.--.--. */
306  fputs("LT5,3;\n",sHPGLFile);
307  break;
308  }
309 }
310 
311 /************************************************************************/
312 /*>void blHPGLFont(int font, REAL size)
313  ------------------------------------
314 *//**
315 
316  \param[in] font Font number
317  \param[in] size Point size of font
318 
319  Set font for HPGL plot
320 
321 - 25.06.92 Taken from MoG
322 - 29.06.92 Corrected CA to CS and added SS. Changed to use global width
323  and height variables. Altered width to 1/2.4 * height
324 - 27.07.93 Changed precision of floating i/o to double
325 - 07.07.14 Use bl prefix for functions By: CTP
326 */
327 void blHPGLFont(int font,
328  REAL size)
329 {
330  char buffer[80];
331  REAL width;
332 
333  /* Character dimensions in centimeters. We convert pts to cm, then
334  divide by 1.7 to get a better size. Width is set to half height.
335  */
336  sFontHcm = size * 2.54 / (1.7 * 72.0);
337  sFontWcm = sFontHcm/2.4;
338 
339  sprintf(buffer,"PU;CS%d;SS;SI%5.3f, %5.3f;\n",
340  font,sFontWcm,sFontHcm);
341  fputs(buffer,sHPGLFile);
342 
343  /* Character height in scaled units */
344  sFontHeight = (int)((size * 10000.0) / (72.0 * PSypicsize));
345 
346  /* Character width from height in cm. This conversion is empirical! */
347  width = sFontHcm * 0.6154; /* cm */
348  width /= 2.54; /* in */
349  width *= 10000.0/PSxpicsize; /* Graph units */
350  sFontWidth = (int)width;
351 }
352 
353 /************************************************************************/
354 /*>void blHPGLLText(REAL x, REAL y, char *string)
355  ----------------------------------------------
356 *//**
357 
358  \param[in] x X coordinate
359  \param[in] y Y coordinate
360  \param[in] *string Text to print
361 
362  Write left justified text on HPGL plot
363 
364 - 25.06.92 Taken from MoG
365 - 29.06.92 Changed to use HPGLShowText().
366 - 07.07.14 Use bl prefix for functions By: CTP
367 */
369  REAL y,
370  char *string)
371 {
372  char buffer[80];
373 
374  sprintf(buffer,"PU;PA%d, %d;",
375  (int)(10000.0 * x),(int)(10000.0 * y));
376  fputs(buffer,sHPGLFile);
377 
378  blHPGLShowText(string,0,(int)(10000.0 * x),(int)(10000.0 * y));
379 }
380 
381 /************************************************************************/
382 /*>void blHPGLCBText(REAL x, REAL y, REAL offset, char *text)
383  ----------------------------------------------------------
384 *//**
385 
386  \param[in] x X coordinate
387  \param[in] y Y coordinate
388  \param[in] offset Y-offset (multiplied by font height).
389  Move text up by this amount
390  \param[in] *text Text to print
391 
392  Write centre-bottom justified text in HPGL
393 
394 - 25.06.92 Framework
395 - 26.06.92 Original
396 - 29.06.92 Added SimplifyText(). Changed to use HPGLShowText().
397 - 06.07.92 Modified x-pos for wider font width
398 - 07.07.14 Use bl prefix for functions By: CTP
399 */
401  REAL y,
402  REAL offset,
403  char *text)
404 {
405  char buffer[80];
406  int xpos,
407  ypos;
408 
409  xpos = (int)(10000.0 * x);
410  xpos -= strlen(blSimplifyText(text)) * sFontWidth / 2;
411  xpos += sFontWidth / 6;
412 
413  ypos = (int)(10000.0 * y);
414  ypos -= (int)(offset * sFontHeight);
415 
416  sprintf(buffer,"PU;PA%d, %d;", xpos, ypos);
417  fputs(buffer,sHPGLFile);
418 
419  blHPGLShowText(text,0,xpos,ypos);
420 }
421 
422 /************************************************************************/
423 /*>void blHPGLROffText(REAL x, REAL y, REAL offset, char *text)
424  ------------------------------------------------------------
425 *//**
426 
427  \param[in] x X coordinate
428  \param[in] y Y coordinate
429  \param[in] offset Move left by this amount (pts)
430  \param[in] *text Text to print
431 
432  Print right-justified text to HPGL
433 
434 - 25.06.92 Framework
435 - 26.06.92 Original
436 - 29.06.92 Added SimplifyText(). Changed to use HPGLShowText().
437 - 06.07.92 Modified x-pos for wider font width
438 - 07.07.14 Use bl prefix for functions By: CTP
439 */
441  REAL y,
442  REAL offset,
443  char *text)
444 {
445  char buffer[80];
446  int xpos,
447  ypos;
448 
449  /* Base position */
450  xpos = (int)(10000.0 * x);
451  /* Right justify */
452  xpos -= (strlen(blSimplifyText(text)) * sFontWidth);
453  xpos += sFontWidth/6;
454  /* Convert offset from pt to plotter units */
455  xpos += (int)((offset * 10000.0) / (72.0 * PSxpicsize));
456 
457  ypos = (int)(10000.0 * y);
458  /* Centre y-height */
459  ypos -= (int)(1.0 * sFontHeight / 3.0);
460 
461  sprintf(buffer,"PU;PA%d, %d;\n", xpos, ypos);
462  fputs(buffer,sHPGLFile);
463  blHPGLShowText(text,0,xpos,ypos);
464 }
465 
466 /************************************************************************/
467 /*>void blHPGLLCText(REAL x, REAL y, char *text)
468  ---------------------------------------------
469 *//**
470 
471  \param[in] x X coordinate
472  \param[in] y Y coordinate
473  \param[in] *text Text to print
474 
475  Print left-centre justified text
476 
477 - 25.06.92 Framework
478 - 26.06.92 Original
479 - 29.06.92 Changed to use HPGLShowText().
480 - 07.07.14 Use bl prefix for functions By: CTP
481 */
483  REAL y,
484  char *text)
485 {
486  char buffer[80];
487  int xpos,
488  ypos;
489 
490  xpos = (int)(10000.0 * x);
491  ypos = (int)(10000.0 * y);
492 
493  /* Centre y-height */
494  ypos -= (int)(1.0 * sFontHeight / 3.0);
495 
496  sprintf(buffer,"PU;PA%d, %d;", xpos, ypos);
497  fputs(buffer,sHPGLFile);
498  blHPGLShowText(text,0,xpos,ypos);
499 }
500 
501 /************************************************************************/
502 /*>void blHPGLCTText(REAL x, REAL y, REAL offset, char *text)
503  ----------------------------------------------------------
504 *//**
505 
506  \param[in] x X coordinate
507  \param[in] y Y coordinate
508  \param[in] offset Y offset in points. Move text down by this.
509  \param[in] *text Text to print
510 
511  Center Top justify text at x,y with y-offset in pts.
512 
513 - 25.06.92 Framework
514 - 26.06.92 Original
515 - 29.06.92 Added SimplifyText(). Changed to use HPGLShowText().
516 - 01.07.92 Corrected y-positioning. Changed offset to be in pts rather
517  than a multiplier of font size.
518 - 06.07.92 Modified x-pos for wider font width
519 - 07.07.14 Use bl prefix for functions By: CTP
520 */
522  REAL y,
523  REAL offset,
524  char *text)
525 {
526  char buffer[80];
527  int xpos,
528  ypos;
529 
530  xpos = (int)(10000.0 * x);
531  xpos -= (strlen(blSimplifyText(text)) * sFontWidth / 2.0);
532  xpos += sFontWidth/6;
533 
534  ypos = (int)(10000.0 * y);
535  /* Move down by height of font */
536  ypos -= sFontHeight;
537  /* Move by offset */
538  ypos += (int)((offset * 10000.0) / (72.0 * PSypicsize));
539 
540  sprintf(buffer,"PU;PA%d, %d;\n", xpos, ypos);
541  fputs(buffer,sHPGLFile);
542 
543  blHPGLShowText(text,0,xpos,ypos);
544 }
545 
546 /************************************************************************/
547 /*>void blHPGLVText(REAL x, REAL y, REAL xoff, char *text, int TitleFont,
548  REAL TitleSize, char *label, int LabelFont, REAL LabelSize)
549  -----------------------------------------------------------------------
550 *//**
551 
552  \param[in] x X coordinate (in data units)
553  \param[in] y Y coordinate (in data units)
554  \param[in] xoff X-offset in pts
555  \param[in] *text Text to be written
556  \param[in] *TitleFont Font in which to write it
557  \param[in] TitleSize Size of font
558  \param[in] *label Label to be used to calc x offset
559  \param[in] *LabelFont Font of this label
560  \param[in] LabelSize Size of this label
561 
562  Write vertical text centred on x,y offset back along x by the size of
563  label and by xoff in pts
564  The `label' specification is used to calculate an amount by
565  which to move the text back. Typically this would be the longest data
566  label on the graph's Y-axis.
567  The FIXVERT code is used to correct character dimensions. Not sure if
568  it is a bug in the PLT: interpreter which requires this, or whether
569  it is standard HPGL. Define FIXVERT if it improves your output.
570 
571 - 25.06.92 Framework
572 - 29.06.92 Original
573 - 06.07.92 Modified x-pos for wider font width
574 - 27.07.93 Changed precision of floating i/o to double
575 - 07.07.14 Use bl prefix for functions By: CTP
576 */
578  REAL y,
579  REAL xoff,
580  char *text,
581  int TitleFont,
582  REAL TitleSize,
583  char *label,
584  int LabelFont,
585  REAL LabelSize)
586 {
587  REAL LabelWidth;
588  char buffer[240];
589 
590 #ifdef FIXVERT
591  REAL width,
592  fixwidth,
593  height,
594  fixheight;
595 #endif
596 
597  /* Find size of label */
598  LabelWidth = strlen(blSimplifyText(label)) *
599  (LabelSize * 10000.0) / (2.0 * 72.0 * PSxpicsize);
600  /* Convert offset from points to plotter units */
601  xoff *= 10000.0 / (72.0 * PSxpicsize);
602 
603  /* Convert x & y to plotter coordinates */
604  x *= 10000.0;
605  y *= 10000.0;
606 
607  /* Modify the x-coordinate to account for the offsets */
608  x -= LabelWidth;
609  x += xoff;
610 
611  /* Now find the y-start to centre the string vertically */
612  y -= strlen(blSimplifyText(text)) * sFontWidth / 2;
613  y += sFontWidth/6;
614 
615 #ifdef FIXVERT
616  /* Character dimensions in centimeters. We convert pts to cm, then
617  divide by 1.7 to get a better size. Width is set to half height
618  */
619  height = TitleSize * 2.54 / (1.7 * 72.0);
620  width = height/2.0;
621 
622  fixwidth = width * PSxpicsize/PSypicsize;
623  fixheight = height * PSypicsize/PSxpicsize;
624 
625  sprintf(buffer,"PU;SI%5.3f, %5.3f;\n",fixwidth,fixheight);
626  fputs(buffer,sHPGLFile);
627 #endif
628 
629  /* Now output the text */
630  sprintf(buffer,"PU;PA%d,%d;DR0,1;",(int)x,(int)y);
631  fputs(buffer,sHPGLFile);
632  blHPGLShowText(text,1,(int)x,(int)y);
633  fputs("DR;\n",sHPGLFile);
634 
635 #ifdef FIXVERT
636  sprintf(buffer,"PU;SI%5.3f, %5.3f;\n",width,height);
637  fputs(buffer,sHPGLFile);
638 #endif
639 }
640 
641 /************************************************************************/
642 /*>void blHPGLEnd(void)
643  --------------------
644 *//**
645 
646  Close the HPGL plot file
647 
648 - 06.07.93 Original
649 - 07.07.14 Use bl prefix for functions By: CTP
650 */
651 void blHPGLEnd(void)
652 {
653  fclose(sHPGLFile);
654 }
655 
656 /************************************************************************/
657 /*>void blHPGLShowText(char *text, BOOL orientation, int XBase, int YBase)
658  -----------------------------------------------------------------------
659 *//**
660 
661  \param[in] *text Text to be displayed with control codes
662  \param[in] orientation TRUE=vertical, FALSE=horizontal
663  \param[in] XBase Position at which to start (device coords)
664  \param[in] YBase Position at which to start (device coords)
665 
666  Displays the text, raising or lowering as appropriate and selecting
667  alternate font where required. Used by the various ...Text() routines.
668 
669 - 29.06.92 Original based on PostScript version.
670 - 27.07.93 Changed precision of floating i/o to double
671 - 11.03.94 Changed orientation to BOOL
672 - 07.07.14 Use bl prefix for functions By: CTP
673 */
674 void blHPGLShowText(char *text,
675  BOOL orientation,
676  int XBase,
677  int YBase)
678 {
679  char buffer[MAXBUFF],
680  OutBuff[MAXBUFF];
681  int i, j,
682  chcount,
683  first = TRUE;
684  REAL fixwidth,
685  fixheight;
686 
687  /* Walk along the string */
688  for(i=0, j=0, chcount=0; i<strlen(text) && j<MAXBUFF-1; i++)
689  {
690  switch(text[i])
691  {
692  case '\\': /* Should interpret next character as Greek */
693  /* Finish the current string */
694  if(j)
695  {
696  buffer[j] = '\0';
697  sprintf(OutBuff,"LB%s\\;",buffer);
698  fputs(OutBuff,sHPGLFile);
699  j = 0;
700  }
701  /* Output the next character as Greek */
702  sprintf(OutBuff,"SA;LB%c\\;SS;",text[++i]);
703  fputs(OutBuff,sHPGLFile);
704  chcount++;
705  break;
706  case '^': /* Should raise next character */
707  /* Finish the current string */
708  if(j)
709  {
710  buffer[j] = '\0';
711  sprintf(OutBuff,"LB%s\\;",buffer);
712  fputs(OutBuff,sHPGLFile);
713  j = 0;
714  }
715 
716  if(first)
717  {
718  if(orientation) chcount++;
719  first = FALSE;
720  }
721 
722  /* Move to the shifted position */
723  if(orientation) /* VERTICAL */
724  sprintf(OutBuff,"PU;PA%d,%d;", XBase-sFontHeight/2,
725  (int)(YBase+(PSxpicsize*chcount*sFontWidth/PSypicsize)));
726  else /* HORIZONTAL */
727  sprintf(OutBuff,"PU;PA%d,%d;", XBase + chcount*sFontWidth,
728  YBase+sFontHeight/2);
729  fputs(OutBuff,sHPGLFile);
730 
731  /* If necessary build string */
732  if(text[++i] == '{')
733  {
734  while(text[++i] != '}' && text[i] != '\0' && j<MAXBUFF-1)
735  {
736  buffer[j++] = text[i];
737  chcount++;
738  }
739  }
740  else
741  {
742  buffer[j++] = text[i];
743  chcount++;
744  }
745  /* Output raised string */
746  if(j)
747  {
748  buffer[j] = '\0';
749  if(orientation)
750  {
751  fixwidth = sFontWcm * PSxpicsize/PSypicsize;
752  fixheight = sFontHcm * PSypicsize/PSxpicsize;
753  }
754  else
755  {
756  fixwidth = sFontWcm;
757  fixheight = sFontHcm;
758  }
759  sprintf(OutBuff,"PU;SI%f,%f;LB%s\\;PU;SI%f,%f;",
760  fixwidth,fixheight/2.0,buffer,fixwidth,fixheight);
761  fputs(OutBuff,sHPGLFile);
762  j = 0;
763  }
764  /* Reset position */
765  if(orientation) /* VERTICAL */
766  sprintf(OutBuff,"PU;PA%d,%d;", XBase,
767  (int)(YBase+(PSxpicsize*chcount*sFontWidth/PSypicsize)));
768  else /* HORIZONTAL */
769  sprintf(OutBuff,"PU;PA%d,%d;", XBase + chcount*sFontWidth,
770  YBase);
771  fputs(OutBuff,sHPGLFile);
772  break;
773  case '_': /* Should lower next character */
774  /* Finish the current string */
775  if(j)
776  {
777  buffer[j] = '\0';
778  sprintf(OutBuff,"LB%s\\;",buffer);
779  fputs(OutBuff,sHPGLFile);
780  j = 0;
781  }
782 
783  if(first)
784  {
785  if(orientation) chcount++;
786  first = FALSE;
787  }
788 
789  /* Move to the shifted position */
790  if(orientation) /* VERTICAL */
791  sprintf(OutBuff,"PU;PA%d,%d;", XBase+sFontHeight/4,
792  (int)(YBase+(PSxpicsize*chcount*sFontWidth/PSypicsize)));
793  else /* HORIZONTAL */
794  sprintf(OutBuff,"PU;PA%d,%d;", XBase + chcount*sFontWidth,
795  YBase-sFontHeight/4);
796  fputs(OutBuff,sHPGLFile);
797 
798  /* If necessary build string */
799  if(text[++i] == '{')
800  {
801  while(text[++i] != '}' && text[i] != '\0' && j<MAXBUFF-1)
802  {
803  buffer[j++] = text[i];
804  chcount++;
805  }
806  }
807  else
808  {
809  buffer[j++] = text[i];
810  chcount++;
811  }
812 
813  /* Output lowered string */
814  if(j)
815  {
816  buffer[j] = '\0';
817  if(orientation)
818  {
819  fixwidth = sFontWcm * PSxpicsize/PSypicsize;
820  fixheight = sFontHcm * PSypicsize/PSxpicsize;
821  }
822  else
823  {
824  fixwidth = sFontWcm;
825  fixheight = sFontHcm;
826  }
827  sprintf(OutBuff,"PU;SI%f,%f;LB%s\\;PU;SI%f,%f;",
828  fixwidth,fixheight/2.0,buffer,fixwidth,fixheight);
829  fputs(OutBuff,sHPGLFile);
830  j = 0;
831  }
832  /* Reset position */
833  if(orientation) /* VERTICAL */
834  sprintf(OutBuff,"PU;PA%d,%d;", XBase,
835  (int)(YBase+(PSxpicsize*chcount*sFontWidth/PSypicsize)));
836  else /* HORIZONTAL */
837  sprintf(OutBuff,"PU;PA%d,%d;", XBase + chcount*sFontWidth,
838  YBase);
839  fputs(OutBuff,sHPGLFile);
840 
841  break;
842  default: /* An ordinary character */
843  buffer[j++] = text[i];
844  chcount++;
845  break;
846  }
847  }
848 
849  if(j)
850  {
851  buffer[j] = '\0';
852  sprintf(OutBuff,"LB%s\\;",buffer);
853  fputs(OutBuff,sHPGLFile);
854  j = 0;
855  }
856 
857  if(strlen(text)) fputs("\n",sHPGLFile);
858 }
859 
void blHPGLCTText(REAL x, REAL y, REAL offset, char *text)
Definition: hpgl.c:521
REAL PSyoffset
short BOOL
Definition: SysDefs.h:64
#define NULL
Definition: array2.c:99
void blHPGLPen(int num)
Definition: hpgl.c:214
void blHPGLEnd(void)
Definition: hpgl.c:651
char * blSimplifyText(char *string)
Definition: plotting.c:915
#define FALSE
Definition: macros.h:223
void blHPGLShowText(char *text, BOOL orientation, int XBase, int YBase)
Definition: hpgl.c:674
void blHPGLCBText(REAL x, REAL y, REAL offset, char *text)
Definition: hpgl.c:400
void blHPGLSetDash(int style)
Definition: hpgl.c:286
Include file for using plotting routines.
double REAL
Definition: MathType.h:67
REAL PSypicsize
REAL PSxoffset
#define MAXBUFF
Definition: hpgl.c:126
#define TRUE
Definition: macros.h:219
void blHPGLROffText(REAL x, REAL y, REAL offset, char *text)
Definition: hpgl.c:440
void blHPGLMove(REAL x, REAL y)
Definition: hpgl.c:235
int blPS2HPGLFont(char *font)
Definition: plotting.c:803
void blHPGLLText(REAL x, REAL y, char *string)
Definition: hpgl.c:368
System-type variable type definitions.
REAL PSxpicsize
void blHPGLVText(REAL x, REAL y, REAL xoff, char *text, int TitleFont, REAL TitleSize, char *label, int LabelFont, REAL LabelSize)
Definition: hpgl.c:577
void blHPGLLCText(REAL x, REAL y, char *text)
Definition: hpgl.c:482
Type definitions for maths.
BOOL blHPGLInit(char *filename, char *AltFont, REAL xmargin, REAL ymargin)
Definition: hpgl.c:170
void blHPGLDraw(REAL x, REAL y)
Definition: hpgl.c:257
void blHPGLFont(int font, REAL size)
Definition: hpgl.c:327