Exemple #1
0
void
eda_cairo_arc (cairo_t *cr, int flags,
               double width, double x, double y,
               double radius, double start_angle, double sweep_angle)
{
  int s_width;
  double x1, y1, x2, y2;
  double s_x, s_y, s_radius;
  double offset, dummy = 0;

  if (!(flags & EDA_CAIRO_ENABLE_HINTS)) {
    do_arc (cr, x, y, radius, start_angle, sweep_angle);
    return;
  }

  WORLDtoSCREEN (cr, x - radius, y + radius, &x1, &y1);
  WORLDtoSCREEN (cr, x + radius, y - radius, &x2, &y2);
  s_width = screen_width (cr, width);
  offset = ((s_width % 2) == 0) ? 0 : 0.5;

  s_x = (double)(x1 + x2) / 2.;
  s_y = (double)(y1 + y2) / 2.;
  s_radius = (double)(y2 - y1) / 2.;

  cairo_device_to_user (cr, &s_x, &s_y);
  cairo_device_to_user_distance (cr, &offset, &dummy);
  cairo_device_to_user_distance (cr, &s_radius, &dummy);

  do_arc (cr, s_x + offset, s_y + offset,
          s_radius, start_angle, sweep_angle);
}
Exemple #2
0
void
eda_cairo_center_arc (cairo_t *cr, int flags,
                      double center_width,
                      double line_width, double x, double y,
                      double radius, double start_angle, double sweep_angle)
{
  int s_center_width, s_line_width;
  double s_x, s_y, dummy = 0;
  int s_diameter;
  double even_center_width;
  double even_line_width;
  double even_diameter;
  double center_offset;
  double s_radius;
  int do_radius_hint = TRUE;

  if (!(flags & EDA_CAIRO_ENABLE_HINTS)) {
    do_arc (cr, x, y, radius, start_angle, sweep_angle);
    return;
  }

  WORLDtoSCREEN (cr, x, y, &s_x, &s_y);
  s_diameter = SCREENabs (cr, 2 * radius);
  even_diameter = ((s_diameter % 2) == 0);
  s_radius = (double) s_diameter / 2.;

  /* Switch off radius hinting for small radii. If we don't, then we get
   * a very abrupt transition once the arc reaches a single pixel size. */
  if (s_radius <= 1.) do_radius_hint = FALSE;

  /* Hint the center of the arc based on where a line
   * of thickness center_width (world) would drawn */
  s_center_width = screen_width (cr, center_width);
  even_center_width = (center_width == -1 || (s_center_width % 2) == 0);
  center_offset = even_center_width ? 0. : 0.5;

  /* Hint the radius to land its extermity on the pixel grid */
  s_line_width = screen_width (cr, line_width);
  even_line_width = (line_width == -1 || (s_line_width % 2) == 0);
  if (do_radius_hint)
    s_radius += ((even_center_width ==
                        even_line_width) == even_diameter) ? 0. : 0.5;

  s_x += center_offset;
  s_y += center_offset;
  cairo_device_to_user (cr, &s_x, &s_y);
  cairo_device_to_user_distance (cr, &s_radius, &dummy);

  do_arc (cr, s_x, s_y, s_radius, start_angle, sweep_angle);
}
Exemple #3
0
void gschem_cairo_arc (GSCHEM_TOPLEVEL *w_current,
                       int width, int x, int y,
                       int radius, int start_angle, int end_angle)
{
  int s_width;
  int x1, y1, x2, y2;
  double s_x, s_y, s_radius;
  double offset;

  WORLDtoSCREEN (w_current, x - radius, y + radius, &x1, &y1);
  WORLDtoSCREEN (w_current, x + radius, y - radius, &x2, &y2);
  s_width = screen_width (w_current, width);
  offset = ((s_width % 2) == 0) ? 0 : 0.5;

  s_x = (double)(x1 + x2) / 2.;
  s_y = (double)(y1 + y2) / 2.;
  s_radius = (double)(y2 - y1) / 2.;

  cairo_save (w_current->cr);
  cairo_translate (w_current->cr, s_x + offset, s_y + offset);

  /* Adjust for non-uniform X/Y scale factor. Note that the + 1
     allows for the case where x2 == x1 or y2 == y1 */
  cairo_scale (w_current->cr, (double)(x2 - x1 + 1) /
                              (double)(y2 - y1 + 1), 1.);

  do_arc (w_current->cr, 0., 0., (double) s_radius, start_angle, end_angle);

  cairo_restore (w_current->cr);
}
Exemple #4
0
void gschem_cairo_center_arc (GSCHEM_TOPLEVEL *w_current,
                              int center_width,
                              int line_width, int x, int y,
                              int radius, int start_angle, int end_angle)
{
  int s_center_width, s_line_width;
  int s_x, s_y, s_diameter;
  int even_center_width;
  int even_line_width;
  int even_diameter;
  double center_offset;
  double s_radius;
  int do_radius_hint = TRUE;

  WORLDtoSCREEN (w_current, x, y, &s_x, &s_y);
  s_diameter = SCREENabs (w_current, 2 * radius);
  even_diameter = ((s_diameter % 2) == 0);
  s_radius = (double) s_diameter / 2.;

  /* Switch off radius hinting for small radii. If we don't, then we get
   * a very abrupt transition once the arc reaches a single pixel size. */
  if (s_radius <= 1.) do_radius_hint = FALSE;

  /* Hint the center of the arc based on where a line
   * of thickness center_width (world) would drawn */
  s_center_width = screen_width (w_current, center_width);
  even_center_width = (center_width == -1 || (s_center_width % 2) == 0);
  center_offset = even_center_width ? 0. : 0.5;

  /* Hint the radius to land its extermity on the pixel grid */
  s_line_width = screen_width (w_current, line_width);
  even_line_width = (line_width == -1 || (s_line_width % 2) == 0);
  if (do_radius_hint)
    s_radius += ((even_center_width ==
                        even_line_width) == even_diameter) ? 0. : 0.5;

  do_arc (w_current->cr, (double) s_x + center_offset,
                         (double) s_y + center_offset,
                         (double) s_radius,
                         start_angle, end_angle);
}
Exemple #5
0
	void
