예제 #1
0
int
gs_currentpoint(gs_state *pgs, gs_point *ppt)
{   gs_fixed_point pt;
    int code = gx_path_current_point(pgs->path, &pt);
    if ( code < 0 ) return code;
    return gs_itransform(pgs, fixed2float(pt.x), fixed2float(pt.y), ppt);
}
예제 #2
0
/* RO; */
int
hpgl_RO(hpgl_args_t *pargs, hpgl_state_t *pgls)
{	
	int angle=0;
	gs_point point, dev_pt;

	/* this business is used by both SC and RO -- perhaps it needs
           a new home */
	hpgl_call(hpgl_set_ctm(pgls));
	hpgl_call(hpgl_get_current_position(pgls, &point));
	hpgl_call(gs_transform(pgls->pgs, point.x, point.y, &dev_pt));

	if ( hpgl_arg_c_int(pgls->memory, pargs, &angle) )
	    switch ( angle )
	      {
	      case 0: case 90: case 180: case 270:
		break;
	      default:
		return e_Range;
	      }

        if ( angle != pgls->g.rotation )
	  {
	    hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
	    pgls->g.rotation = angle;
	    hpgl_call(hpgl_set_ctm(pgls));
	    hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
	    hpgl_call(hpgl_set_current_position(pgls, &point));
	    hpgl_call(hpgl_update_carriage_return_pos(pgls));
	  }
	return 0;
}
예제 #3
0
int
gs_currentpoint(gs_state * pgs, gs_point * ppt)
{
    if (!pgs->current_point_valid)
	return_error(gs_error_nocurrentpoint);
    return gs_itransform(pgs, pgs->current_point.x, 
			      pgs->current_point.y, ppt);
}
예제 #4
0
/* set variables other than setting the page device that do not
   default to pcl reset values */
void
pxPassthrough_pcl_state_nonpage_exceptions(px_state_t * pxs)
{
    /* xl cursor -> pcl cursor position */
    gs_point xlcp, pclcp, dp;

    /* make the pcl ctm active, after resets the hpgl/2 ctm is
       active. */
    pcl_set_graphics_state(global_pcs);
    /* xl current point -> device point -> pcl current
       point.  If anything fails we assume the current
       point is not valid and use the cap from the pcl
       state initialization - pcl's origin */
    if (gs_currentpoint(pxs->pgs, &xlcp) ||
        gs_transform(pxs->pgs, xlcp.x, xlcp.y, &dp) ||
        gs_itransform(global_pcs->pgs, dp.x, dp.y, &pclcp)) {
        global_pcs->cap.x = 0;
        global_pcs->cap.y = inch2coord(2.0 / 6.0);      /* 1/6" off by 2x in resolution. */
        if (gs_debug_c('i'))
            dmprintf2(pxs->memory,
                      "passthrough: changing cap NO currentpoint (%d, %d) \n",
                      global_pcs->cap.x, global_pcs->cap.y);
    } else {
        if (gs_debug_c('i'))
            dmprintf8(pxs->memory,
                      "passthrough: changing cap from (%d,%d) (%d,%d) (%d, %d) (%d, %d) \n",
                      global_pcs->cap.x, global_pcs->cap.y, (coord) xlcp.x,
                      (coord) xlcp.y, (coord) dp.x, (coord) dp.y,
                      (coord) pclcp.x, (coord) pclcp.y);
        global_pcs->cap.x = (coord) pclcp.x;
        global_pcs->cap.y = (coord) pclcp.y;
    }
    if (global_pcs->underline_enabled)
        global_pcs->underline_start = global_pcs->cap;


    global_char_angle = pxs->pxgs->char_angle;
    global_char_shear.x = pxs->pxgs->char_shear.x;
    global_char_shear.y = pxs->pxgs->char_shear.y;
    global_char_scale.x = pxs->pxgs->char_scale.x;
    global_char_scale.y = pxs->pxgs->char_scale.y;
    global_char_bold_value = pxs->pxgs->char_bold_value;

}
예제 #5
0
파일: rtmisc.c 프로젝트: ststeiger/ghostsvg
/*
 * We export this so we can call it from HP-GL/2 configurations.
 * Note that it returns 1 iff it changed the PCL CAP.
 *
 * ESC % <enum> A
 */ 
  int
