示例#1
0
static void
add_linearrow(F_line *line, F_point *prev_point, F_point *selected_point)
{
    if (line->points->next == NULL)
	return;			/* A single point line */

    if (prev_point == NULL) {	/* selected_point is the first point */
	if (line->back_arrow)
	    return;
	line->back_arrow = backward_arrow();
	redisplay_line(line);
    } else if (selected_point->next == NULL) {	/* forward arrow */
	if (line->for_arrow)
	    return;
	line->for_arrow = forward_arrow();
	redisplay_line(line);
    } else
	return;
    clean_up();
    set_last_prevpoint(prev_point);
    set_last_selectedpoint(selected_point);
    set_latestline(line);
    set_action_object(F_ADD_ARROW_HEAD, O_POLYLINE);
    set_modifiedflag();
}
示例#2
0
void
delete_splinearrow(F_spline *spline, F_point *prev_point, F_point *selected_point)
{
    if (closed_spline(spline))
	return;
    if (prev_point == NULL) {	/* selected_point is the first point */
	if (!spline->back_arrow)
	    return;
	draw_spline(spline, ERASE);
	saved_back_arrow=spline->back_arrow;
	if (saved_for_arrow && saved_for_arrow != spline->for_arrow)
	    free((char *) saved_for_arrow);
	saved_for_arrow = NULL;
	spline->back_arrow = NULL;
	redisplay_spline(spline);
    } else if (selected_point->next == NULL) {	/* forward arrow */
	if (!spline->for_arrow)
	    return;
	draw_spline(spline, ERASE);
	saved_for_arrow=spline->for_arrow;
	if (saved_back_arrow && saved_back_arrow != spline->back_arrow)
	    free((char *) saved_back_arrow);
	saved_back_arrow = NULL;
	spline->for_arrow = NULL;
	redisplay_spline(spline);
    } else
	return;
    clean_up();
    set_last_prevpoint(prev_point);
    set_last_selectedpoint(selected_point);
    set_latestspline(spline);
    set_action_object(F_DELETE_ARROW_HEAD, O_SPLINE);
    set_modifiedflag();
}
示例#3
0
void
delete_linearrow(F_line *line, F_point *prev_point, F_point *selected_point)
{
    if (line->points->next == NULL)
	return;			/* A single point line */

    if (prev_point == NULL) {	/* selected_point is the first point */
	if (!line->back_arrow)
	    return;
	draw_line(line, ERASE);
	saved_back_arrow=line->back_arrow;
	if (saved_for_arrow && saved_for_arrow != line->for_arrow)
	    free((char *) saved_for_arrow);
	saved_for_arrow = NULL;
	line->back_arrow = NULL;
	redisplay_line(line);
    } else if (selected_point->next == NULL) {	/* forward arrow */
	if (!line->for_arrow)
	    return;
	draw_line(line, ERASE);
	saved_for_arrow=line->for_arrow;
	if (saved_back_arrow && saved_back_arrow != line->back_arrow)
	    free((char *) saved_back_arrow);
	saved_back_arrow = NULL;
	line->for_arrow = NULL;
	redisplay_line(line);
    } else
	return;
    clean_up();
    set_last_prevpoint(prev_point);
    set_last_selectedpoint(selected_point);
    set_latestline(line);
    set_action_object(F_DELETE_ARROW_HEAD, O_POLYLINE);
    set_modifiedflag();
}
示例#4
0
void
toggle_polyline_polygon(F_line *line, F_point *previous_point, F_point *selected_point)
{
  F_point *point, *last_pt;
  
  last_pt = last_point(line->points);

  if (line->type == T_POLYLINE)
    {

      if (line->points->next == NULL || line->points->next->next == NULL) {
	  put_msg("Not enough points for a polygon");
	  beep();
	  return;  /* less than 3 points - don't close the polyline */
      }
      if ((point = create_point()) == NULL)
	  return;
      
      point->x = last_pt->x;
      point->y = last_pt->y;
      point->next = line->points;
      line->points = point;
      
      line->type = T_POLYGON;
      clean_up();
      set_last_arrows(line->for_arrow, line->back_arrow);
      line->back_arrow = line->for_arrow = NULL;
    }
  else if (line->type == T_POLYGON)
    {
      point = line->points;
      line->points = point->next;           /* unchain the first point */
      free((char *) point);
            
      if ((line->points != selected_point) && (previous_point != NULL))
	{
	  last_pt->next = line->points;     /* let selected point become */
	  previous_point->next = NULL;      /* first point */
	  line->points = selected_point;
	}
      line->type = T_POLYLINE;
      clean_up();
    }
  redisplay_line(line);
  set_action_object(F_OPEN_CLOSE, O_POLYLINE);
  set_last_selectedpoint(line->points);
  set_last_prevpoint(NULL);
  set_latestline(line);
  set_modifiedflag();
}
示例#5
0
void
linepoint_deleting(F_line *line, F_point *prev_point, F_point *selected_point)
{
    F_point	   *p, *next_point;

    next_point = selected_point->next;
    /* delete it and redraw underlying objects */
    list_delete_line(&objects.lines, line);
    redisplay_line(line);
    if (line->type == T_POLYGON) {
	if (prev_point == NULL) {
	    /* The deleted point is the first point */
	    line->points = next_point;
	    for (prev_point = next_point, p = prev_point->next;
		 p->next != NULL;
		 prev_point = p, p = p->next);
	    /*
	     * prev_point now points at next to last point (the last point is
	     * a copy of the first).
	     */
	    p->x = next_point->x;
	    p->y = next_point->y;
	    next_point = p;
	    /*
	     * next_point becomes the last point.  If this operation (point
	     * deletion) is reversed (undo), the selected_point will not be
	     * inserted into it original place, but will be between
	     * prev_point and next_point.
	     */
	} else
	    prev_point->next = next_point;
    } else {			/* polyline */
	if (prev_point == NULL)
	    line->points = next_point;
	else
	    prev_point->next = next_point;
    }
    /* put it back in the list and draw the new line */
    list_add_line(&objects.lines, line);
    /* redraw it and anything on top of it */
    redisplay_line(line);
    clean_up();
    set_modifiedflag();
    set_action_object(F_DELETE_POINT, O_POLYLINE);
    set_latestline(line);
    set_last_prevpoint(prev_point);
    set_last_selectedpoint(selected_point);
    set_last_nextpoint(next_point);
}
示例#6
0
void
splinepoint_deleting(F_spline *spline, F_point *previous_point, F_point *selected_point)
{
    F_point	   *next_point;
    F_sfactor      *s_prev_point, *selected_sfactor;

    next_point = selected_point->next;
    set_temp_cursor(wait_cursor);
    clean_up();
    set_last_prevpoint(previous_point);
    /* delete it and redraw underlying objects */
    list_delete_spline(&objects.splines, spline);
    draw_spline(spline, ERASE);
    redisplay_spline(spline);
    if (previous_point == NULL) {
	    spline->points = next_point;
	if (open_spline(spline)) {
	    selected_sfactor = spline->sfactors->next;
	    spline->sfactors->next = selected_sfactor->next;
	} else {
	    selected_sfactor = spline->sfactors;
	    spline->sfactors = spline->sfactors->next;
	}
    } else {
	previous_point->next = next_point;

	if ((next_point == NULL) && (open_spline(spline)))
	  previous_point = prev_point(spline->points, previous_point);

	s_prev_point = search_sfactor(spline,previous_point);
	selected_sfactor = s_prev_point->next;
	s_prev_point->next = s_prev_point->next->next;
    }

    /* put it back in the list and draw the new spline */
    list_add_spline(&objects.splines, spline);
    /* redraw it and anything on top of it */
    redisplay_spline(spline);
    set_action_object(F_DELETE_POINT, O_SPLINE);
    set_latestspline(spline);
    set_last_selectedpoint(selected_point);
    set_last_selectedsfactor(selected_sfactor);
    set_last_nextpoint(next_point);
    set_modifiedflag();
    reset_cursor();
}
示例#7
0
static void
add_splinearrow(F_spline *spline, F_point *prev_point, F_point *selected_point)
{
    if (prev_point == NULL) {	/* add backward arrow */
	if (spline->back_arrow)
	    return;
	spline->back_arrow = backward_arrow();
	redisplay_spline(spline);
    } else if (selected_point->next == NULL) {	/* add forward arrow */
	if (spline->for_arrow)
	    return;
	spline->for_arrow = forward_arrow();
	redisplay_spline(spline);
    }
    clean_up();
    set_last_prevpoint(prev_point);
    set_last_selectedpoint(selected_point);
    set_latestspline(spline);
    set_action_object(F_ADD_ARROW_HEAD, O_SPLINE);
    set_modifiedflag();
}
示例#8
0
void
toggle_open_closed_spline(F_spline *spline, F_point *previous_point, F_point *selected_point)
{
  F_point *last_pt;
  F_sfactor *last_sfactor, *previous_sfactor, *selected_sfactor;

  if (spline->points->next == NULL || spline->points->next->next == NULL) {
      put_msg("Not enough points for a spline");
      beep();
      return;  /* less than 3 points - don't close the spline */
  }

  last_pt = last_point(spline->points);
  last_sfactor = search_sfactor(spline, last_pt);

  if (previous_point == NULL)
    {
      previous_sfactor = NULL;
      selected_sfactor = spline->sfactors;
    }
  else
    {
      previous_sfactor = search_sfactor(spline, previous_point);
      selected_sfactor = previous_sfactor->next;
      set_last_tension(selected_sfactor->s, previous_sfactor->s);
    }

  draw_spline(spline, ERASE);

  if (closed_spline(spline))
    {      
      if (spline->points != selected_point)
	{
	  last_pt->next = spline->points;
	  last_sfactor->next = spline->sfactors;
	  previous_point->next = NULL;
	  previous_sfactor->next = NULL;
	  previous_sfactor->s = S_SPLINE_ANGULAR;
	  spline->points = selected_point;
	  spline->sfactors = selected_sfactor;
	}
      else
	{
	  last_sfactor->s = S_SPLINE_ANGULAR;
	}
      spline->sfactors->s = S_SPLINE_ANGULAR;
      spline->type = (x_spline(spline)) ? T_OPEN_XSPLINE :
	(int_spline(spline)) ? T_OPEN_INTERP : T_OPEN_APPROX;
      clean_up();
    }
  else
    {
      int type_tmp;
      double s_tmp;

      if(int_spline(spline))
	{
	  s_tmp = S_SPLINE_INTERP;
	  type_tmp = T_CLOSED_INTERP;
	}
      else
	if (x_spline(spline))
	  {
	      s_tmp = S_SPLINE_INTERP;
	      type_tmp = T_CLOSED_XSPLINE;
	    }
	else
	  {
	    s_tmp = S_SPLINE_APPROX;
	    type_tmp = T_CLOSED_APPROX;
	  }
      spline->sfactors->s = last_sfactor->s = s_tmp;
      spline->type = type_tmp;
      clean_up();
      set_last_arrows(spline->for_arrow, spline->back_arrow);
      spline->back_arrow = spline->for_arrow = NULL;
    }
  draw_spline(spline, PAINT);
  set_action_object(F_OPEN_CLOSE, O_SPLINE);
  set_last_selectedpoint(spline->points);
  set_last_prevpoint(NULL);
  set_latestspline(spline);
  set_modifiedflag();
}