Beispiel #1
0
void
sp_sel_trans_transform (SPSelTrans * seltrans, NRMatrixD *affine, NRPointF *norm)
{
	NRMatrixD n2p, p2n;

	g_return_if_fail (seltrans->grabbed);
	g_return_if_fail (!seltrans->empty);

	nr_matrix_d_set_translate (&n2p, norm->x, norm->y);
	nr_matrix_d_set_translate (&p2n, -norm->x, -norm->y);
	nr_matrix_multiply_ddd (affine, &p2n, affine);
	nr_matrix_multiply_ddd (affine, affine, &n2p);

	if (seltrans->show == SP_SELTRANS_SHOW_CONTENT) {
	        // update the content
		int i;
		for (i = 0; i < seltrans->nitems; i++) {
			NRMatrixF i2dnew;
			nr_matrix_multiply_ffd (&i2dnew, &seltrans->transforms[i], affine);
			sp_item_set_i2d_affine (seltrans->items[i], &i2dnew);
		}
	} else {
		NRPointF p[4];
        	/* update the outline */
		p[0].x = NR_MATRIX_DF_TRANSFORM_X (affine, seltrans->box.x0, seltrans->box.y0);
		p[0].y = NR_MATRIX_DF_TRANSFORM_Y (affine, seltrans->box.x0, seltrans->box.y0);
		p[1].x = NR_MATRIX_DF_TRANSFORM_X (affine, seltrans->box.x1, seltrans->box.y0);
		p[1].y = NR_MATRIX_DF_TRANSFORM_Y (affine, seltrans->box.x1, seltrans->box.y0);
		p[2].x = NR_MATRIX_DF_TRANSFORM_X (affine, seltrans->box.x1, seltrans->box.y1);
		p[2].y = NR_MATRIX_DF_TRANSFORM_Y (affine, seltrans->box.x1, seltrans->box.y1);
		p[3].x = NR_MATRIX_DF_TRANSFORM_X (affine, seltrans->box.x0, seltrans->box.y1);
		p[3].y = NR_MATRIX_DF_TRANSFORM_Y (affine, seltrans->box.x0, seltrans->box.y1);
		sp_ctrlline_set_coords (SP_CTRLLINE (seltrans->l1), p[0].x, p[0].y, p[1].x, p[1].y);
		sp_ctrlline_set_coords (SP_CTRLLINE (seltrans->l2), p[1].x, p[1].y, p[2].x, p[2].y);
		sp_ctrlline_set_coords (SP_CTRLLINE (seltrans->l3), p[2].x, p[2].y, p[3].x, p[3].y);
		sp_ctrlline_set_coords (SP_CTRLLINE (seltrans->l4), p[3].x, p[3].y, p[0].x, p[0].y);
	}

	
	seltrans->current = *affine;

	seltrans->changed = TRUE;

	sp_sel_trans_update_handles (seltrans);
}
Beispiel #2
0
/**
Create a line from p1 to p2 and add it to the lines list
 */
void
VPDrag::addLine (Geom::Point p1, Geom::Point p2, guint32 rgba)
{
    SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(inkscape_active_desktop()), SP_TYPE_CTRLLINE, NULL);
    sp_ctrlline_set_coords(SP_CTRLLINE(line), p1, p2);
    if (rgba != VP_LINE_COLOR_FILL) // fill is the default, so don't set color for it to speed up redraw
        sp_ctrlline_set_rgba32 (SP_CTRLLINE(line), rgba);
    sp_canvas_item_show (line);
    this->lines = g_slist_append (this->lines, line);
}
Beispiel #3
0
static void
spdc_pen_set_ctrl (SPPenContext *pc, NRPointF *p, guint state)
{
	SPDrawContext *dc;

	dc = SP_DRAW_CONTEXT (pc);

	sp_canvas_item_show (pc->c1);
	sp_canvas_item_show (pc->cl1);

	if (dc->npoints == 2) {
		dc->p[1] = *p;
		sp_canvas_item_hide (pc->c0);
		sp_canvas_item_hide (pc->cl0);
		sp_ctrl_moveto (SP_CTRL (pc->c1), dc->p[1].x, dc->p[1].y);
		sp_ctrlline_set_coords (SP_CTRLLINE (pc->cl1), dc->p[0].x, dc->p[0].y, dc->p[1].x, dc->p[1].y);
	} else if (dc->npoints == 5) {
		dc->p[4] = *p;
		sp_canvas_item_show (pc->c0);
		sp_canvas_item_show (pc->cl0);
		if (((pc->mode == SP_PEN_CONTEXT_MODE_CLICK) && (state & GDK_CONTROL_MASK)) ||
		    ((pc->mode == SP_PEN_CONTEXT_MODE_DRAG) && !(state & GDK_MOD1_MASK))) {
			gdouble dx, dy;
			dx = p->x - dc->p[3].x;
			dy = p->y - dc->p[3].y;
			dc->p[2].x = dc->p[3].x - dx;
			dc->p[2].y = dc->p[3].y - dy;
			sp_curve_reset (dc->red_curve);
			sp_curve_moveto (dc->red_curve, dc->p[0].x, dc->p[0].y);
			sp_curve_curveto (dc->red_curve, dc->p[1].x, dc->p[1].y, dc->p[2].x, dc->p[2].y, dc->p[3].x, dc->p[3].y);
			sp_canvas_bpath_set_bpath (SP_CANVAS_BPATH (dc->red_bpath), dc->red_curve);
		}
		sp_ctrl_moveto (SP_CTRL (pc->c0), dc->p[2].x, dc->p[2].y);
		sp_ctrlline_set_coords (SP_CTRLLINE (pc->cl0), dc->p[3].x, dc->p[3].y, dc->p[2].x, dc->p[2].y);
		sp_ctrl_moveto (SP_CTRL (pc->c1), dc->p[4].x, dc->p[4].y);
		sp_ctrlline_set_coords (SP_CTRLLINE (pc->cl1), dc->p[3].x, dc->p[3].y, dc->p[4].x, dc->p[4].y);
	} else {
		g_warning ("Something bad happened - npoints is %d", dc->npoints);
	}
}
Beispiel #4
0
void
sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end)
{
    sp_ctrlline_set_coords(cl, start[0], start[1], end[0], end[1]);
}