- gnome_canvas_item_i2w (item, &x, &y);
- gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x, y, &simpleline->bbox_lrx, &simpleline->bbox_lry);
+ /* force non-zero dimensionality for both axes */
+
+ if (x1 == x2) {
+ x2 += 1.0;
+ }
+
+ if (y1 == y2) {
+ y2 += 1.0;
+ }
+
+ /* reset item bounding box (canvas coordinates, so integral. but stored in doubles) */
+
+ gnome_canvas_w2c_d (GNOME_CANVAS(item->canvas), x1, y1, &item->x1, &item->y1);
+ gnome_canvas_w2c_d (GNOME_CANVAS(item->canvas), x2, y2, &item->x2, &item->y2);
+
+ /* redraw new location */
+
+ gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
+
+ /* store actual line coords as canvas coordinates for use in render() */
+
+ x1 = simpleline->x1;
+ y1 = simpleline->y1;
+ x2 = simpleline->x2;
+ y2 = simpleline->y2;
+ /* convert to world */
+ gnome_canvas_item_i2w (item, &x1, &y1);
+ gnome_canvas_item_i2w (item, &x2, &y2);
+ /* avoid rounding errors */
+ x1 = (int) floor (item->x1);
+ y1 = (int) floor (item->y1);
+ x2 = (int) ceil (item->x2);
+ y2 = (int) ceil (item->y2);
+ /* convert to canvas coordinates, integral, stored in integers */
+ gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x1, y1, &simpleline->cx1, &simpleline->cy1);
+ gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x2, y2, &simpleline->cx2, &simpleline->cy2);