Пример #1
0
static void
fix_movedlinepoint(int x, int y)
{
    (*canvas_locmove_proc) (x, y);
    canvas_ref_proc = canvas_locmove_proc = null_proc;
    elastic_linelink();
    /* erase last lengths if appres.showlengths is true */
    erase_lengths();
    if (cur_latexcursor != crosshair_cursor)
	set_cursor(crosshair_cursor);
    /* make a copy of the original and save as unchanged object */
    old_l = copy_line(cur_l);
    clean_up();
    set_latestline(old_l);
    set_action_object(F_EDIT, O_POLYLINE);
    old_l->next = cur_l;
    /* now change the original to become the new object */
    relocate_linepoint(cur_l, cur_x, cur_y, moved_point, left_point);
    /* redraw anything under the old line */
    redisplay_line(old_l);
    /* and the new line */
    redisplay_line(cur_l);
    /* turn back on all relevant markers */
    update_markers(new_objmask);
    wrapup_movepoint();
}
Пример #2
0
void
box_2_box(F_line *old_l)
{
    F_line	   *new_l;

    new_l = copy_line(old_l);
    switch (old_l->type) {
      case T_BOX:
	new_l->type = T_ARCBOX;
	if (new_l->radius == DEFAULT || new_l->radius == 0)
	    new_l->radius = cur_boxradius;
	break;
      case T_ARCBOX:
	new_l->type = T_BOX;
	break;
    }
    list_delete_line(&objects.lines, old_l);
    list_add_line(&objects.lines, new_l);
    clean_up();
    old_l->next = new_l;
    set_latestline(old_l);
    set_action_object(F_CONVERT, O_POLYLINE);
    set_modifiedflag();
    /* save pointer to this line for undo */
    latest_line = new_l;
    redisplay_line(new_l);
    return;
}
Пример #3
0
static void
place_line_x(int x, int y)
{
    int		    dx, dy;
    canvas_leftbut_proc = null_proc;
    canvas_middlebut_proc = null_proc;
    canvas_rightbut_proc = null_proc;
    canvas_locmove_proc = null_proc;
    canvas_ref_proc = null_proc;
    adjust_pos(x, y, fix_x, fix_y, &x, &y);
    dx = x - fix_x;
    dy = y - fix_y;
    translate_line(new_l, dx, dy);
    clean_up();
    set_latestline(new_l);
    if (return_proc == copy_selected) {
	add_line(new_l);
	adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, True);
	free_linkinfo(&cur_links);
    } else {
	list_add_line(&objects.lines, new_l);
	adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, False);
	set_lastposition(fix_x, fix_y);
	set_newposition(x, y);
	set_lastlinkinfo(cur_linkmode, cur_links);
	cur_links = NULL;
	set_action_object(F_MOVE, O_POLYLINE);
    }
    set_modifiedflag();
    redisplay_line(new_l);
    /* turn back on all relevant markers */
    update_markers(new_objmask);
    (*return_proc) ();
    draw_mousefun_canvas();
}
Пример #4
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();
}
Пример #5
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();
}
Пример #6
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();
}
Пример #7
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);
}
Пример #8
0
void
spline_line(F_spline *s)
{
    F_line	   *l;
    F_point        *tmppoint;

    /* Now we turn s into a line */
    if ((l = create_line()) == NULL)
	return;

    if (open_spline(s)) {
	l->type = T_POLYLINE;
	l->points = s->points;
    } else {
	l->type = T_POLYGON;
	if ((l->points = create_point())==NULL)
	    return;
	tmppoint = last_point(s->points);
	l->points->x = tmppoint->x;
	l->points->y = tmppoint->y;
	l->points->next = copy_points(s->points);
    }
    l->style = s->style;
    l->thickness = s->thickness;
    l->pen_color = s->pen_color;
    l->fill_color = s->fill_color;
    l->depth = s->depth;
    l->style_val = s->style_val;
    l->cap_style = s->cap_style;
    l->join_style = cur_joinstyle;
    l->pen_style = s->pen_style;
    l->radius = DEFAULT;
    l->fill_style = s->fill_style;
    if (s->for_arrow) {
	l->for_arrow = create_arrow();
	l->for_arrow->type = s->for_arrow->type;
	l->for_arrow->style = s->for_arrow->style;
	l->for_arrow->thickness = s->for_arrow->thickness;
	l->for_arrow->wd = s->for_arrow->wd;
	l->for_arrow->ht = s->for_arrow->ht;
    } else {
	l->for_arrow = NULL;
    }
    if (s->back_arrow) {
	l->back_arrow = create_arrow();
	l->back_arrow->type = s->back_arrow->type;
	l->back_arrow->style = s->back_arrow->style;
	l->back_arrow->thickness = s->back_arrow->thickness;
	l->back_arrow->wd = s->back_arrow->wd;
	l->back_arrow->ht = s->back_arrow->ht;
    } else {
	l->back_arrow = NULL;
    }

    /* now we have finished creating the line, we can get rid of the spline */
    delete_spline(s);

    /* and put in the new line */
    mask_toggle_linemarker(l);
    list_add_line(&objects.lines, l);
    redisplay_line(l);
    set_action_object(F_CONVERT, O_SPLINE);
    set_latestline(l);
    set_modifiedflag();
    return;
}