mirror of
git://projects.qi-hardware.com/ben-scans.git
synced 2024-11-25 01:46:16 +02:00
The top face can now be shifted.
- solidify/overlap.c (scroll_event): use center of canvas as center, not center of the top face - solidify/overlap.c (do_shift, shift, scroll_event): added translation (shifting)
This commit is contained in:
parent
525e1557ec
commit
d49f349fa0
@ -180,25 +180,51 @@ static void rotate(struct matrix *m, double r)
|
||||
}
|
||||
|
||||
|
||||
static void do_shift(struct matrix *m, int dx, int dy)
|
||||
{
|
||||
m->b[0] -= dx;
|
||||
m->b[1] += dy;
|
||||
}
|
||||
|
||||
|
||||
static void shift(struct matrix *m, int dx, int dy, int dir)
|
||||
{
|
||||
if (dx > 0 && dy < dx && dy > -dx)
|
||||
do_shift(m, dir, 0);
|
||||
if (dx < 0 && dy < -dx && dy > dx)
|
||||
do_shift(m, -dir, 0);
|
||||
if (dy > 0 && dx < dy && dx > -dy)
|
||||
do_shift(m, 0, dir);
|
||||
if (dy < 0 && dx < -dy && dx > dy)
|
||||
do_shift(m, 0, -dir);
|
||||
}
|
||||
|
||||
|
||||
static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *da = gtk_bin_get_child(GTK_BIN(widget));
|
||||
struct solid *s = data;
|
||||
struct face *f = s->a;
|
||||
int dx = event->x-f->sx/2;
|
||||
int dy = event->y-f->sy/2;
|
||||
int dx = event->x-sx(s)/2;
|
||||
int dy = event->y-sy(s)/2;
|
||||
double r = hypot(dx, dy);
|
||||
int center = r/hypot(sx(s), sy(s)) < 0.25;
|
||||
|
||||
if (r < 1)
|
||||
return TRUE;
|
||||
switch (event->direction) {
|
||||
case GDK_SCROLL_UP:
|
||||
rotate(&f->m, r);
|
||||
if (center)
|
||||
shift(&s->a->m, dx, dy, 1);
|
||||
else
|
||||
rotate(&s->a->m, r);
|
||||
draw_image(da, s);
|
||||
break;
|
||||
case GDK_SCROLL_DOWN:
|
||||
rotate(&f->m, -r);
|
||||
if (center)
|
||||
shift(&s->a->m, dx, dy, -1);
|
||||
else
|
||||
rotate(&s->a->m, -r);
|
||||
draw_image(da, s);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user