Exemplo n.º 1
0
static void
init_splinepointmoving(void)
{
    set_action_on();
    /* turn off all markers */
    update_markers(0);
    from_x = cur_x = moved_point->x;
    from_y = cur_y = moved_point->y;
    set_cursor(crosshair_cursor);
    if (open_spline(cur_s)) {
	if (left_point == NULL || right_point == NULL) {
            if (left_point != NULL) {
                fix_x = left_point->x;
                fix_y = left_point->y;
            } else if (right_point != NULL) {
                fix_x = right_point->x;
                fix_y = right_point->y;
            }
	    if (latexline_mode || latexarrow_mode) {
                canvas_locmove_proc = latex_line;
		canvas_ref_proc = elastic_line;
                cur_latexcursor = crosshair_cursor;
            } else if (mountain_mode || manhattan_mode) {
                canvas_locmove_proc = constrainedangle_line;
		canvas_ref_proc = elastic_line;
            } else {
                /* freehand line */
                canvas_locmove_proc = reshaping_line;
		canvas_ref_proc = elastic_linelink;
            }
	} else {
            /* linelink, always freehand */
	    force_noanglegeom();
	    canvas_locmove_proc = reshaping_line;
	    canvas_ref_proc = elastic_linelink;
	}
    } else {
	/* must be closed spline */
	force_noanglegeom();
	canvas_locmove_proc = reshaping_line;
	canvas_ref_proc = elastic_linelink;
	if (left_point == NULL) {
	    for (left_point = right_point;
		 left_point->next != NULL;
		 left_point = left_point->next);
	}
	if (right_point == NULL) {
	   right_point = cur_s->points;  /* take the first */
    }
    }
    /* show current length(s) */
    (canvas_locmove_proc)(cur_x, cur_y);
    elastic_linelink();
    canvas_leftbut_proc = fix_movedsplinepoint;
    canvas_rightbut_proc = cancel_movedsplinepoint;
}
Exemplo n.º 2
0
void
init_arcdragging(F_arc *a, int x, int y)
{
    new_a = a;
    fix_x = cur_x = x;
    fix_y = cur_y = y;
    canvas_locmove_proc = moving_arc;
    canvas_ref_proc = elastic_movenewarc;
    canvas_leftbut_proc = place_arc;
    canvas_middlebut_proc = array_place_arc;
    canvas_rightbut_proc = cancel_drag_arc;
    set_action_on();
    elastic_movearc(new_a);
}
Exemplo n.º 3
0
void
init_splinedragging(F_spline *s, int x, int y)
{
    new_s = s;
    cur_x = fix_x = x;
    cur_y = fix_y = y;
    canvas_locmove_proc = moving_spline;
    canvas_ref_proc = elastic_movenewspline;
    canvas_leftbut_proc = place_spline;
    canvas_middlebut_proc = array_place_spline;
    canvas_rightbut_proc = cancel_spline;
    set_action_on();
    elastic_moveline(new_s->points);
}
Exemplo n.º 4
0
static void
init_arcpointmoving(void)
{
    set_action_on();
    /* turn off all markers */
    update_markers(0);
    cur_x = cur_a->point[movedpoint_num].x;
    cur_y = cur_a->point[movedpoint_num].y;
    set_cursor(crosshair_cursor);
    canvas_locmove_proc = reshaping_arc;
    canvas_ref_proc = elastic_arclink;
    canvas_leftbut_proc = fix_movedarcpoint;
    canvas_rightbut_proc = cancel_movedarcpoint;
    elastic_arclink();
    /* show current length(s) */
    (canvas_locmove_proc)(cur_x, cur_y);
}
Exemplo n.º 5
0
void
put_selected(void)
{
	int	 i, x,y;
	char	*com;

	set_mousefun("place object","new object","cancel library",
			"place and edit","change draw mode", "place at orig posn");
	set_action_on();
	cur_c = lib_compounds[cur_library_object]->compound;
	new_c = copy_compound(cur_c);
	/* add it to the depths so it is displayed */
	add_compound_depth(new_c);
	/* find lower-right corner for draw_box() */
	off_library_x = new_c->secorner.x;
	off_library_y = new_c->secorner.y;
	/* and upper-left in case the user wants to place it at its original position */
	/* this is saved here because the compound was shifted to 0,0 when reading in */
	orig_put_x = lib_compounds[cur_library_object]->corner.x;
	orig_put_y = lib_compounds[cur_library_object]->corner.y;

	canvas_locmove_proc = init_move_object;
	canvas_ref_proc = null_proc;
	canvas_leftbut_proc = place_lib_object;
	canvas_middlebut_proc = sel_place_lib_obj_proc;
	canvas_rightbut_proc = cancel_place_lib_obj;
	set_cursor(null_cursor);

	/* get the pointer position */
	get_pointer_win_xy(&x, &y);
	/* draw the first image */
	init_move_object(BACKX(x), BACKY(y));

	/* message that we're placing object so and so */
	com = strdup(lib_compounds[cur_library_object]->compound->comments);
	if (strlen(com)) {
	    /* change newlines to blanks */
	    for (i=strlen(com); i>=0; i--)
		if (com[i] == '\n')
		    com[i] = ' ';
	    put_msg("Placing library object \"%s\" (%s.fig)",
		com, library_objects_texts[cur_library_object]);
	} else {
	    put_msg("Placing library object %s.fig", library_objects_texts[cur_library_object]);
	}
}
Exemplo n.º 6
0
static void
init_circlebydiameter_drawing(int x, int y)
{
    cur_mode = F_CIRCLE_BY_DIA;
    cur_x = fix_x = x;
    cur_y = fix_y = y;
    center_marker(fix_x, fix_y);
    set_mousefun("final point", "", "cancel", "", "", "");
    draw_mousefun_canvas();
    canvas_locmove_proc = resizing_cbd;
    canvas_leftbut_proc = create_circlebydia;
    canvas_middlebut_proc = null_proc;
    canvas_rightbut_proc = cancel_circlebydia;
    set_cursor(null_cursor);
    elastic_cbd();
    set_action_on();
}
Exemplo n.º 7
0
static void
init_compoundpointmoving(void)
{
    double	    dx, dy, l;
    F_line	   *line, *dum;

    set_action_on();
    if (cur_x == cur_c->nwcorner.x)
	fix_x = cur_c->secorner.x;
    else
	fix_x = cur_c->nwcorner.x;
    if (cur_y == cur_c->nwcorner.y)
	fix_y = cur_c->secorner.y;
    else
	fix_y = cur_c->nwcorner.y;
    from_x = cur_x;
    from_y = cur_y;
    /* turn off all markers */
    update_markers(0);
    set_cursor(crosshair_cursor);
    elastic_box(fix_x, fix_y, cur_x, cur_y);
    /* is this a dimension line? */
    if (dimline_components(cur_c, &line, &dum, &dum, &dum) && line) {
	/* yes, constrain the resizing in the direction of the line */
	if (line->points->x == line->points->next->x)
	    /* vertical line */
	    constrained = BOX_VSTRETCH;
	else
	    /* horizontal line */
	    constrained = BOX_HSTRETCH;
    }
    if (constrained) {
	dx = cur_x - fix_x;
	dy = cur_y - fix_y;
	l = sqrt(dx * dx + dy * dy);
	cosa = fabs(dx / l);
	sina = fabs(dy / l);
    }
    canvas_locmove_proc = constrained_resizing_scale_box;
    canvas_ref_proc = elastic_fixedbox;
    canvas_leftbut_proc = fix_movedcompoundpoint;
    canvas_rightbut_proc = cancel_compound;
    /* show current length(s) */
    (canvas_locmove_proc)(cur_x, cur_y);
}
Exemplo n.º 8
0
static void
init_ellipsebyradius_drawing(int x, int y)
{
    cur_mode = F_ELLIPSE_BY_RAD;
    cur_x = fix_x = x;
    cur_y = fix_y = y;
    cur_angle = cur_elltextangle/180.0*M_PI;
    center_marker(fix_x, fix_y);
    set_mousefun("Ellipse corner", "Ellipse corner", "cancel", "", "", "");
    draw_mousefun_canvas();
    canvas_locmove_proc = resizing_ebr;
    canvas_leftbut_proc = create_ellipsebyrad;
    canvas_middlebut_proc = create_ellipsebyrad;
    canvas_rightbut_proc = cancel_ellipsebyrad;
    set_cursor(null_cursor);
    elastic_ebr();
    set_action_on();
}
Exemplo n.º 9
0
void
init_compounddragging(F_compound *c, int x, int y)
{
    new_c = c;
    fix_x = cur_x = x;
    fix_y = cur_y = y;
    x1off = c->nwcorner.x - x;
    x2off = c->secorner.x - x;
    y1off = c->nwcorner.y - y;
    y2off = c->secorner.y - y;
    canvas_locmove_proc = moving_box;
    canvas_ref_proc = elastic_movebox;
    canvas_leftbut_proc = place_compound;
    canvas_middlebut_proc = array_place_compound;
    canvas_rightbut_proc = cancel_drag_compound;
    set_action_on();
    get_interior_links(c->nwcorner.x, c->nwcorner.y, c->secorner.x, c->secorner.y);
    elastic_movebox();
}
Exemplo n.º 10
0
void
init_ellipsedragging(F_ellipse *e, int x, int y)
{
    new_e = e;
    fix_x = cur_x = x;
    fix_y = cur_y = y;
    cur_angle = e->angle;
    x1off = (e->center.x - e->radiuses.x) - cur_x;
    x2off = (e->center.x + e->radiuses.x) - cur_x;
    y1off = (e->center.y - e->radiuses.y) - cur_y;
    y2off = (e->center.y + e->radiuses.y) - cur_y;
    canvas_locmove_proc = moving_ellipse;
    canvas_ref_proc = elastic_moveellipse;
    canvas_leftbut_proc = place_ellipse;
    canvas_middlebut_proc = array_place_ellipse;
    canvas_rightbut_proc = cancel_ellipse;
    set_action_on();
    elastic_moveellipse();
}
Exemplo n.º 11
0
void
init_trace_drawing(int x, int y)
{
    if ((first_point = create_point()) == NULL)
	return;

    cur_point = first_point;
    set_action_on();
    cur_point->x = fix_x = cur_x = x;
    cur_point->y = fix_y = cur_y = y;
    cur_point->next = NULL;
    canvas_leftbut_proc = (FCallBack)get_intermediatepoint;
    if (freehand_line) {
	canvas_locmove_proc = freehand_get_intermediatepoint;
    } else {
	/* only two points in a dimension line */
	if (dimension_line)
	    canvas_leftbut_proc = (FCallBack)create_lineobject;
	if (latexline_mode || latexarrow_mode) {
	    canvas_locmove_proc = latex_line;
	} else if (manhattan_mode || mountain_mode) {
	    canvas_locmove_proc = constrainedangle_line;
	} else {
	    canvas_locmove_proc = unconstrained_line;
	}
    }
    canvas_middlebut_save = create_lineobject;
    canvas_rightbut_proc = (FCallBack)cancel_line_drawing;
    return_proc = line_drawing_selected;
    num_point = 1;
    set_mousefun("next point", "", "cancel", "del point", "", "");
    if (dimension_line) {
	set_mousefun("final point", "", "cancel", "del point", "", "");
	canvas_middlebut_proc = (FCallBack)null_proc;
    } else if (num_point >= min_num_points - 1) {
	set_mousefun("next point", "final point", "cancel", "del point", "", "");
	canvas_middlebut_proc = (FCallBack)canvas_middlebut_save;
    }
	
    draw_mousefun_canvas();
    set_cursor(null_cursor);
    elastic_line();
}
Exemplo n.º 12
0
void
init_linedragging(F_line *l, int x, int y)
{
    int		    xmin, ymin, xmax, ymax;

    new_l = l;
    cur_x = fix_x = x;
    cur_y = fix_y = y;
    canvas_locmove_proc = moving_line;
    canvas_ref_proc = elastic_movenewline;
    canvas_leftbut_proc = place_line;
    canvas_middlebut_proc = array_place_line;
    canvas_rightbut_proc = cancel_line;
    set_action_on();
    if (l->type == T_BOX || l->type == T_ARCBOX || l->type == T_PICTURE) {
	line_bound(l, &xmin, &ymin, &xmax, &ymax);
	get_links(xmin, ymin, xmax, ymax);
    }
    elastic_moveline(new_l->points);
}
Exemplo n.º 13
0
void
init_textdragging(F_text *t, int x, int y)
{
    float	   cw,cw2;
    int		   x1, y1;

    new_t = t;
    fix_x = cur_x = x;
    fix_y = cur_y = y;
    x1 = new_t->base_x;
    y1 = new_t->base_y;
    /* adjust fix_x/y so that text will fall on grid if grid is on */		// isometric grid
    round_coords( &x1, &y1 );
    fix_x += new_t->base_x - x1;
    fix_y += new_t->base_y - y1;
    x1off = x1-x; /*new_t->base_x - x;*/
    y1off = y1-y; /*new_t->base_y - y;*/
    if (t->type == T_CENTER_JUSTIFIED || t->type == T_RIGHT_JUSTIFIED) {
	txsize = textsize(t->fontstruct, strlen(t->cstring), t->cstring);
	if (t->type == T_CENTER_JUSTIFIED) {
	    cw2 = txsize.length/2.0/display_zoomscale;
	    x1off = round(x1off - cos((double)t->angle)*cw2);
	    y1off = round(y1off + sin((double)t->angle)*cw2);
	} else { /* T_RIGHT_JUSTIFIED */
	    cw = 1.0*txsize.length/display_zoomscale;
	    x1off = round(x1off - cos((double)t->angle)*cw);
	    y1off = round(y1off + sin((double)t->angle)*cw);
	}
    }
    canvas_locmove_proc = moving_text;
    canvas_ref_proc = elastic_movetext;
    canvas_leftbut_proc = place_text;
    canvas_middlebut_proc = array_place_text;
    canvas_rightbut_proc = cancel_text;
    elastic_movetext();
    set_action_on();
}
Exemplo n.º 14
0
static void
init_linepointmoving(void)
{
    F_point	   *p;

    set_action_on();
    /* turn off all markers */
    update_markers(0);
    from_x = cur_x = moved_point->x;
    from_y = cur_y = moved_point->y;
    set_cursor(crosshair_cursor);
    switch (cur_l->type) {
      case T_POLYGON:
	if (left_point == NULL)
	    for (left_point = right_point, p = left_point->next;
		 p->next != NULL;
		 left_point = p, p = p->next);
        force_noanglegeom();
	canvas_locmove_proc = reshaping_line;
	canvas_ref_proc = elastic_linelink;
	break;

      case T_BOX:
      case T_ARCBOX:
      case T_PICTURE:
	if (right_point->next == NULL) {	/* point 4 */
	    fix_x = cur_l->points->next->x;
	    fix_y = cur_l->points->next->y;
	} else {
	    fix_x = right_point->next->x;
	    fix_y = right_point->next->y;
	}
	if (constrained) {
	    double		dx, dy, l;

	    dx = cur_x - fix_x;
	    dy = cur_y - fix_y;
	    l = sqrt(dx * dx + dy * dy);
	    cosa = fabs(dx / l);
	    sina = fabs(dy / l);
	}

        force_noanglegeom();
	if (cur_l->thickness != 1)
	    elastic_box(fix_x, fix_y, cur_x, cur_y);
	canvas_locmove_proc = constrained_resizing_box;
	canvas_ref_proc = elastic_fixedbox;
	canvas_leftbut_proc = fix_box;
	canvas_rightbut_proc = cancel_movept_box;
	/* show current length(s) */
	(canvas_locmove_proc)(cur_x, cur_y);
	return;

      case T_POLYLINE:
	if (left_point == NULL || right_point == NULL) {
	    if (left_point != NULL) {
		fix_x = left_point->x;
		fix_y = left_point->y;
	    } else if (right_point != NULL) {
		fix_x = right_point->x;
		fix_y = right_point->y;
	    }
            if (latexline_mode || latexarrow_mode) {
                canvas_locmove_proc = latex_line;
		canvas_ref_proc = elastic_line;
		cur_latexcursor = crosshair_cursor;
            } else if (mountain_mode || manhattan_mode) {
                canvas_locmove_proc = constrainedangle_line;
		canvas_ref_proc = elastic_line;
            } else {
		/* unconstrained or freehand line */
		canvas_locmove_proc = reshaping_line;
		canvas_ref_proc = elastic_linelink;
	    }
	} else {
	    /* linelink, always freehand */
            force_noanglegeom();
	    canvas_locmove_proc = reshaping_line;
	    canvas_ref_proc = elastic_linelink;
	}
	break;
    }
    canvas_leftbut_proc = fix_movedlinepoint;
    canvas_rightbut_proc = cancel_movedlinepoint;
    /* show current length(s) */
    (canvas_locmove_proc)(cur_x, cur_y);
}
Exemplo n.º 15
0
static		Boolean
init_ellipsepointmoving(void)
{
    double	    dx, dy, l;

    if (constrained &&
	(cur_e->type == T_CIRCLE_BY_DIA || cur_e->type == T_CIRCLE_BY_RAD)) {
	put_msg("Constrained move not supported for CIRCLES");
	return False;		/* abort - constrained move for circle not allowed */
    }
    if (movedpoint_num == 0) {
	if (cur_e->type == T_ELLIPSE_BY_RAD ||
	    cur_e->type == T_CIRCLE_BY_RAD) {
	    put_msg("Cannot move CENTER point");
	    return False;	/* abort - center point is selected */
	}
	cur_x = cur_e->start.x;
	cur_y = cur_e->start.y;
	fix_x = cur_e->end.x;
	fix_y = cur_e->end.y;
    } else {
	cur_x = cur_e->end.x;
	cur_y = cur_e->end.y;
	fix_x = cur_e->start.x;
	fix_y = cur_e->start.y;
    }
    if (constrained) {
	dx = cur_x - fix_x;
	dy = cur_y - fix_y;
	l = sqrt(dx * dx + dy * dy);
	cosa = fabs(dx / l);
	sina = fabs(dy / l);
    }
    cur_angle = cur_e->angle;
    set_action_on();
    /* turn off all markers */
    update_markers(0);
    switch (cur_e->type) {
      case T_ELLIPSE_BY_RAD:
	canvas_locmove_proc = constrained_resizing_ebr;
	canvas_ref_proc = elastic_ebr;
	break;
      case T_CIRCLE_BY_RAD:
	canvas_locmove_proc = resizing_cbr;
	canvas_ref_proc = elastic_cbr;
	break;
      case T_ELLIPSE_BY_DIA:
	canvas_locmove_proc = constrained_resizing_ebd;
	canvas_ref_proc = elastic_ebd;
	break;
      case T_CIRCLE_BY_DIA:
	canvas_locmove_proc = resizing_cbd;
	canvas_ref_proc = elastic_cbd;
	break;
    }
    /* show current radius(ii) */
    (canvas_locmove_proc)(cur_x, cur_y);
    from_x = cur_x;
    from_y = cur_y;
    set_cursor(crosshair_cursor);
    canvas_leftbut_proc = fix_movedellipsepoint;
    canvas_rightbut_proc = cancel_movedellipsepoint;
    return True;
}