main(int argc, char **argv) {
	char *arg, **eargv = argv, *strnchr();
	FILE *fid;
	static int eargc = 0, c;

	if (emess_dat.Prog_name = strrchr(*argv,'/')) ++emess_dat.Prog_name;
	else emess_dat.Prog_name = *argv;
	inverse = ! strncmp(emess_dat.Prog_name, "inv", 3);
		/* process run line arguments */
	while (--argc > 0) { /* collect run line arguments */
		if(**++argv == '-') for(arg = *argv;;) {
			switch(*++arg) {
			case '\0': /* position of "stdin" */
				if (arg[-1] == '-') eargv[eargc++] = "-";
				break;
			case 'a': /* output full set of values */
				fullout = 1;
				continue;
			case 'I': /* alt. inverse spec. */
				inverse = 1;
				continue;
			case 't': /* set col. one char */
				if (arg[1]) tag = *++arg;
				else emess(1,"missing -t col. 1 tag");
				continue;
			case 'W': /* specify seconds precision */
			case 'w': /* -W for constant field width */
				if ((c = arg[1]) && isdigit(c)) {
					set_rtodms(c - '0', *arg == 'W');
					++arg;
				} else
				    emess(1,"-W argument missing or non-digit");
				continue;
			case 'f': /* alternate output format degrees or xy */
				if (--argc <= 0)
noargument:		   emess(1,"missing argument for -%c",*arg);
				oform = *++argv;
				continue;
			case 'F': /* alternate output format degrees or xy */
				if (--argc <= 0) goto noargument;
				osform = *++argv;
				continue;
			case 'l':
				if (!arg[1] || arg[1] == 'e') { /* list of ellipsoids */
					struct PJ_ELLPS *le;
	
					for (le = pj_ellps; le->id ; ++le)
						(void)printf("%9s %-16s %-16s %s\n",
						le->id, le->major, le->ell, le->name);
				 		emess(1,"invalid list option: l%c",arg[1]);
							emess(1,"-l[p|e] terminates program");
				} else if (arg[1] == 'u') { /* list of units */
					struct PJ_UNITS *lu;

					for (lu = pj_units; lu->id ; ++lu)
						(void)printf("%12s %-20s %s\n",
				 			lu->id, lu->to_meter, lu->name);
				} else
					emess(1,"invalid list option: l%c",arg[1]);
				emess(1,"will not proceed after display list option");
			case 'p': /* output azimuths as positive */
				pos_azi = 1;
				continue;
			default:
				emess(1, "invalid option: -%c",*arg);
				break;
			}
			break;
		} else if (**argv == '+') /* + argument */
			if (pargc < MAX_PARGS)
				pargv[pargc++] = *argv + 1;
			else
				emess(1,"overflowed + argument table");
		else /* assumed to be input file name(s) */
			eargv[eargc++] = *argv;
	}
	/* done with parameter and control input */
	geod_setup(pargc, pargv); /* setup projection */
	if ((n_alpha || n_S) && eargc)
		emess(1,"files specified for arc/geodesic mode");
	if (n_alpha)
		do_arc();
	else if (n_S)
		do_geod();
	else { /* process input file list */
		if (eargc == 0) /* if no specific files force sysin */
			eargv[eargc++] = "-";
		for ( ; eargc-- ; ++eargv) {
			if (**eargv == '-') {
				fid = stdin;
				emess_dat.File_name = "<stdin>";
			} else {
				if ((fid = fopen(*eargv, "r")) == NULL) {
					emess(-2, *eargv, "input file");
					continue;
				}
				emess_dat.File_name = *eargv;
			}
			emess_dat.File_line = 0;
			process(fid);
			(void)fclose(fid);
			emess_dat.File_name = (char *)0;
		}
	}
	exit(0); /* normal completion */
}