Esempio n. 1
0
void
ghid_draw_line (hidGC gc, int x1, int y1, int x2, int y2)
{
    double dx1, dy1, dx2, dy2;

    dx1 = Vx ((double) x1);
    dy1 = Vy ((double) y1);
    dx2 = Vx ((double) x2);
    dy2 = Vy ((double) y2);

    if (!ClipLine (0, 0, gport->width, gport->height,
                   &dx1, &dy1, &dx2, &dy2, gc->width / gport->zoom))
        return;

    USE_GC (gc);
    gdk_draw_line (gport->drawable, gport->u_gc, dx1, dy1, dx2, dy2);
}
Esempio n. 2
0
void
ghid_fill_circle (hidGC gc, int cx, int cy, int radius)
{
    gint w, h, vr;

    w = gport->width * gport->zoom;
    h = gport->height * gport->zoom;
    if (SIDE_X (cx) < gport->view_x0 - radius
            || SIDE_X (cx) > gport->view_x0 + w + radius
            || SIDE_Y (cy) < gport->view_y0 - radius
            || SIDE_Y (cy) > gport->view_y0 + h + radius)
        return;

    USE_GC (gc);
    vr = Vz (radius);
    gdk_draw_arc (gport->drawable, gport->u_gc, TRUE,
                  Vx (cx) - vr, Vy (cy) - vr, vr * 2, vr * 2, 0, 360 * 64);
}
Esempio n. 3
0
void
ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
{
  double dx1, dy1, dx2, dy2;
  render_priv *priv = gport->render_priv;

  dx1 = Vx ((double) x1);
  dy1 = Vy ((double) y1);
  dx2 = Vx ((double) x2);
  dy2 = Vy ((double) y2);

  if (!ClipLine (0, 0, gport->width, gport->height,
		 &dx1, &dy1, &dx2, &dy2, gc->width / gport->view.coord_per_px))
    return;

  USE_GC (gc);
  gdk_draw_line (gport->drawable, priv->u_gc, dx1, dy1, dx2, dy2);
}
Esempio n. 4
0
void
ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius)
{
  gint w, h, vr;
  render_priv *priv = gport->render_priv;

  w = gport->width * gport->view.coord_per_px;
  h = gport->height * gport->view.coord_per_px;
  if (SIDE_X (cx) < gport->view.x0 - radius
      || SIDE_X (cx) > gport->view.x0 + w + radius
      || SIDE_Y (cy) < gport->view.y0 - radius
      || SIDE_Y (cy) > gport->view.y0 + h + radius)
    return;

  USE_GC (gc);
  vr = Vz (radius);
  gdk_draw_arc (gport->drawable, priv->u_gc, TRUE,
		Vx (cx) - vr, Vy (cy) - vr, vr * 2, vr * 2, 0, 360 * 64);
}
Esempio n. 5
0
void
ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
{
  gint w, h, lw;
  render_priv *priv = gport->render_priv;

  lw = gc->width;
  w = gport->width * gport->view.coord_per_px;
  h = gport->height * gport->view.coord_per_px;

  if ((SIDE_X (x1) < gport->view.x0 - lw
       && SIDE_X (x2) < gport->view.x0 - lw)
      || (SIDE_X (x1) > gport->view.x0 + w + lw
	  && SIDE_X (x2) > gport->view.x0 + w + lw)
      || (SIDE_Y (y1) < gport->view.y0 - lw
	  && SIDE_Y (y2) < gport->view.y0 - lw)
      || (SIDE_Y (y1) > gport->view.y0 + h + lw
	  && SIDE_Y (y2) > gport->view.y0 + h + lw))
    return;

  x1 = Vx (x1);
  y1 = Vy (y1);
  x2 = Vx (x2);
  y2 = Vy (y2);

  if (x1 > x2)
    {
      gint xt = x1;
      x1 = x2;
      x2 = xt;
    }
  if (y1 > y2)
    {
      gint yt = y1;
      y1 = y2;
      y2 = yt;
    }

  USE_GC (gc);
  gdk_draw_rectangle (gport->drawable, priv->u_gc, FALSE,
		      x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
Esempio n. 6
0
void
ghid_fill_polygon (hidGC gc, int n_coords, int *x, int *y)
{
    static GdkPoint *points = 0;
    static int npoints = 0;
    int i;
    USE_GC (gc);

    if (npoints < n_coords)
    {
        npoints = n_coords + 1;
        points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint));
    }
    for (i = 0; i < n_coords; i++)
    {
        points[i].x = Vx (x[i]);
        points[i].y = Vy (y[i]);
    }
    gdk_draw_polygon (gport->drawable, gport->u_gc, 1, points, n_coords);
}
Esempio n. 7
0
void
ghid_draw_rect (hidGC gc, int x1, int y1, int x2, int y2)
{
    gint w, h, lw;

    lw = gc->width;
    w = gport->width * gport->zoom;
    h = gport->height * gport->zoom;

    if ((SIDE_X (x1) < gport->view_x0 - lw
            && SIDE_X (x2) < gport->view_x0 - lw)
            || (SIDE_X (x1) > gport->view_x0 + w + lw
                && SIDE_X (x2) > gport->view_x0 + w + lw)
            || (SIDE_Y (y1) < gport->view_y0 - lw
                && SIDE_Y (y2) < gport->view_y0 - lw)
            || (SIDE_Y (y1) > gport->view_y0 + h + lw
                && SIDE_Y (y2) > gport->view_y0 + h + lw))
        return;

    x1 = Vx (x1);
    y1 = Vy (y1);
    x2 = Vx (x2);
    y2 = Vy (y2);

    if (x1 > x2)
    {
        gint xt = x1;
        x1 = x2;
        x2 = xt;
    }
    if (y1 > y2)
    {
        gint yt = y1;
        y1 = y2;
        y2 = yt;
    }

    USE_GC (gc);
    gdk_draw_rectangle (gport->drawable, gport->u_gc, FALSE,
                        x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
Esempio n. 8
0
void
ghid_fill_rect (hidGC gc, int x1, int y1, int x2, int y2)
{
    gint w, h, lw, xx, yy;

    lw = gc->width;
    w = gport->width * gport->zoom;
    h = gport->height * gport->zoom;

    if ((SIDE_X (x1) < gport->view_x0 - lw
            && SIDE_X (x2) < gport->view_x0 - lw)
            || (SIDE_X (x1) > gport->view_x0 + w + lw
                && SIDE_X (x2) > gport->view_x0 + w + lw)
            || (SIDE_Y (y1) < gport->view_y0 - lw
                && SIDE_Y (y2) < gport->view_y0 - lw)
            || (SIDE_Y (y1) > gport->view_y0 + h + lw
                && SIDE_Y (y2) > gport->view_y0 + h + lw))
        return;

    x1 = Vx (x1);
    y1 = Vy (y1);
    x2 = Vx (x2);
    y2 = Vy (y2);
    if (x2 < x1)
    {
        xx = x1;
        x1 = x2;
        x2 = xx;
    }
    if (y2 < y1)
    {
        yy = y1;
        y1 = y2;
        y2 = yy;
    }
    USE_GC (gc);
    gdk_draw_rectangle (gport->drawable, gport->u_gc, TRUE,
                        x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
Esempio n. 9
0
void
ghid_draw_arc (hidGC gc, Coord cx, Coord cy,
	       Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle)
{
  gint vrx, vry;
  gint w, h, radius;
  render_priv *priv = gport->render_priv;

  w = gport->width * gport->view.coord_per_px;
  h = gport->height * gport->view.coord_per_px;
  radius = (xradius > yradius) ? xradius : yradius;
  if (SIDE_X (cx) < gport->view.x0 - radius
      || SIDE_X (cx) > gport->view.x0 + w + radius
      || SIDE_Y (cy) < gport->view.y0 - radius
      || SIDE_Y (cy) > gport->view.y0 + h + radius)
    return;

  USE_GC (gc);
  vrx = Vz (xradius);
  vry = Vz (yradius);

  if (gport->view.flip_x)
    {
      start_angle = 180 - start_angle;
      delta_angle = -delta_angle;
    }
  if (gport->view.flip_y)
    {
      start_angle = -start_angle;
      delta_angle = -delta_angle;
    }
  /* make sure we fall in the -180 to +180 range */
  start_angle = NormalizeAngle (start_angle);
  if (start_angle >= 180)  start_angle -= 360;

  gdk_draw_arc (gport->drawable, priv->u_gc, 0,
		Vx (cx) - vrx, Vy (cy) - vry,
		vrx * 2, vry * 2, (start_angle + 180) * 64, delta_angle * 64);
}
Esempio n. 10
0
void
ghid_draw_arc (hidGC gc, int cx, int cy,
               int xradius, int yradius, int start_angle, int delta_angle)
{
    gint vrx, vry;
    gint w, h, radius;

    w = gport->width * gport->zoom;
    h = gport->height * gport->zoom;
    radius = (xradius > yradius) ? xradius : yradius;
    if (SIDE_X (cx) < gport->view_x0 - radius
            || SIDE_X (cx) > gport->view_x0 + w + radius
            || SIDE_Y (cy) < gport->view_y0 - radius
            || SIDE_Y (cy) > gport->view_y0 + h + radius)
        return;

    USE_GC (gc);
    vrx = Vz (xradius);
    vry = Vz (yradius);

    if (ghid_flip_x)
    {
        start_angle = 180 - start_angle;
        delta_angle = -delta_angle;
    }
    if (ghid_flip_y)
    {
        start_angle = -start_angle;
        delta_angle = -delta_angle;
    }
    /* make sure we fall in the -180 to +180 range */
    start_angle = (start_angle + 360 + 180) % 360 - 180;

    gdk_draw_arc (gport->drawable, gport->u_gc, 0,
                  Vx (cx) - vrx, Vy (cy) - vry,
                  vrx * 2, vry * 2, (start_angle + 180) * 64, delta_angle * 64);
}