예제 #1
0
/* IR; */
int
hpgl_IR(hpgl_args_t *pargs, hpgl_state_t *pgls)
{	hpgl_real_t rptxy[4];
	int i;
	hpgl_args_t args;
	gs_int_rect win;

	for ( i = 0; i < 4 && hpgl_arg_c_real(pgls->memory, pargs, &rptxy[i]); ++i )
	  ;
	if ( i & 1 )
	  return e_Range;

	/* get the PCL picture frame coordinates */
	hpgl_call(hpgl_picture_frame_coords(pgls, &win));
	hpgl_args_setup(&args);
        if ( i != 0 )
          {
            hpgl_args_add_int(&args, win.p.x + (win.q.x - win.p.x) *
                              rptxy[0] / 100.0);
            hpgl_args_add_int(&args, win.p.y + (win.q.y - win.p.y) *
                              rptxy[1] / 100.0);
          }
	if ( i == 4 )
	  {
	    hpgl_args_add_int(&args, win.p.x + (win.q.x - win.p.x) *
			      rptxy[2] / 100.0);

	    hpgl_args_add_int(&args, win.p.y + (win.q.y - win.p.y) *
			      rptxy[3] / 100.0);
	  }
	hpgl_IP( &args, pgls );
	return 0;
}
예제 #2
0
/*
 * The "implicit" portion of the IN command.
 *
 * With the advent of PCL 5c, both PCL and GL want to reset the current
 * palette. The difficulty is that they want to reset it to different things.
 *
 * The proper way to handle this would be to implement IN as a reset type,
 * create a single palette reset routine, and have it do different things
 * depending on the nature of the reset.
 *
 * At the time this comment was written, such a change was larger than could
 * be easily accommodated. Hence, a less drastic alternative was employed:
 * split the IN command into implicit and explicit portions, and only use the
 * latter when the IN command is explicitly invoked.
 */
  int
hpgl_IN_implicit(
    hpgl_state_t *  pgls\
)
{
    hpgl_args_t     args;

    /* cancel rotation */
    pgls->g.rotation = 0;
    /* restore defaults */
    hpgl_DF(&args, pgls);

    /* if in RTL mode provided initial values for PS */
    if ( pgls->personality == rtl ) {
        hpgl_args_setup(&args);
        hpgl_PS(&args, pgls);
    }
            
    /* defaults P1 and P2 */
    hpgl_args_setup(&args);
    hpgl_IP(&args, pgls);

    /* pen width units - metric, also resets pen widths.   */
    hpgl_args_setup(&args);
    hpgl_WU(&args, pgls);


    /*
     * pen up-absolute position and set gl/2 current positon to
     * 0,0 or the lower left of the picture frame.  Simply sets
     * the gl/2 state, we subsequently clear the path because we
     * do not want to create a live gs path.
     */
    hpgl_args_set_real2(&args, 0.0, 0.0);
    hpgl_PU(&args, pgls);
    hpgl_args_set_real2(&args, 0.0, 0.0);
    hpgl_PA(&args, pgls);
    hpgl_call(hpgl_clear_current_path(pgls));

    return 0;
}
예제 #3
0
void
hpgl_do_reset(pcl_state_t * pcs, pcl_reset_type_t type)
{
    /* pgframe.c (Chapter 18) */
    hpgl_args_t hpgl_args;

    if ((type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_cold)) !=
        0) {
        if ((type & (pcl_reset_initial | pcl_reset_cold)) != 0) {
            gx_path_alloc_contained(&pcs->g.polygon.buffer.path,
                                    pcs->memory,
                                    "hpgl_do_reset polygon buffer");
            gs_setlimitclamp(pcs->pgs, true);
        } else
            gx_path_new(&pcs->g.polygon.buffer.path);

        /* provide default anchor point, plot size and picture frame size */
        hpgl_default_coordinate_system(pcs);

        /* we should not have a path at this point but we make sure */
        hpgl_clear_current_path(pcs);

        /* Initialize stick/arc font instances */
        hpgl_initialize_stick_fonts(pcs);

        /* intialize subpolygon started hack flag */
        pcs->g.subpolygon_started = false;

        /* indicates a line down operation has been done in polygon
           mode */
        pcs->g.have_drawn_in_path = false;
        /* execute only the implicit portion of IN */
        hpgl_IN_implicit(pcs);

        /* we select the default pen 1 here, oddly, IN does not select
           the default pen even though it sets pen widths and units of
           measure */
        pcs->g.pen.selected = 1;
    }
    /* NB check all of these */
    if ((type & pcl_reset_page_params) != 0) {
        /* provide default anchor point, plot size and picture frame
           size.  Oddly HP does not reset the scaling parameters
           when the page size is changed. */
        int scale_type = pcs->g.scaling_type;
        hpgl_scaling_params_t params = pcs->g.scaling_params;

        hpgl_default_coordinate_system(pcs);

        /* restore the scaling parameter. */
        pcs->g.scaling_type = scale_type;
        pcs->g.scaling_params = params;

        hpgl_args_setup(&hpgl_args);
        hpgl_IW(&hpgl_args, pcs);
        hpgl_args_set_int(&hpgl_args, 0);
        hpgl_PM(&hpgl_args, pcs);
        hpgl_args_set_int(&hpgl_args, 2);
        hpgl_PM(&hpgl_args, pcs);
        hpgl_args_setup(&hpgl_args);
        hpgl_IP(&hpgl_args, pcs);
    }

    if ((type & pcl_reset_picture_frame) != 0) {
        /* this shouldn't happen.  Picture frame side effects are
           handled directly by the command picture frame command. */
        dmprintf(pcs->memory, "PCL reset picture frame received\n");
    }

    if ((type & pcl_reset_overlay) != 0)
        /* ignore return */
        (void)hpgl_reset_overlay(pcs);

    if ((type & (pcl_reset_plot_size)) != 0) {
        /* this shouldn't happen.  Plot size side effects are handled
           directly by the command picture frame command. */
        dmprintf(pcs->memory, "PCL reset plot received\n");
    }

    if ((type & (pcl_reset_permanent)) != 0) {
        gx_path_free(&pcs->g.polygon.buffer.path,
                     "hpgl_do_reset polygon buffer");
        /* if we have allocated memory for a stick font free the memory */
        hpgl_free_stick_fonts(pcs);
    }
    return;
}