File: h_position.c

package info (click to toggle)
plotutils 2.0-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,964 kB
  • ctags: 2,522
  • sloc: ansic: 38,416; sh: 1,853; yacc: 856; makefile: 181; lex: 144
file content (44 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* This file contains a low-level method for moving the pen position of an
   HP-GL plotter to agree with an HPGLPlotter's notion of what the graphics
   cursor position should be.

   The state of the pen (up vs. down) after calling this function is not
   uniquely determined.  */

#include "sys-defines.h"
#include "plot.h"
#include "extern.h"

void
#ifdef _HAVE_PROTOS
_h_set_position (void)
#else
_h_set_position ()
#endif
{
  int xnew, ynew;
  
  /* if plotter's pen position doesn't agree with what it should be,
     adjust it */

  xnew = IROUND(XD(_plotter->drawstate->pos.x, _plotter->drawstate->pos.y));
  ynew = IROUND(YD(_plotter->drawstate->pos.x, _plotter->drawstate->pos.y));  

  if (_plotter->position_is_unknown == true
      || xnew != _plotter->pos.x || ynew != _plotter->pos.y)
    {
      if (_plotter->pendown == true)
	{
	  sprintf (_plotter->outbuf.current, "PU;PA%d,%d;", xnew, ynew);
	  _plotter->pendown = false;
	}
      else
	sprintf (_plotter->outbuf.current, "PA%d,%d;", xnew, ynew);
      _update_buffer (&_plotter->outbuf);

      /* update our knowledge of pen position */
      _plotter->position_is_unknown = false;
      _plotter->pos.x = xnew;
      _plotter->pos.y = ynew;
    }
}