File: g_erase.c

package info (click to toggle)
plotutils 2.4.1-15
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 11,072 kB
  • ctags: 6,952
  • sloc: ansic: 76,305; cpp: 12,402; sh: 8,475; yacc: 2,604; makefile: 894; lex: 144
file content (91 lines) | stat: -rw-r--r-- 2,723 bytes parent folder | download | duplicates (3)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* This file contains the erase method, which is a standard part of
   libplot.  It erases all objects on the graphics device display.

   This generic version is designed mostly for Plotters that do not do
   real-time plotting, and have no internal state.  It simply resets the
   output buffer for the current `page', discarding all objects written 
   to it. */

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

int
#ifdef _HAVE_PROTOS
_API_erase (S___(Plotter *_plotter))
#else
_API_erase (S___(_plotter))
     S___(Plotter *_plotter;) 
#endif
{
  bool retval1;
  int retval2 = 0;

  if (!_plotter->data->open)
    {
      _plotter->error (R___(_plotter) 
		       "erase: invalid operation");
      return -1;
    }

  _API_endpath (S___(_plotter)); /* flush path if any */

  switch ((int)_plotter->data->output_model)
    {
    case (int)PL_OUTPUT_NONE:
      /* Plotter doesn't do output, so do nothing */
      break;

    case (int)PL_OUTPUT_ONE_PAGE:
    case (int)PL_OUTPUT_ONE_PAGE_AT_A_TIME:
    case (int)PL_OUTPUT_PAGES_ALL_AT_ONCE:
      /* the builtin plOutbuf mechanism is being used for storing pages, so
	 remove all stored graphics code from the buffer corresponding to
	 the current page; reset page bounding box, etc. */
      if (_plotter->data->page)	/* paranoid */
	_reset_outbuf (_plotter->data->page);
      break;

    case (int)PL_OUTPUT_VIA_CUSTOM_ROUTINES:
    case (int)PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME:
    case (int)PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM:
      /* Plotter does its own output, and doesn't use libplot's
	 plOutbuf-based output system.  So do nothing. */
      break;

    default:			/* shouldn't happen */
      break;
    }

  /* Invoke Plotter-specific method to do device-dependent aspects of page
     erasure.  For example, reset the elements of the Plotter that keep
     track of the output device's graphics state to their default
     values. */
  retval1 = _plotter->erase_page (S___(_plotter));

  /* if Plotter is using custom output routines, and is, or could be,
     drawing graphics in real time, flush out the erasure */
  if (_plotter->data->output_model == 
      PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME
      || _plotter->data->output_model == 
      PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM)
    retval2 = _API_flushpl (S___(_plotter));

  /* on to next frame */
  _plotter->data->frame_number++;

  return (retval1 == true && retval2 == 0 ? 0 : -1);
}

/* Plotter-specific things that take place when erase() is invoked.  In a
   generic Plotter, this does nothing. */

bool
#ifdef _HAVE_PROTOS
_g_erase_page (S___(Plotter *_plotter))
#else
_g_erase_page (S___(_plotter))
     S___(Plotter *_plotter;) 
#endif
{
  return true;
}