Beispiel #1
0
static void
place_spline_x(int x, int y)
{
    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);
    translate_spline(new_s, x - fix_x, y - fix_y);
    if (return_proc == copy_selected) {
	add_spline(new_s);
    } else {
	list_add_spline(&objects.splines, new_s);
	clean_up();
	set_lastposition(fix_x, fix_y);
	set_newposition(x, y);
	set_action_object(F_MOVE, O_SPLINE);
	set_latestspline(new_s);
	set_modifiedflag();
    }
    redisplay_spline(new_s);
    /* turn back on all relevant markers */
    update_markers(new_objmask);
    (*return_proc) ();
    draw_mousefun_canvas();
}
Beispiel #2
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();
}
Beispiel #3
0
static void
place_lib_object(int x, int y, unsigned int shift)
{
    F_compound *this_c;

    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;
    put_draw(ERASE);
    clean_up();
    if (draw_box) 
    	translate_compound(new_c,cur_x,cur_y);
    /* remove it from the depths because it will be added when it is put in the main list */
    remove_compound_depth(new_c);
    add_compound(new_c);
    set_modifiedflag();
    redisplay_compound(new_c);
    if (shift) {
	/* temporarily turn off library place mode so we can edit the object just placed */
	canvas_kbd_proc = null_proc;
	clear_mousefun();
	set_mousefun("","","", "", "", "");
	turn_off_current();
	set_cursor(arrow_cursor);
	edit_remember_lib_mode = True;
	this_c = new_c;
	edit_item(this_c, O_COMPOUND, 0, 0);
    } else {
	put_selected();
    }
}
Beispiel #4
0
static void
relocate_splinepoint(F_spline *s, int x, int y, F_point *moved_point)
{
    moved_point->x = x;
    moved_point->y = y;
    set_modifiedflag();
}
Beispiel #5
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();
}
Beispiel #6
0
static void
fix_movedcompoundpoint(int x, int y)
{
    float	    scalex, scaley;

    canvas_ref_proc = canvas_locmove_proc = null_proc;
    elastic_box(fix_x, fix_y, cur_x, cur_y);
    /* erase last lengths if appres.showlengths is true */
    erase_lengths();
    adjust_box_pos(x, y, from_x, from_y, &cur_x, &cur_y);

    /* make a copy of the original and save as unchanged object */
    old_c = copy_compound(cur_c);
    clean_up();
    old_c->next = cur_c;
    set_latestcompound(old_c);
    set_action_object(F_EDIT, O_COMPOUND);

    scalex = ((float) (cur_x - fix_x)) / (from_x - fix_x);
    scaley = ((float) (cur_y - fix_y)) / (from_y - fix_y);
    /* scale the compound */
    scale_compound(cur_c, scalex, scaley, fix_x, fix_y);

    /* redraw anything under the old compound */
    redisplay_compound(old_c);
    /* and the new compound */
    redisplay_compound(cur_c);
    /* turn back on all relevant markers */
    update_markers(new_objmask);

    set_lastposition(from_x, from_y);
    set_newposition(cur_x, cur_y);
    set_modifiedflag();
    wrapup_movepoint();
}
Beispiel #7
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();
}
Beispiel #8
0
void
delete_arcarrow(F_arc *arc, int point_num)
{
    if (arc->type == T_PIE_WEDGE_ARC)
	return;;
    if (point_num == 0) {	/* backward arrow  */
	if (!arc->back_arrow)
	    return;
	draw_arc(arc, ERASE);
	saved_back_arrow=arc->back_arrow;
	if (saved_for_arrow && saved_for_arrow != arc->for_arrow)
	    free((char *) saved_for_arrow);
	saved_for_arrow = NULL;
	arc->back_arrow = NULL;
	redisplay_arc(arc);
    } else if (point_num == 2) {/* for_arrow  */
	if (!arc->for_arrow)
	    return;
	draw_arc(arc, ERASE);
	saved_for_arrow=arc->for_arrow;
	if (saved_back_arrow && saved_back_arrow != arc->back_arrow)
	    free((char *) saved_back_arrow);
	saved_back_arrow = NULL;
	arc->for_arrow = NULL;
	redisplay_arc(arc);
    } else
	return;
    clean_up();
    set_last_arcpointnum(point_num);
    set_latestarc(arc);
    set_action_object(F_DELETE_ARROW_HEAD, O_ARC);
    set_modifiedflag();
}
Beispiel #9
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();
}
Beispiel #10
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;
}
Beispiel #11
0
static void
add_arcarrow(F_arc *arc, int point_num)
{

    /* only allow arrowheads on open arc */
    if (arc->type == T_PIE_WEDGE_ARC)
	return;
    if (point_num == 0) {	/* backward arrow  */
	if (arc->back_arrow)
	    return;
	arc->back_arrow = backward_arrow();
	redisplay_arc(arc);
    } else if (point_num == 2) {/* for_arrow  */
	if (arc->for_arrow)
	    return;
	arc->for_arrow = forward_arrow();
	redisplay_arc(arc);
    } else
	return;
    clean_up();
    set_last_arcpointnum(point_num);
    set_latestarc(arc);
    set_action_object(F_ADD_ARROW_HEAD, O_ARC);
    set_modifiedflag();
}
Beispiel #12
0
static void
init_align_canvas(int x, int y, unsigned int shift)
       		         
                          	/* Shift Key Status from XEvent */
{
    int		    ux;

    cur_c = &objects;
    toggle_all_compoundmarkers();
    draw_compoundelements(cur_c, ERASE);
    old_c = copy_compound(&objects);
    xcmin=ycmin=0;

    /* get the current page size */
    xcmax = paper_sizes[appres.papersize].width;
    ycmax = paper_sizes[appres.papersize].height;
    if (!appres.INCHES) {
	xcmax = (int)(xcmax*2.54*PIX_PER_CM/PIX_PER_INCH);
	ycmax = (int)(ycmax*2.54*PIX_PER_CM/PIX_PER_INCH);
    }
    /* swap height and width if landscape */
    if (appres.landscape) {
	ux = xcmax;
	xcmax = ycmax;
	ycmax = ux;
    }
    align_ellipse();
    align_arc();
    align_line();
    align_spline();
    align_compound();
    align_text();

    /*
     * Display messages indicating that distribution or alignment can't be
     * performed with respect to the canvas.
     */
    if ((cur_halign == ALIGN_DISTRIB_C) || (cur_halign == ALIGN_DISTRIB_E))
      put_msg("Can't DISTRIBUTE horizontally with respect to the canvas");
    else if (cur_halign == ALIGN_ABUT)
      put_msg("Can't ABUT horizontally with respect to the canvas");
    if ((cur_valign == ALIGN_DISTRIB_C) || (cur_valign == ALIGN_DISTRIB_E))
      put_msg("Can't DISTRIBUTE vertically with respect to the canvas");
    else if (cur_valign == ALIGN_ABUT)
      put_msg("Can't ABUT vertically with respect to the canvas");

    draw_compoundelements(cur_c, PAINT);
    toggle_all_compoundmarkers();
    clean_up();
    set_latestobjects(old_c);
    set_action_object(F_EDIT, O_ALL_OBJECT);
    set_modifiedflag();
}
Beispiel #13
0
static void
relocate_linepoint(F_line *line, int x, int y, F_point *moved_point, F_point *left_point)
{
    if (line->type == T_POLYGON)
	if (line->points == moved_point) {
	    left_point->next->x = x;
	    left_point->next->y = y;
	}
    moved_point->x = x;
    moved_point->y = y;
    set_modifiedflag();
}
Beispiel #14
0
static void 
do_update(Widget widget, XtPointer closure, XtPointer call_data)
{
  if (found_text_cnt > 0) {
    search_text_in_compound(&objects,
            panel_get_value(search_text_widget), update_text);
    found_text_panel_dismiss();
    redisplay_canvas();
    set_modifiedflag();
    show_search_msg("%d object%s updated", 
	found_text_cnt, (found_text_cnt != 1)? "s":"");
  }
}
Beispiel #15
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();
}
Beispiel #16
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);
}
Beispiel #17
0
static void
create_compoundobject(int x, int y)
{
    F_compound	   *c;

    if ((c = create_compound()) == NULL)
	return;

    if (compose_compound(c) == 0) {
	free((char *) c);
	compound_selected();
	draw_mousefun_canvas();
	put_msg("Empty compound, ignored");
	return;
    }
    /*
     * Make the bounding box exactly match the dimensions of the compound.
     */
    compound_bound(c, &c->nwcorner.x, &c->nwcorner.y,
		   &c->secorner.x, &c->secorner.y);

    /* if zero width or height in the compound, adjust to next positioning 
       grid point or a few pixels if positioning grid is "ANY" */
    if (c->nwcorner.x == c->secorner.x) {
	if (cur_pointposn != P_ANY) {
	    c->secorner.x += posn_rnd[cur_gridunit][cur_pointposn];
	    c->secorner.x = ceil_coords_x(c->secorner.x,c->secorner.y);
	}
    }
    if (c->nwcorner.y == c->secorner.y) {
	if (cur_pointposn != P_ANY) {
	    c->secorner.y += posn_rnd[cur_gridunit][cur_pointposn];
	    c->secorner.y = ceil_coords_y(c->secorner.x,c->secorner.y);
	}
    }
    c->next = NULL;
    clean_up();
    set_action(F_GLUE);
    toggle_markers_in_compound(c);
    list_add_compound(&objects.compounds, c);
    mask_toggle_compoundmarker(c);
    set_latestcompound(c);
    set_modifiedflag();
    compound_selected();
    draw_mousefun_canvas();
}
Beispiel #18
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();
}
Beispiel #19
0
static void
place_lib_object_orig(int x, int y, unsigned int shift)
{
    int dx,dy;

    canvas_ref_proc = null_proc;
    put_draw(ERASE);
    clean_up();
    /* move back to original position */
    dx = orig_put_x-x;
    dy = orig_put_y-y;
    translate_compound(new_c,dx,dy);
    /* remove it from the depths because it will be added when it is put in the main list */
    remove_compound_depth(new_c);
    add_compound(new_c);
    set_modifiedflag();
    redisplay_compound(new_c);
    put_selected();
}
Beispiel #20
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();
}
Beispiel #21
0
static void
init_align(F_line *p, int type, int x, int y, int px, int py)
{
    if (type != O_COMPOUND)
	return;
    cur_c = (F_compound *) p;
    toggle_compoundmarker(cur_c);
    draw_compoundelements(cur_c, ERASE);
    old_c = copy_compound(cur_c);
    compound_bound(cur_c, &xcmin, &ycmin, &xcmax, &ycmax);
    align_ellipse();
    align_arc();
    align_line();
    align_spline();
    align_compound();
    align_text();

    /*
     * Perform the distribution of the objects in the compound
     */
    if ( (cur_halign == ALIGN_DISTRIB_C) || (cur_halign == ALIGN_DISTRIB_E)
	|| (cur_halign == ALIGN_ABUT) )
      distribute_horizontally();
    if ( (cur_valign == ALIGN_DISTRIB_C) || (cur_valign == ALIGN_DISTRIB_E)
	|| (cur_valign == ALIGN_ABUT) )
      distribute_vertically();

    /*
     * recompute the compound's bounding box
     */
    compound_bound(cur_c, &cur_c->nwcorner.x, &cur_c->nwcorner.y,
		   &cur_c->secorner.x, &cur_c->secorner.y);
    draw_compoundelements(cur_c, PAINT);
    toggle_compoundmarker(cur_c);
    clean_up();
    old_c->next = cur_c;
    set_latestcompound(old_c);
    set_action_object(F_EDIT, O_COMPOUND);
    set_modifiedflag();
}
Beispiel #22
0
void undo_change(void)
{
    char	   *swp_comm;
    F_compound	    swp_c;
    F_line	    swp_l;
    F_spline	    swp_s;
    F_ellipse	    swp_e;
    F_arc	    swp_a;
    F_text	    swp_t;

    last_action = F_NULL;	/* to avoid a clean-up during "unchange" */
    switch (last_object) {
      case O_POLYLINE:
	new_l = saved_objects.lines;		/* the original */
	old_l = saved_objects.lines->next;	/* the changed object */
	/* account for depths */
	remove_depth(O_POLYLINE, old_l->depth);
	add_depth(O_POLYLINE, new_l->depth);
	/* swap old with new */
	bcopy((char*)old_l, (char*)&swp_l, sizeof(F_line));
	bcopy((char*)new_l, (char*)old_l, sizeof(F_line));
	bcopy((char*)&swp_l, (char*)new_l, sizeof(F_line));
	/* but keep the next pointers unchanged */
	swp_l.next = old_l->next;
	old_l->next = new_l->next;
	new_l->next = swp_l.next;
	set_action_object(F_EDIT, O_POLYLINE);
	redisplay_lines(new_l, old_l);
	break;
      case O_ELLIPSE:
	new_e = saved_objects.ellipses;
	old_e = saved_objects.ellipses->next;
	/* account for depths */
	remove_depth(O_ELLIPSE, old_e->depth);
	add_depth(O_ELLIPSE, new_e->depth);
	/* swap old with new */
	bcopy((char*)old_e, (char*)&swp_e, sizeof(F_ellipse));
	bcopy((char*)new_e, (char*)old_e, sizeof(F_ellipse));
	bcopy((char*)&swp_e, (char*)new_e, sizeof(F_ellipse));
	/* but keep the next pointers unchanged */
	swp_e.next = old_e->next;
	old_e->next = new_e->next;
	new_e->next = swp_e.next;
	set_action_object(F_EDIT, O_ELLIPSE);
	redisplay_ellipses(new_e, old_e);
	break;
      case O_TXT:
	new_t = saved_objects.texts;
	old_t = saved_objects.texts->next;
	/* account for depths */
	remove_depth(O_TXT, old_t->depth);
	add_depth(O_TXT, new_t->depth);
	/* swap old with new */
	bcopy((char*)old_t, (char*)&swp_t, sizeof(F_text));
	bcopy((char*)new_t, (char*)old_t, sizeof(F_text));
	bcopy((char*)&swp_t, (char*)new_t, sizeof(F_text));
	/* but keep the next pointers unchanged */
	swp_t.next = old_t->next;
	old_t->next = new_t->next;
	new_t->next = swp_t.next;
	set_action_object(F_EDIT, O_TXT);
	redisplay_texts(new_t, old_t);
	break;
      case O_SPLINE:
	new_s = saved_objects.splines;
	old_s = saved_objects.splines->next;
	/* account for depths */
	remove_depth(O_SPLINE, old_s->depth);
	add_depth(O_SPLINE, new_s->depth);
	/* swap old with new */
	bcopy((char*)old_s, (char*)&swp_s, sizeof(F_spline));
	bcopy((char*)new_s, (char*)old_s, sizeof(F_spline));
	bcopy((char*)&swp_s, (char*)new_s, sizeof(F_spline));
	/* but keep the next pointers unchanged */
	swp_s.next = old_s->next;
	old_s->next = new_s->next;
	new_s->next = swp_s.next;
	set_action_object(F_EDIT, O_SPLINE);
	redisplay_splines(new_s, old_s);
	break;
      case O_ARC:
	new_a = saved_objects.arcs;
	old_a = saved_objects.arcs->next;
	/* account for depths */
	remove_depth(O_ARC, old_a->depth);
	add_depth(O_ARC, new_a->depth);
	/* swap old with new */
	bcopy((char*)old_a, (char*)&swp_a, sizeof(F_arc));
	bcopy((char*)new_a, (char*)old_a, sizeof(F_arc));
	bcopy((char*)&swp_a, (char*)new_a, sizeof(F_arc));
	/* but keep the next pointers unchanged */
	swp_a.next = old_a->next;
	old_a->next = new_a->next;
	new_a->next = swp_a.next;
	set_action_object(F_EDIT, O_ARC);
	redisplay_arcs(new_a, old_a);
	break;
      case O_COMPOUND:
	new_c = saved_objects.compounds;
	old_c = saved_objects.compounds->next;
	/* account for depths */
	remove_compound_depth(old_c);
	add_compound_depth(new_c);
	/* swap old with new */
	bcopy((char*)old_c, (char*)&swp_c, sizeof(F_compound));
	bcopy((char*)new_c, (char*)old_c, sizeof(F_compound));
	bcopy((char*)&swp_c, (char*)new_c, sizeof(F_compound));
	/* but keep the next pointers unchanged */
	swp_c.next = old_c->next;
	old_c->next = new_c->next;
	new_c->next = swp_c.next;
	set_action_object(F_EDIT, O_COMPOUND);
	redisplay_compounds(new_c, old_c);
	break;
      case O_FIGURE:
	/* swap saved figure comments with current */
	swp_comm = objects.comments;
	objects.comments = saved_objects.comments;
	saved_objects.comments = swp_comm;
	set_action_object(F_EDIT, O_FIGURE);
	break;
      case O_ALL_OBJECT:
	swp_c = objects;
	objects = saved_objects;
	saved_objects = swp_c;
	new_c = &objects;
	old_c = &saved_objects;
	/* account for depths */
	remove_compound_depth(old_c);
	add_compound_depth(new_c);
	set_action_object(F_EDIT, O_ALL_OBJECT);
	set_modifiedflag();
	redisplay_zoomed_region(0, 0, BACKX(CANVAS_WD), BACKY(CANVAS_HT));
	break;
    }
}
Beispiel #23
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();
}
Beispiel #24
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;
}
Beispiel #25
0
void
line_spline(F_line *l, int type_value)
{
    F_spline	   *s;

    if (num_points(l->points) < CLOSED_SPLINE_MIN_NUM_POINTS) {
	put_msg("Not enough points for a spline");
	beep();
	return;
    }

    if ((s = create_spline()) == NULL)
        return;
    s->type = type_value;

    if (l->type == T_POLYGON)
	s->points = copy_points(l->points->next);
    else
	s->points = copy_points(l->points);

    s->style = l->style;
    s->thickness = l->thickness;
    s->pen_color = l->pen_color;
    s->fill_color = l->fill_color;
    s->depth = l->depth;
    s->style_val = l->style_val;
    s->cap_style = l->cap_style;
    s->pen_style = l->pen_style;
    s->fill_style = l->fill_style;
    s->sfactors = NULL;
    s->next = NULL;

    if (l->for_arrow) {
	s->for_arrow = create_arrow();
	s->for_arrow->type = l->for_arrow->type;
	s->for_arrow->style = l->for_arrow->style;
	s->for_arrow->thickness = l->for_arrow->thickness;
	s->for_arrow->wd = l->for_arrow->wd;
	s->for_arrow->ht = l->for_arrow->ht;
    } else {
	s->for_arrow = NULL;
    }
    if (l->back_arrow) {
	s->back_arrow = create_arrow();
	s->back_arrow->type = l->back_arrow->type;
	s->back_arrow->style = l->back_arrow->style;
	s->back_arrow->thickness = l->back_arrow->thickness;
	s->back_arrow->wd = l->back_arrow->wd;
	s->back_arrow->ht = l->back_arrow->ht;
    } else {
	s->back_arrow = NULL;
    }
    /* A spline must have an s parameter for each point */
    if (!make_sfactors(s)) {
	free_spline(&s);
	return;
    }

    /* Get rid of the line and draw the new spline */
    delete_line(l);
    /* now put back the new spline */
    mask_toggle_splinemarker(s);
    list_add_spline(&objects.splines, s);
    redisplay_spline(s);
    set_action_object(F_CONVERT, O_POLYLINE);
    set_latestspline(s);
    set_modifiedflag();
}