summaryrefslogtreecommitdiff
path: root/pcl/pcl/pgmisc.c
blob: 46ceb0a4b2c1928265e9aa09980db2285e9b2774 (plain)
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
/* Copyright (C) 2001-2023 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
   CA 94129, USA, for further information.
*/


/* pgmisc.c */
/* HP-GL/2 miscellaneous support */

#include "pgmand.h"
#include "pgmisc.h"

bool
current_units_out_of_range(hpgl_real_t x)
{
    const hpgl_real_t max = (1 << 30) - 1;
    const hpgl_real_t min = -(1 << 30);

    /* Not much to do about the floating point equality checking here
       The problem is the coordinates should already be in an exact
       (fixed) representation at this time but they are not so we make
       due with the following. */
    return (x < min || x > max);
}

void
hpgl_set_lost_mode(hpgl_state_t * pgls, hpgl_lost_mode_t lost_mode)
{
    if (lost_mode == hpgl_lost_mode_entered) {
#ifdef INFINITE_LOOP
        hpgl_args_t args;

        /* raise the pen.  Note this should handle the pcl oddity
           that when lost mode is cleared with an absolute PD we
           draw a line from the last valid position to the first
           args of pen down.  The following appends a moveto the
           current point in the gs path */
        hpgl_args_setup(&args);
        hpgl_call(hpgl_PU(&args, pgls));
#endif
#ifdef DEBUG
        dmprintf(pgls->memory, "entering lost mode\n");
#endif
    }
    pgls->g.lost_mode = lost_mode;

}

#ifdef DEBUG

/* Print an error message.  Note that function may be NULL. */
/* This procedure must return its 'code' argument: see pgmisc.h. */
int
hpgl_print_error(const gs_memory_t * mem,
                 const char *function, const char *file, int line, int code)
{
    dmprintf4(mem,
              "hpgl call failed\n\tcalled from: %s\n\tfile: %s\n\tline: %d\n\terror code: %d\n",
              (function == 0 ? "" : function), file, line, code);
    hpgl_error();
    return code;
}

/* called when there is a graphics error.  Keep a breakpoint on this function */
void
hpgl_error()
{
    return;
}
#endif