rtl_enter_pcl_mode(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    int             b = int_arg(pargs) & 1;

    if ( pcs->parse_other == 
	 (int(*)(void *, pcl_state_t *, stream_cursor_read *))hpgl_process ) {
        /* 
         * We were in HP-GL/2 mode.  Destroy the gl/2 polygon path
	 * and conditionally copy back the cursor position.
         */
	if (b != 0) {
            /* the usual user -> device -> user dance. */
	    gs_point    pt, dev_pt;

	    hpgl_call_mem(pcs->memory, hpgl_set_ctm(pcs));
	    hpgl_call_mem(pcs->memory, hpgl_get_current_position(pcs, &pt));
	    hpgl_call_mem(pcs->memory, gs_transform(pcs->pgs, pt.x, pt.y, &dev_pt));
	    hpgl_call_mem(pcs->memory, pcl_set_ctm(pcs, true));
	    hpgl_call_mem(pcs->memory, gs_itransform(pcs->pgs, dev_pt.x, dev_pt.y, &pt));

	    /* HPGL/2 uses floats for coordinates */
#define round(x)    (((x) < 0.0) ? (ceil ((x) - 0.5)) : (floor ((x) + 0.5)))
	    pcs->cap.x = round(pt.x);
	    pcs->cap.y = round(pt.y);
#undef round
	}
    } else
	  b = 0;

    pcs->parse_other = 0;
    return b;		/* not 0, see comment above */
}
예제 #6
0
/* SC; */
int
hpgl_SC(hpgl_args_t *pargs, hpgl_state_t *pgls)
{	hpgl_real_t xy[4];
	int i;
	int type;
	hpgl_scaling_params_t scale_params;
	gs_point point, dev_pt, dev_anchor;

	scale_params = pgls->g.scaling_params;
	hpgl_call(hpgl_get_current_position(pgls, &point));
	hpgl_call(gs_transform(pgls->pgs, point.x, point.y, &dev_pt));
	hpgl_call(gs_transform(pgls->pgs, pgls->g.anchor_corner.x, 
			       pgls->g.anchor_corner.y, &dev_anchor));
	for ( i = 0; i < 4 && hpgl_arg_real(pgls->memory, pargs, &xy[i]); ++i )
	  ;
	switch ( i )
	  {
	  case 0:		/* set defaults */
              {
                  /* a naked SC implies the soft clip window is bound
                     to plotter units.  */
                  gs_matrix umat;
                  type = hpgl_scaling_none;
                  hpgl_compute_user_units_to_plu_ctm(pgls, &umat);
                  /* in-place */
                  hpgl_call(gs_bbox_transform(&pgls->g.soft_clip_window.rect,
                                              &umat,
                                              &pgls->g.soft_clip_window.rect));
                  pgls->g.soft_clip_window.isbound = true;
                  break;
              }
	  default:
	    return e_Range;
	  case 4:
	    type = hpgl_scaling_anisotropic;
	    hpgl_arg_c_int(pgls->memory, pargs, &type);
	    switch ( type )
	      {
	      case hpgl_scaling_anisotropic: /* 0 */
		if ( xy[0] == xy[1] || xy[2] == xy[3] )
		  return e_Range;
pxy:		scale_params.pmin.x = xy[0];
		scale_params.pmax.x = xy[1];
		scale_params.pmin.y = xy[2];
		scale_params.pmax.y = xy[3];
		break;
	      case hpgl_scaling_isotropic: /* 1 */
		if ( xy[0] == xy[1] || xy[2] == xy[3] )
		  return e_Range;
		{ hpgl_real_t left = 50, bottom = 50;
		  if ( (hpgl_arg_c_real(pgls->memory, pargs, &left) &&
			(left < 0 || left > 100 ||
			 !hpgl_arg_c_real(pgls->memory, pargs, &bottom) ||
			 bottom < 0 || bottom > 100))
		     )
		    return e_Range;
		  scale_params.left = left;
		  scale_params.bottom = bottom;
		}
		goto pxy;
	      case hpgl_scaling_point_factor: /* 2 */
		if ( xy[1] == 0 || xy[3] == 0 )
		  return e_Range;
		scale_params.pmin.x = xy[0];
		scale_params.factor.x = xy[1];
		scale_params.pmin.y = xy[2];
		scale_params.factor.y = xy[3];
		break;
	      default:
		return e_Range;
	      }
	  }
	hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
	pgls->g.scaling_params = scale_params;
	pgls->g.scaling_type = type;
	hpgl_call(hpgl_set_ctm(pgls));
	hpgl_call(gs_itransform(pgls->pgs, dev_pt.x, dev_pt.y, &point));
	hpgl_call(hpgl_set_current_position(pgls, &point));
	hpgl_call(gs_itransform(pgls->pgs, dev_anchor.x, dev_anchor.y, 
				&pgls->g.anchor_corner));

	/* PCLTRM 23-7 (commands the update cr position) does not list
           SC but PCL updates the position */
	hpgl_call(hpgl_update_carriage_return_pos(pgls));
	return 0;
}
예제 #7
0
/* The part of the DF command applicable for overlay macros */
int
hpgl_reset_overlay(hpgl_state_t *pgls)
{	hpgl_args_t args;
	hpgl_args_setup(&args);
	hpgl_AC(&args, pgls);
	hpgl_args_setup(&args);
	pgls->g.font_selected = 0;
	hpgl_AD(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_SD(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_CF(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_args_add_int(&args, 1);
	hpgl_args_add_int(&args, 0);
	hpgl_DI(&args, pgls);
	/* HAS -- Figure out some way to do this so that it is consistant */
	pgls->g.label.terminator = 3;
	pgls->g.label.print_terminator = false;
	hpgl_args_setup(&args);
	hpgl_DV(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_ES(&args, pgls);
	pgls->g.label.write_vertical = false;
	pgls->g.label.double_byte = false;
	hpgl_args_setup(&args);
	hpgl_LM(&args, pgls);
	hpgl_args_set_int(&args, 1);
	hpgl_LO(&args, pgls);
	/* we do this instead of calling SC directly */
        if ( pgls->g.scaling_type != hpgl_scaling_none ) {
            gs_point dpt, pt; /* device point and user point */
            hpgl_call(hpgl_get_current_position(pgls, &pt));
            hpgl_call(gs_transform(pgls->pgs, pt.x, pt.y, &dpt));
            pgls->g.scaling_type = hpgl_scaling_none;
            hpgl_call(hpgl_set_ctm(pgls));
            hpgl_call(gs_itransform(pgls->pgs, dpt.x, dpt.y, &pt));
            hpgl_call(hpgl_set_current_position(pgls, &pt));
        }
	pgls->g.fill_type = hpgl_even_odd_rule;
	hpgl_args_set_int(&args,0);
	hpgl_PM(&args, pgls);
	hpgl_args_set_int(&args,2);
	hpgl_PM(&args, pgls);
	pgls->g.bitmap_fonts_allowed = 0;
	hpgl_args_setup(&args);
	hpgl_SI(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_SL(&args, pgls);
	/* We initialize symbol mode directly because hpgl_SM parses
           its argument differently than most other commands */
	pgls->g.symbol_mode = 0;
	hpgl_args_setup(&args);
	hpgl_SS(&args, pgls);
	hpgl_args_set_int(&args,1);
	hpgl_TR(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_TD(&args, pgls);
	hpgl_args_setup(&args);
	hpgl_MC(&args, pgls);
#ifdef LJ6_COMPAT
	/* LJ6 seems to reset PP with an IN command the Color Laserjet
           does not.  NB this needs to be handled with dynamic
           configuration */
	hpgl_args_setup(&args);
	hpgl_PP(&args, pgls);
#endif
        return 0;
}