From: Jim Evins Date: Sat, 28 Dec 2002 22:59:10 +0000 (+0000) Subject: No longer attempt to rotate/flip around center of object. This was very problematic... X-Git-Tag: glabels-2_3_0~659 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dfdf166ca400fd4028dda0248a0be7f19d7383c4;p=glabels No longer attempt to rotate/flip around center of object. This was very problematic because the object's affine keeps changing under one's nose. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@228 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/label-object.c b/glabels2/src/label-object.c index ebca6552..44920b24 100644 --- a/glabels2/src/label-object.c +++ b/glabels2/src/label-object.c @@ -500,7 +500,7 @@ gl_label_object_get_extent (glLabelObject *object, a4.y = h; /* transform these points */ - gl_label_object_get_applied_affine (object, affine); + gl_label_object_get_affine (object, affine); art_affine_point (&b1, &a1, affine); art_affine_point (&b2, &a2, affine); art_affine_point (&b3, &a3, affine); @@ -609,26 +609,40 @@ gl_label_object_get_affine (glLabelObject *object, } /****************************************************************************/ -/* Get applied affine, i.e. translated to center of object and back */ +/* Get i2w affine, i.e. applied affine + translation. */ /****************************************************************************/ void -gl_label_object_get_applied_affine (glLabelObject *object, - gdouble affine[6]) +gl_label_object_get_i2w_affine (glLabelObject *object, + gdouble affine[6]) { - gdouble w, h; - gdouble to_center[6], to_origin[6]; + gdouble x, y; + gdouble translation[6]; gl_debug (DEBUG_LABEL, ""); g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); - gl_label_object_get_size (object, &w, &h); + gl_label_object_get_affine (object, affine); + gl_label_object_get_position (object, &x, &y); + + art_affine_translate (translation, x, y); + art_affine_multiply (affine, affine, translation); +} + +/****************************************************************************/ +/* Get w2i affine, i.e. inverse of applied affine + translation. */ +/****************************************************************************/ +void +gl_label_object_get_w2i_affine (glLabelObject *object, + gdouble affine[6]) +{ + gdouble i2w[6]; + gl_debug (DEBUG_LABEL, ""); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); - /* setup transformation affine */ - art_affine_translate (to_center, -w/2.0, -h/2.0); - art_affine_multiply (affine, to_center, object->private->affine); - art_affine_translate (to_origin, w/2.0, h/2.0); - art_affine_multiply (affine, affine, to_origin); + gl_label_object_get_i2w_affine (object, i2w); + art_affine_invert (affine, i2w); } /****************************************************************************/ diff --git a/glabels2/src/label-object.h b/glabels2/src/label-object.h index a7703b94..b81f8f45 100644 --- a/glabels2/src/label-object.h +++ b/glabels2/src/label-object.h @@ -169,7 +169,10 @@ void gl_label_object_set_affine (glLabelObject *object, void gl_label_object_get_affine (glLabelObject *object, gdouble affine[6]); -void gl_label_object_get_applied_affine (glLabelObject *object, +void gl_label_object_get_i2w_affine (glLabelObject *object, + gdouble affine[6]); + +void gl_label_object_get_w2i_affine (glLabelObject *object, gdouble affine[6]); G_END_DECLS diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 618782e5..893ab3bc 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -570,7 +570,7 @@ draw_object (PrintInfo *pi, gl_debug (DEBUG_PRINT, "START"); gl_label_object_get_position (object, &x0, &y0); - gl_label_object_get_applied_affine (object, affine); + gl_label_object_get_affine (object, affine); gnome_print_gsave (pi->pc); diff --git a/glabels2/src/view-highlight.c b/glabels2/src/view-highlight.c index 8417a88e..d25b10f8 100644 --- a/glabels2/src/view-highlight.c +++ b/glabels2/src/view-highlight.c @@ -262,7 +262,7 @@ gl_view_highlight_new (glViewObject *view_object, } - gl_label_object_get_applied_affine (view_highlight->private->object, affine); + gl_label_object_get_affine (view_highlight->private->object, affine); gnome_canvas_item_affine_absolute (view_highlight->private->group, affine); g_signal_connect (G_OBJECT (view_highlight->private->object), "moved", @@ -684,7 +684,7 @@ flip_rotate_object_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "START"); /* Adjust affine of inner canvas group. */ - gl_label_object_get_applied_affine (object, affine); + gl_label_object_get_affine (object, affine); gnome_canvas_item_affine_absolute (view_highlight->private->group, affine); gl_debug (DEBUG_VIEW, "END"); diff --git a/glabels2/src/view-object.c b/glabels2/src/view-object.c index 540fbfa1..2e9eb073 100644 --- a/glabels2/src/view-object.c +++ b/glabels2/src/view-object.c @@ -327,7 +327,7 @@ gl_view_object_item_new (glViewObject *view_object, gnome_canvas_item_set_valist (item, first_arg_name, args); va_end (args); - gl_label_object_get_applied_affine (view_object->private->object, affine); + gl_label_object_get_affine (view_object->private->object, affine); /* Apply a very small rotation, fixes problems with flipped or rotated images */ art_affine_rotate (delta_affine, DELTA_DEG); @@ -467,7 +467,7 @@ flip_rotate_object_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "START"); - gl_label_object_get_applied_affine (object, affine); + gl_label_object_get_affine (object, affine); /* Apply a very small rotation, fixes problems with flipped or rotated images */ art_affine_rotate (delta_affine, DELTA_DEG);