From 0738347091099d6871fc5a8d6adfe031db99148c Mon Sep 17 00:00:00 2001 From: mh17 <mh17> Date: Fri, 26 Feb 2010 13:34:51 +0000 Subject: [PATCH] RT 159350: bump col lines and glyphs restored. Seems to work but I have reservations re the fix --- src/zmapWindow/items/zmapWindowCanvasItem.c | 435 ++++++++++-------- .../items/zmapWindowCollectionFeature.c | 42 +- src/zmapWindow/zmapWindowColBump.c | 174 +++---- 3 files changed, 359 insertions(+), 292 deletions(-) diff --git a/src/zmapWindow/items/zmapWindowCanvasItem.c b/src/zmapWindow/items/zmapWindowCanvasItem.c index 8ebd151e1..f7b2a9495 100755 --- a/src/zmapWindow/items/zmapWindowCanvasItem.c +++ b/src/zmapWindow/items/zmapWindowCanvasItem.c @@ -6,12 +6,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -23,13 +23,13 @@ * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk * - * Description: + * Description: * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: * Last edited: Feb 16 10:20 2010 (edgrif) * Created: Wed Dec 3 09:00:20 2008 (rds) - * CVS info: $Id: zmapWindowCanvasItem.c,v 1.18 2010-02-17 16:00:33 mh17 Exp $ + * CVS info: $Id: zmapWindowCanvasItem.c,v 1.19 2010-02-26 13:34:51 mh17 Exp $ *------------------------------------------------------------------- */ @@ -60,7 +60,7 @@ typedef enum #define DEBUG_ITEM_MARK #endif -typedef struct +typedef struct { ZMapWindowCanvasItem parent; ZMapFeature feature; @@ -72,7 +72,7 @@ typedef struct static void zmap_window_canvas_item_class_init (ZMapWindowCanvasItemClass class); static void zmap_window_canvas_item_init (ZMapWindowCanvasItem group); -static void zmap_window_canvas_item_set_property(GObject *object, +static void zmap_window_canvas_item_set_property(GObject *object, guint param_id, const GValue *value, GParamSpec *pspec); @@ -109,8 +109,8 @@ static void zmap_window_canvas_item_translate (FooCanvasItem *item, double d static void zmap_window_canvas_item_bounds (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2); #ifdef WINDOW_CANVAS_ITEM_BOUNDS_REQUIRED -static void window_canvas_item_bounds (FooCanvasItem *item, - double *x1, double *y1, +static void window_canvas_item_bounds (FooCanvasItem *item, + double *x1, double *y1, double *x2, double *y2); #endif /* WINDOW_CANVAS_ITEM_BOUNDS_REQUIRED */ @@ -127,12 +127,12 @@ static void window_canvas_item_invoke_update (FooCanvasItem *item, double i2w_dx, double i2w_dy, int flags); -static double window_canvas_item_invoke_point (FooCanvasItem *item, - double x, double y, +static double window_canvas_item_invoke_point (FooCanvasItem *item, + double x, double y, int cx, int cy, FooCanvasItem **actual_item); -static gboolean feature_is_drawable(ZMapFeature feature_any, - ZMapFeatureTypeStyle feature_style, +static gboolean feature_is_drawable(ZMapFeature feature_any, + ZMapFeatureTypeStyle feature_style, ZMapStyleMode *mode_to_use, GType *type_to_use); static void window_canvas_invoke_set_colours(gpointer list_data, gpointer user_data); @@ -164,10 +164,10 @@ static gboolean debug_point_method_G = FALSE; GType zMapWindowCanvasItemGetType (void) { static GType group_type = 0; - - if (!group_type) + + if (!group_type) { - static const GTypeInfo group_info = + static const GTypeInfo group_info = { sizeof (zmapWindowCanvasItemClass), (GBaseInitFunc) NULL, @@ -180,13 +180,13 @@ GType zMapWindowCanvasItemGetType (void) (GInstanceInitFunc) zmap_window_canvas_item_init, NULL }; - + group_type = g_type_register_static (foo_canvas_group_get_type (), ZMAP_WINDOW_CANVAS_ITEM_NAME, &group_info, 0); } - + return group_type; } @@ -219,9 +219,9 @@ void zMapWindowCanvasItemCheckSize(ZMapWindowCanvasItem canvas_item) * \param parent The FooCanvasGroup which is to be the parent * \param feature_start The group->ypos. where is gets drawn in Y. * \param feature The Feature that will be attached. - * \param feature_style The style that relates to the feature. This - * is not and should not be held by the canvas item. - * There is a specific interface method for accessing + * \param feature_style The style that relates to the feature. This + * is not and should not be held by the canvas item. + * There is a specific interface method for accessing * the style from the canvas item and feature! * * \return The newly created ZMapWindowCanvasItem or NULL on failure @@ -239,11 +239,11 @@ ZMapWindowCanvasItem zMapWindowCanvasItemCreate(FooCanvasGroup *parent, { FooCanvasItem *item; - item = foo_canvas_item_new(parent, sub_type, - "x", 0.0, - "y", feature_start, + item = foo_canvas_item_new(parent, sub_type, + "x", 0.0, + "y", feature_start, NULL); - + if (item && ZMAP_IS_CANVAS_ITEM(item)) { GObject *object; @@ -275,7 +275,7 @@ ZMapWindowCanvasItem zMapWindowCanvasItemCreate(FooCanvasGroup *parent, /*! * \brief simply the opposite of create - * \code + * \code * canvas_item = zMapWindowCanvasItemDestroy(canvas_Item); * \endcode * \param canvas_item The ZMapWindowCanvasItem to clean up. @@ -303,7 +303,7 @@ ZMapWindowCanvasItem zMapWindowCanvasItemDestroy(ZMapWindowCanvasItem canvas_ite /*! * \brief Function to access the ZMapFeature - * \details Although a little surprising, NULL maybe returned legitimately, + * \details Although a little surprising, NULL maybe returned legitimately, * as not all ZMapWindowCanvasItem subclasses require features... * It is architected this way so that we can have _all_ the items * on the canvas below ZMapWindowContainerFeatureSet extend @@ -331,7 +331,7 @@ ZMapFeature zMapWindowCanvasItemGetFeature(FooCanvasItem *any_item) /*! * \brief Function to access the ZMapFeature - * \details Although a little surprising, NULL maybe returned legitimately, + * \details Although a little surprising, NULL maybe returned legitimately, * as not all ZMapWindowCanvasItem subclasses require features... * It is architected this way so that we can have _all_ the items * on the canvas below ZMapWindowContainerFeatureSet extend @@ -357,9 +357,9 @@ void zMapWindowCanvasItemGetBounds(ZMapWindowCanvasItem canvas_item) /*! * \brief Add an "Interval" to the canvas representation. * - * \details An interval is the term I'm using for a region/span, - * whatever else... I chose interval over others for no - * particular reason other than it was different and easy + * \details An interval is the term I'm using for a region/span, + * whatever else... I chose interval over others for no + * particular reason other than it was different and easy * to search for in the codebase. * * \param canvas_item The ZMapWindowCanvasItem to add it to. @@ -373,7 +373,7 @@ void zMapWindowCanvasItemGetBounds(ZMapWindowCanvasItem canvas_item) */ FooCanvasItem *zMapWindowCanvasItemAddInterval(ZMapWindowCanvasItem canvas_item, ZMapFeatureSubPartSpan sub_feature_in, - double top, double bottom, + double top, double bottom, double left, double right) { ZMapWindowCanvasItemClass canvas_item_class; @@ -401,12 +401,12 @@ FooCanvasItem *zMapWindowCanvasItemAddInterval(ZMapWindowCanvasItem canvas_ite ZMapFeature feature; feature = canvas_item->feature; printf("->AddInterval(canvas_item=%p{unique_id=%s}, sub_feature=*{%d,%d,%d}, top=%f, bot=%f, left=%f, right%f)\n", - canvas_item, (feature ? g_quark_to_string(feature->unique_id) : "<no-feature>"), + canvas_item, (feature ? g_quark_to_string(feature->unique_id) : "<no-feature>"), sub_feature->subpart, sub_feature->start, sub_feature->end, top, bottom, left, right); } - interval = (* canvas_item_class->add_interval)(canvas_item, sub_feature, + interval = (* canvas_item_class->add_interval)(canvas_item, sub_feature, top, bottom, left, right); if(interval && ZMAP_IS_CANVAS(interval->canvas)) @@ -422,12 +422,12 @@ FooCanvasItem *zMapWindowCanvasItemAddInterval(ZMapWindowCanvasItem canvas_ite if(sub_feature_in) { /* This means we can be the creators and destroyers of this data, - * callers need not be concerned in any way and can pass in + * callers need not be concerned in any way and can pass in * pointers to structs. We could use g_slice_alloc too! */ if((sub_feature = g_slice_alloc(window_item_feature_size_G))) { memcpy(sub_feature, sub_feature_in, window_item_feature_size_G); - g_object_set_data_full(G_OBJECT(interval), ITEM_SUBFEATURE_DATA, + g_object_set_data_full(G_OBJECT(interval), ITEM_SUBFEATURE_DATA, sub_feature, window_item_feature_destroy); } } @@ -440,7 +440,7 @@ FooCanvasItem *zMapWindowCanvasItemAddInterval(ZMapWindowCanvasItem canvas_ite } } - + #ifdef AUTO_RESIZE_OFF expand_background(canvas_item, NULL, &top, NULL, &bottom); #endif /* AUTO_RESIZE_OFF */ @@ -450,7 +450,7 @@ FooCanvasItem *zMapWindowCanvasItemAddInterval(ZMapWindowCanvasItem canvas_ite /*! * \brief Designed to fix a buglet in FooCanvasItem get_bounds() - * \details Size of Foo canvas items are zero while not being mapped. + * \details Size of Foo canvas items are zero while not being mapped. * This is not really sane for when you want to position items * before mapping occurs... This function fixes that. * \param canvas_item ZMapWindowCanvasItem you want the size of @@ -479,7 +479,7 @@ void zMapWindowCanvasItemGetBumpBounds(ZMapWindowCanvasItem canvas_item, if(0 && x1 + width > x2) x2 = x1 + width; - + if(x1_out) *x1_out = x1; if(x2_out) @@ -500,7 +500,7 @@ gboolean zMapWindowCanvasItemCheckData(ZMapWindowCanvasItem canvas_item, GError { *error = g_error_new(zmap_window_canvas_item_get_domain(), 1, "No ZMapFeatureAny attached to item"); - + result = FALSE; } @@ -508,19 +508,19 @@ gboolean zMapWindowCanvasItemCheckData(ZMapWindowCanvasItem canvas_item, GError { result = ZMAP_CANVAS_ITEM_GET_CLASS(canvas_item)->check_data(canvas_item, error); } - + return result; } /*! * \brief Calls the interface function clear * \details Designed to destroy all the child FooCanvasItems the ZMapWindowCanvasItem knows - * about. As the ZMapWindowCanvasItem has the ZMapFeature, in theory it could + * about. As the ZMapWindowCanvasItem has the ZMapFeature, in theory it could * redraw itself. That's where the idea for this comes from. * \param canvas_item The ZMapWindowCanvasItem to clear * \return void * - * \code + * \code * // currently fantasy psuedo code * transcript_feature = zMapWindowCanvasItemGetFeature(canvas_item); * zMapWindowCanvasItemClear(canvas_item); @@ -535,14 +535,14 @@ void zMapWindowCanvasItemClear(ZMapWindowCanvasItem canvas_item) { ZMAP_CANVAS_ITEM_GET_CLASS(canvas_item)->clear(canvas_item); } - + return ; } void zMapWindowCanvasItemClearOverlay(ZMapWindowCanvasItem canvas_item) { FooCanvasGroup *group; - + group = FOO_CANVAS_GROUP(canvas_item->items[WINDOW_ITEM_OVERLAY]); zmap_canvas_item_purge_group(group); @@ -553,7 +553,7 @@ void zMapWindowCanvasItemClearOverlay(ZMapWindowCanvasItem canvas_item) void zMapWindowCanvasItemClearUnderlay(ZMapWindowCanvasItem canvas_item) { FooCanvasGroup *group; - + group = FOO_CANVAS_GROUP(canvas_item->items[WINDOW_ITEM_UNDERLAY]); zmap_canvas_item_purge_group(group); @@ -620,12 +620,12 @@ FooCanvasItem *zMapWindowCanvasItemGetInterval(ZMapWindowCanvasItem canvas_item, gy = y; foo_canvas_item_w2i(item, &gx, &gy); - + foo_canvas_w2c(canvas, x, y, &cx, &cy); if(debug_point_method_G) printf("GetInterval like ->point(canvas_item=%p, gx=%f, gy=%f, cx=%d, cy=%d)\n", item, gx, gy, cx, cy); - + foo_canvas_item_get_bounds(item, &ix1, &iy1, &ix2, &iy2); wx1 = ix1; wy1 = iy1; @@ -635,52 +635,52 @@ FooCanvasItem *zMapWindowCanvasItemGetInterval(ZMapWindowCanvasItem canvas_item, foo_canvas_item_i2w(item, &wx2, &wy2); if(debug_point_method_G) - printf("ItemCoords(%f,%f,%f,%f), WorldCoords(%f,%f,%f,%f)\n", + printf("ItemCoords(%f,%f,%f,%f), WorldCoords(%f,%f,%f,%f)\n", ix1, iy1, ix2, iy2, wx1, wy1, wx2, wy2); - + dist = window_canvas_item_invoke_point(item, gx, gy, cx, cy, &check); - + small_enough = (int)(dist * canvas->pixels_per_unit_x + 0.5); - + if(small_enough <= canvas->close_enough) { /* we'll continue! */ gx -= group->xpos; gy -= group->ypos; - + if(debug_point_method_G) printf("GetInterval like ->point(canvas_item=%p, gx=%f, gy=%f, cx=%d, cy=%d)\n", item, gx, gy, cx, cy); - + x1 = cx - canvas->close_enough; y1 = cy - canvas->close_enough; x2 = cx + canvas->close_enough; y2 = cy + canvas->close_enough; best = 1e18; - + /* Go through each interval (FooCanvasGroup's item list). * Backgrounds/overlays/underlays not in this list! */ - for (list = group->item_list; list; i++, list = list->next) + for (list = group->item_list; list; i++, list = list->next) { FooCanvasItem *child; - + child = list->data; - + if(debug_point_method_G) printf("examining child[%d]\n", i); - + /* We actaully want the full width of the item here... lines and score by width columns... */ /* filtering only by y coords, effectively... */ if ((child->y1 > y2) || (child->y2 < y1)) continue; - + point_item = NULL; /* cater for incomplete item implementations */ - + if(debug_point_method_G) { printf("further examination..."); - + foo_canvas_item_get_bounds(child, &ix1, &iy1, &ix2, &iy2); wx1 = ix1; wy1 = iy1; @@ -688,28 +688,28 @@ FooCanvasItem *zMapWindowCanvasItemGetInterval(ZMapWindowCanvasItem canvas_item, wy2 = iy2; foo_canvas_item_i2w(child, &wx1, &wy1); foo_canvas_item_i2w(child, &wx2, &wy2); - printf("ItemCoords(%f,%f,%f,%f), WorldCoords(%f,%f,%f,%f)\n", + printf("ItemCoords(%f,%f,%f,%f), WorldCoords(%f,%f,%f,%f)\n", ix1, iy1, ix2, iy2, wx1, wy1, wx2, wy2); } - + /* filter out unmapped items */ if ((child->object.flags & FOO_CANVAS_ITEM_MAPPED) - && FOO_CANVAS_ITEM_GET_CLASS (child)->point) + && FOO_CANVAS_ITEM_GET_CLASS (child)->point) { /* There's some quirks here to get round for lines and rectangles with no fill... */ - + /* We could just check with y coords of item, but prefer to use the * foo_canvas_item_point() code. This ensures FooCanvasGroups can be * intervals. Useful? */ - + if(FOO_IS_CANVAS_RE(child)) { int save_fill_set; save_fill_set = FOO_CANVAS_RE(child)->fill_set; FOO_CANVAS_RE(child)->fill_set = 1; /* foo_canvas_re_point() has a bug/feature where "empty" rectangles - * points only include the outline. Temporarily setting fill_set + * points only include the outline. Temporarily setting fill_set * subverts this... */ dist = window_canvas_item_invoke_point (child, gx, gy, cx, cy, &point_item); FOO_CANVAS_RE(child)->fill_set = save_fill_set; @@ -742,20 +742,20 @@ FooCanvasItem *zMapWindowCanvasItemGetInterval(ZMapWindowCanvasItem canvas_item, } else /* enables groups to be included in the ZMapWindowCanvasItem tree */ dist = window_canvas_item_invoke_point (child, gx, gy, cx, cy, &point_item); - + has_point = TRUE; } else has_point = FALSE; - + /* guessing that the x factor is OK here. RNGC. */ /* Well it's ok, but not ideal... RDS */ if (has_point && point_item && best >= dist) { int small_enough; - + small_enough = (int) (dist * canvas->pixels_per_unit_y + 0.5); - + if(small_enough <= canvas->close_enough) { if(debug_point_method_G) @@ -765,7 +765,7 @@ FooCanvasItem *zMapWindowCanvasItemGetInterval(ZMapWindowCanvasItem canvas_item, matching_interval = point_item; } else if(debug_point_method_G) - printf("child[%d] _not_ small enough (%d)\n", i, small_enough); + printf("child[%d] _not_ small enough (%d)\n", i, small_enough); } else if(debug_point_method_G) printf("child[%d] has no point\n", i); @@ -777,7 +777,7 @@ FooCanvasItem *zMapWindowCanvasItemGetInterval(ZMapWindowCanvasItem canvas_item, /* but we'll just pick the first */ if(group->item_list) matching_interval = (FooCanvasItem *)(group->item_list->data); - + } } @@ -827,7 +827,7 @@ GList *zMapWindowCanvasItemGetChildren(ZMapWindowCanvasItem *parent) { GList *children = NULL ; FooCanvasGroup *foo_group ; - + if (ZMAP_IS_CANVAS_ITEM(parent) && FOO_IS_CANVAS_GROUP(parent) && (foo_group = FOO_CANVAS_GROUP(parent))) @@ -885,16 +885,16 @@ void zMapWindowCanvasItemSetIntervalColours(FooCanvasItem *item, /*! * \brief Function to mark the canvas item - * - * \details Marks the canvas item by drawing an overlay + * + * \details Marks the canvas item by drawing an overlay * the same size as the background. The overlay - * will be a rectangle drawn with a stipple (bitmap) + * will be a rectangle drawn with a stipple (bitmap) * using the supplied colour. * * \param canvas_item The ZMapWindowCanvasItem to mark * \param colour The GdkColor to use for the mark * \param bitmap The GdkBitmap to use for the mark - * + * * \return void */ void zMapWindowCanvasItemMark(ZMapWindowCanvasItem canvas_item, @@ -915,7 +915,7 @@ void zMapWindowCanvasItemMark(ZMapWindowCanvasItem canvas_item, gdk_color_parse("red", &outline); #endif /* DEBUG_ITEM_MARK */ - foo_canvas_item_get_bounds(FOO_CANVAS_ITEM(canvas_item->items[WINDOW_ITEM_BACKGROUND]), + foo_canvas_item_get_bounds(FOO_CANVAS_ITEM(canvas_item->items[WINDOW_ITEM_BACKGROUND]), &x1, &y1, &x2, &y2); parent = FOO_CANVAS_GROUP(canvas_item->items[WINDOW_ITEM_OVERLAY]); @@ -955,7 +955,7 @@ void zMapWindowCanvasItemUnmark(ZMapWindowCanvasItem canvas_item) if(canvas_item->mark_item) { gtk_object_destroy(GTK_OBJECT(canvas_item->mark_item)); - + canvas_item->mark_item = NULL; } @@ -1020,7 +1020,7 @@ static void zmap_canvas_item_purge_group(FooCanvasGroup *group) static void redraw_and_repick_if_mapped (FooCanvasItem *item) { - if (item->object.flags & FOO_CANVAS_ITEM_MAPPED) + if (item->object.flags & FOO_CANVAS_ITEM_MAPPED) { foo_canvas_item_request_redraw (item); item->canvas->need_repick = TRUE; @@ -1045,20 +1045,20 @@ static void group_add (FooCanvasGroup *group, FooCanvasItem *item) { g_object_ref (GTK_OBJECT (item)); gtk_object_sink (GTK_OBJECT (item)); - - if (!group->item_list) + + if (!group->item_list) { group->item_list = g_list_append (group->item_list, item); group->item_list_end = group->item_list; - } + } else group->item_list_end = g_list_append (group->item_list_end, item)->next; - + if (item->object.flags & FOO_CANVAS_ITEM_VISIBLE && group->item.object.flags & FOO_CANVAS_ITEM_MAPPED) { if (!(item->object.flags & FOO_CANVAS_ITEM_REALIZED)) (* FOO_CANVAS_ITEM_GET_CLASS (item)->realize) (item); - + if (!(item->object.flags & FOO_CANVAS_ITEM_MAPPED)) (* FOO_CANVAS_ITEM_GET_CLASS (item)->map) (item); } @@ -1076,31 +1076,31 @@ static void group_remove (FooCanvasGroup *group, FooCanvasItem *item) #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ - + zMapLogReturnIfFail (FOO_IS_CANVAS_GROUP (group)); zMapLogReturnIfFail (FOO_IS_CANVAS_ITEM (item)); - + for (children = group->item_list; children; children = children->next) { - if (children->data == item) + if (children->data == item) { if (item->object.flags & FOO_CANVAS_ITEM_MAPPED) (* FOO_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); - + if (item->object.flags & FOO_CANVAS_ITEM_REALIZED) (* FOO_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); - + /* Unparent the child */ - + item->parent = NULL; /* item->canvas = NULL; */ /* Just to comment this, without rebuilding! */ g_object_unref (item); - + /* Remove it from the list */ - + if (children == group->item_list_end) group->item_list_end = children->prev; - + group->item_list = g_list_remove_link (group->item_list, children); g_list_free (children); break; @@ -1114,30 +1114,30 @@ void zMapWindowCanvasItemReparent(FooCanvasItem *item, FooCanvasGroup *new_group { zMapLogReturnIfFail (FOO_IS_CANVAS_ITEM (item)); zMapLogReturnIfFail (FOO_IS_CANVAS_GROUP (new_group)); - + /* Both items need to be in the same canvas */ zMapLogReturnIfFail (item->canvas == FOO_CANVAS_ITEM (new_group)->canvas); - + /* The group cannot be an inferior of the item or be the item itself -- * this also takes care of the case where the item is the root item of * the canvas. */ zMapLogReturnIfFail (!is_descendant (FOO_CANVAS_ITEM (new_group), item)); - + /* Everything is ok, now actually reparent the item */ - + g_object_ref (GTK_OBJECT (item)); /* protect it from the unref in group_remove */ - + foo_canvas_item_request_redraw (item); - + group_remove (FOO_CANVAS_GROUP (item->parent), item); item->parent = FOO_CANVAS_ITEM (new_group); /* item->canvas is unchanged. */ group_add (new_group, item); - + /* Redraw and repick */ - + redraw_and_repick_if_mapped (item); - + g_object_unref (GTK_OBJECT (item)); return ; @@ -1170,10 +1170,10 @@ static void zmap_window_canvas_item_class_init (ZMapWindowCanvasItemClass window parent_type = g_type_parent(canvas_item_type); group_parent_class_G = gtk_type_class(parent_type); - + gobject_class->set_property = zmap_window_canvas_item_set_property; gobject_class->get_property = zmap_window_canvas_item_get_property; - + g_object_class_install_property(gobject_class, WINDOW_CANVAS_ITEM_INTERVAL_TYPE, g_param_spec_uint("interval-type", "interval type", "The type to use when creating a new interval", @@ -1228,7 +1228,7 @@ static void zmap_window_canvas_item_class_init (ZMapWindowCanvasItemClass window make_clickable_bmp_height) ; window_item_feature_size_G = sizeof(ZMapFeatureSubPartSpanStruct); - + return ; } @@ -1256,22 +1256,22 @@ static void zmap_window_canvas_item_set_property (GObject *gobject, guint param_ FooCanvasItem *item; FooCanvasGroup *group; gboolean moved; - + zMapLogReturnIfFail (FOO_IS_CANVAS_GROUP (gobject)); - + item = FOO_CANVAS_ITEM (gobject); group = FOO_CANVAS_GROUP (gobject); - + moved = FALSE; - switch (param_id) + switch (param_id) { case WINDOW_CANVAS_ITEM_AUTO_RESIZE_BG: { ZMapWindowCanvasItem canvas_item; canvas_item = ZMAP_CANVAS_ITEM(gobject); - + canvas_item->auto_resize_background = g_value_get_uint(value); } break; @@ -1311,7 +1311,7 @@ static void zmap_window_canvas_item_set_property (GObject *gobject, guint param_ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, param_id, pspec); break; } - + return ; } @@ -1321,13 +1321,13 @@ static void zmap_window_canvas_item_get_property (GObject *gobject, guint param_ { FooCanvasItem *item; FooCanvasGroup *group; - + zMapLogReturnIfFail (FOO_IS_CANVAS_GROUP (gobject)); - + item = FOO_CANVAS_ITEM (gobject); group = FOO_CANVAS_GROUP (gobject); - - switch (param_id) + + switch (param_id) { case WINDOW_CANVAS_ITEM_FEATURE: { @@ -1393,7 +1393,7 @@ static gboolean canvasItemEventCB(FooCanvasItem *item, GdkEvent *event, gpointer FooCanvasRE *rect; double ix1, ix2, iy1, iy2; double wx1, wx2, wy1, wy2; - + rect = FOO_CANVAS_RE(item); foo_canvas_item_get_bounds(item, &ix1, &iy1, &ix2, &iy2); @@ -1425,7 +1425,7 @@ static void zmap_window_canvas_item_post_create(ZMapWindowCanvasItem canvas_item FooCanvasItem *remove_me; int i; #ifdef DEBUG_BACKGROUND_BOX - GdkColor outline = {0}; + GdkColor outline = {0}; GdkColor fill = {0}; gdk_color_parse("orange", &outline); @@ -1447,9 +1447,9 @@ static void zmap_window_canvas_item_post_create(ZMapWindowCanvasItem canvas_item * FooCanvasItem interface they'll get drawn how and in what order we want them to be. */ /* background is drawn _first_, below _everything_ else! */ - canvas_item->items[WINDOW_ITEM_BACKGROUND] = + canvas_item->items[WINDOW_ITEM_BACKGROUND] = foo_canvas_item_new(group, FOO_TYPE_CANVAS_RECT, - "x1", 0.0, "y1", 0.0, + "x1", 0.0, "y1", 0.0, "x1", 0.0, "y2", 0.0, #ifdef DEBUG_BACKGROUND_BOX "width_pixels", 1, @@ -1460,16 +1460,16 @@ static void zmap_window_canvas_item_post_create(ZMapWindowCanvasItem canvas_item /* underlays will be drawn next. */ - canvas_item->items[WINDOW_ITEM_UNDERLAY] = + canvas_item->items[WINDOW_ITEM_UNDERLAY] = foo_canvas_item_new(group, FOO_TYPE_CANVAS_GROUP, "x", 0.0, "y", 0.0, NULL); - + /* If this were the draw cycle the item_list members would be drawn now */ /* overlays last to always be seen */ - canvas_item->items[WINDOW_ITEM_OVERLAY] = + canvas_item->items[WINDOW_ITEM_OVERLAY] = foo_canvas_item_new(group, FOO_TYPE_CANVAS_GROUP, "x", 0.0, "y", 0.0, @@ -1479,7 +1479,7 @@ static void zmap_window_canvas_item_post_create(ZMapWindowCanvasItem canvas_item group->item_list = group->item_list_end = NULL; #ifdef NEVER_INCLUDE_DEBUG_EVENTS - g_signal_connect(G_OBJECT(canvas_item->items[WINDOW_ITEM_BACKGROUND]), "event", + g_signal_connect(G_OBJECT(canvas_item->items[WINDOW_ITEM_BACKGROUND]), "event", G_CALLBACK(canvasItemEventCB), NULL); #endif /* NEVER_INCLUDE_DEBUG_EVENTS */ @@ -1491,12 +1491,12 @@ static void zmap_window_canvas_item_post_create(ZMapWindowCanvasItem canvas_item { if (remove_me->object.flags & FOO_CANVAS_ITEM_MAPPED) (* FOO_CANVAS_ITEM_GET_CLASS (remove_me)->unmap) (remove_me); - + if (remove_me->object.flags & FOO_CANVAS_ITEM_REALIZED) (* FOO_CANVAS_ITEM_GET_CLASS (remove_me)->unrealize) (remove_me); } } - + return ; } @@ -1516,9 +1516,9 @@ static ZMapFeatureTypeStyle zmap_window_canvas_item_get_style(ZMapWindowCanvasIt if(item->parent && item->parent->parent) { - container_parent = zmapWindowContainerCanvasItemGetContainer(item); + container_parent = zmapWindowContainerCanvasItemGetContainer(item); /* can optimise this a bit, by including the featureset_i header... */ - style = zmapWindowContainerFeatureSetStyleFromID((ZMapWindowContainerFeatureSet)container_parent, + style = zmapWindowContainerFeatureSetStyleFromID((ZMapWindowContainerFeatureSet)container_parent, canvas_item->feature->style_id); } @@ -1526,16 +1526,16 @@ static ZMapFeatureTypeStyle zmap_window_canvas_item_get_style(ZMapWindowCanvasIt } static void maximise_background_rectangle(ZMapWindowCanvasItem window_canvas_item, - FooCanvasItem *canvas_item, + FooCanvasItem *canvas_item, FooCanvasRE *rect) { FooCanvasItem *rect_item; double irx1, irx2, iry1, iry2; int canvas_x1, canvas_y1; /* canvas_item canvas coords, calculated from group->update above. */ int canvas_x2, canvas_y2; /* canvas_item canvas coords, calculated from group->update above. */ - + irx1 = iry1 = 0.0; /* placed @ 0,0 */ - + /* We can't trust item->x1 and item->y1 as empty child * groups return 0,0->0,0 hence extend all parents to * 0,0! */ @@ -1555,7 +1555,7 @@ static void maximise_background_rectangle(ZMapWindowCanvasItem window_canvas_ite foo_canvas_c2w(rect_item->canvas, canvas_x1, canvas_y1, &irx1, &iry1); foo_canvas_c2w(rect_item->canvas, canvas_x2, canvas_y2, &irx2, &iry2); - + rect->x1 = (double)(int)(irx1 + 0.5); rect->y1 = (double)(int)(iry1 + 0.5); rect->x2 = (double)(int)(irx2 - 0.5); @@ -1576,7 +1576,7 @@ static void maximise_background_rectangle(ZMapWindowCanvasItem window_canvas_ite feature = window_canvas_item->feature; printf("maximise_background_rectangle: feature=%s, x1=%f, y1=%f, x2=%f, y2=%f\n", - (feature ? g_quark_to_string(feature->unique_id) : "<no-feature>"), + (feature ? g_quark_to_string(feature->unique_id) : "<no-feature>"), rect->x1, rect->y1, rect->x2, rect->y2); if (feature) { @@ -1606,7 +1606,7 @@ static void crop_background_rectangle(ZMapWindowCanvasItem window_canvas_item, double scroll_x1, scroll_y1, scroll_x2, scroll_y2; double iwx1, iwy1, iwx2, iwy2; gboolean crop_needed = TRUE; - + foo_canvas = canvas_item->canvas; crop_item = (FooCanvasItem *)rect; @@ -1620,20 +1620,20 @@ static void crop_background_rectangle(ZMapWindowCanvasItem window_canvas_item, /* x unused ATM */ scroll_x1 = foo_canvas->scroll_x1; scroll_x2 = foo_canvas->scroll_x2; - + scroll_y1 = foo_canvas->scroll_y1; scroll_y2 = foo_canvas->scroll_y2; - + foo_canvas_item_w2i(crop_item, &scroll_x1, &scroll_y1); foo_canvas_item_w2i(crop_item, &scroll_x2, &scroll_y2); - + if (!(iwy2 < scroll_y1) && !(iwy1 > scroll_y2) && ((iwy1 < scroll_y1) || (iwy2 > scroll_y2))) { if(iwy1 < scroll_y1) { rect->y1 = scroll_y1 - 1.0; } - + if(iwy2 > scroll_y2) { rect->y2 = scroll_y2 + 1.0; @@ -1656,7 +1656,7 @@ static void zmap_window_canvas_item_update (FooCanvasItem *item, double i2w_dx, gboolean visible; double xpos, ypos; int i; - + visible = ((item->object.flags & FOO_CANVAS_ITEM_VISIBLE) == FOO_CANVAS_ITEM_VISIBLE); canvas_item = ZMAP_CANVAS_ITEM(item); @@ -1668,18 +1668,18 @@ static void zmap_window_canvas_item_update (FooCanvasItem *item, double i2w_dx, /* chain up, to update all the interval items that are legitimately part of the group, first... */ (* group_parent_class_G->update) (item, i2w_dx, i2w_dy, flags); - + canvas_group = FOO_CANVAS_GROUP(item); - + xpos = canvas_group->xpos; ypos = canvas_group->ypos; - + if((canvas_item->auto_resize_background) && visible && (FOO_IS_CANVAS_RE(canvas_item->items[WINDOW_ITEM_BACKGROUND])) && (bg_rect = FOO_CANVAS_RE(canvas_item->items[WINDOW_ITEM_BACKGROUND]))) { maximise_background_rectangle(canvas_item, item, bg_rect); - + if(flags & ZMAP_CANVAS_UPDATE_CROP_REQUIRED) { crop_background_rectangle(canvas_item, item, bg_rect); @@ -1692,25 +1692,47 @@ static void zmap_window_canvas_item_update (FooCanvasItem *item, double i2w_dx, if(!(update_me = canvas_item->items[i])) continue; +/* these if's should really be included +Code has been added to zmapWindowCollectionFeature,c to realize and map the items but it does not have the desired effect +however: this does what's required with no extra warning messages + if(!(update_me->object.flags & FOO_CANVAS_ITEM_MAPPED)) continue; if(!(update_me->object.flags & FOO_CANVAS_ITEM_REALIZED)) continue; - +*/ if(!(update_me->object.flags & FOO_CANVAS_ITEM_VISIBLE)) - continue; + continue; if(FOO_IS_CANVAS_GROUP(update_me) && FOO_CANVAS_GROUP(update_me)->item_list == NULL) - continue; + continue; + + /* mh17: not sure if this is valid/safe..we're not using the layers that have been set up so carefully + * can't find any definition anywhere of what map and realize signify, + * can only see that they set the MAPPED and REALIZED flags + * However, this causes the underlay and overlay features to draw as required. + * Q: would CollectionFeature be better coded as another layer of CanvasItemGroup? + * then we'd only have one lot of code to debug + */ + +/* + *** WE GET FOO_CANVAS_CRITICAL_ERRORS *** if realize gets called + as it does a request_update, which is not allowed from within an update + + if(!(update_me->object.flags & FOO_CANVAS_ITEM_REALIZED)) + (* FOO_CANVAS_ITEM_GET_CLASS(update_me)->realize)(update_me); + if(!(update_me->object.flags & FOO_CANVAS_ITEM_MAPPED)) + (* FOO_CANVAS_ITEM_GET_CLASS(update_me)->map)(update_me); +*/ window_canvas_item_invoke_update(update_me, i2w_dx + xpos, i2w_dy + ypos, flags); - if(update_me->x2 != 0.0 && - update_me->y2 != 0.0 && - update_me->x1 != update_me->x2 && - update_me->y1 != update_me->y2) + if(update_me->x2 != 0.0 && + update_me->y2 != 0.0 && + update_me->x1 != update_me->x2 && + update_me->y1 != update_me->y2) { item->x1 = MIN ((update_me->x1), item->x1); item->y1 = MIN ((update_me->y1), item->y1); @@ -1721,11 +1743,14 @@ static void zmap_window_canvas_item_update (FooCanvasItem *item, double i2w_dx, { printf("child %d had zero size\n", i); } + } return ; } + + static void zmap_window_canvas_item_realize (FooCanvasItem *item) { ZMapWindowCanvasItem canvas_item; @@ -1781,6 +1806,8 @@ static void zmap_window_canvas_item_map (FooCanvasItem *item) int i; canvas_item = ZMAP_CANVAS_ITEM(item); +if(canvas_item->debug) + printf("mapping debug canvas item\n"); (* group_parent_class_G->map) (item); @@ -1833,7 +1860,7 @@ static void zmap_window_canvas_item_unmap (FooCanvasItem *item) } } } - + return ; } @@ -1852,7 +1879,7 @@ static void zmap_window_canvas_item_draw (FooCanvasItem *item, GdkDrawable *draw canvas_item = ZMAP_CANVAS_ITEM(item); - for(i = (item->object.flags & FOO_CANVAS_ITEM_VISIBLE ? 0 : WINDOW_ITEM_COUNT); + for(i = (item->object.flags & FOO_CANVAS_ITEM_VISIBLE ? 0 : WINDOW_ITEM_COUNT); i < WINDOW_ITEM_COUNT; ++i) { if(i == WINDOW_ITEM_OVERLAY) @@ -1868,7 +1895,7 @@ static void zmap_window_canvas_item_draw (FooCanvasItem *item, GdkDrawable *draw { if(!(draw_me->object.flags & FOO_CANVAS_ITEM_REALIZED)) (* FOO_CANVAS_ITEM_GET_CLASS(draw_me)->realize)(draw_me); - + if(!(draw_me->object.flags & FOO_CANVAS_ITEM_MAPPED)) (*FOO_CANVAS_ITEM_GET_CLASS(draw_me)->map)(draw_me); @@ -1892,15 +1919,15 @@ static double zmap_window_canvas_item_point (FooCanvasItem *item, double x, doub double dist, best; group = FOO_CANVAS_GROUP (item); - + x1 = cx - item->canvas->close_enough; y1 = cy - item->canvas->close_enough; x2 = cx + item->canvas->close_enough; y2 = cy + item->canvas->close_enough; - + best = 0.0; *actual_item = NULL; - + gx = x - group->xpos; gy = y - group->ypos; @@ -1911,37 +1938,37 @@ static double zmap_window_canvas_item_point (FooCanvasItem *item, double x, doub if(debug_point_method_G) printf("->point(canvas_item=%p, x=%f, y=%f, cx=%d, cy=%d)\n", item, x, y, cx, cy); - if (!((child->x1 > x2) || - (child->y1 > y2) || - (child->x2 < x1) || + if (!((child->x1 > x2) || + (child->y1 > y2) || + (child->x2 < x1) || (child->y2 < y1))) { point_item = NULL; - + if ((child->object.flags & FOO_CANVAS_ITEM_MAPPED) - && FOO_CANVAS_ITEM_GET_CLASS (child)->point) + && FOO_CANVAS_ITEM_GET_CLASS (child)->point) { dist = window_canvas_item_invoke_point (child, gx, gy, cx, cy, &point_item); - if((point_item != NULL) && + if((point_item != NULL) && ((int)(dist * item->canvas->pixels_per_unit_x + 0.5) <= item->canvas->close_enough)) { best = dist; *actual_item = point_item; } - } + } } } - + return best; } static void zmap_window_canvas_item_translate (FooCanvasItem *item, double dx, double dy) { FooCanvasGroup *group; - + group = FOO_CANVAS_GROUP (item); - + group->xpos += dx; group->ypos += dy; @@ -1949,8 +1976,8 @@ static void zmap_window_canvas_item_translate (FooCanvasItem *item, double dx, d } /* Bounds handler for canvas groups */ -static void zmap_window_canvas_item_bounds (FooCanvasItem *item, - double *x1_out, double *y1_out, +static void zmap_window_canvas_item_bounds (FooCanvasItem *item, + double *x1_out, double *y1_out, double *x2_out, double *y2_out) { ZMapWindowCanvasItem canvas_item; @@ -1976,9 +2003,9 @@ static void zmap_window_canvas_item_bounds (FooCanvasItem *item, if((background = canvas_item->items[WINDOW_ITEM_BACKGROUND])) { gboolean fix_undrawn_have_zero_size = TRUE; - + (* FOO_CANVAS_ITEM_GET_CLASS(background)->bounds)(background, &x1, &y1, &x2, &y2); - + /* test this! */ #ifdef DEBUG_BACKGROUND_BOX if(fix_undrawn_have_zero_size && x1 == y1 && x2 == y2 && x1 == -0.5) @@ -2003,7 +2030,7 @@ static void zmap_window_canvas_item_bounds (FooCanvasItem *item, } } - + if(x1_out) *x1_out = x1 + gx; if(x2_out) @@ -2137,9 +2164,9 @@ static gboolean zmap_window_canvas_item_check_data(ZMapWindowCanvasItem canvas_i FooCanvasGroup *group; gboolean result = TRUE; GList *list; - + group = FOO_CANVAS_GROUP(canvas_item); - + list = group->item_list; while(result && list) @@ -2177,15 +2204,15 @@ static void expand_background(ZMapWindowCanvasItem canvas_item, top = *y1_in; bottom = *y2_in; - + g_object_get(G_OBJECT(background), "y1", &y1, "y2", &y2, NULL); - + if(top < y1) y1 = top; - + if(bottom > y2) y2 = bottom; - + if(y1 < 0.0) g_warning("unexpected value [%f] for y1.", y1); } @@ -2195,22 +2222,22 @@ static void expand_background(ZMapWindowCanvasItem canvas_item, y2 = (double)(feature->x2 - feature->x1 + 1.0); } - + if(x1_in && x2_in) { double left, right; - + left = *x1_in; right = *x2_in; g_object_get(G_OBJECT(background), "x1", &x1, "x2", &x2, NULL); - + if(left < x1) x1 = left; - + if(right > x2) x2 = right; - + if(x1 < 0.0) g_warning("unexpected value [%f] for x1.", x1); } @@ -2219,15 +2246,15 @@ static void expand_background(ZMapWindowCanvasItem canvas_item, ZMapFeatureTypeStyle style = NULL; style = (ZMAP_CANVAS_ITEM_GET_CLASS(canvas_item)->get_style)(canvas_item); - + x1 = 0.0; x2 = zMapStyleGetWidth(style) - 1.0; } - foo_canvas_item_set(background, - "x1", x1, "x2", x2, - "y1", y1, "y2", y2, + foo_canvas_item_set(background, + "x1", x1, "x2", x2, + "y1", y1, "y2", y2, NULL); /* long items update too! */ @@ -2258,23 +2285,23 @@ static void window_canvas_item_invoke_update (FooCanvasItem *item, int flags) { int child_flags; - + child_flags = flags; - + /* apply object flags to child flags */ child_flags &= ~FOO_CANVAS_UPDATE_REQUESTED; - + if (item->object.flags & FOO_CANVAS_ITEM_NEED_UPDATE) child_flags |= FOO_CANVAS_UPDATE_REQUESTED; - + if (item->object.flags & FOO_CANVAS_ITEM_NEED_DEEP_UPDATE) child_flags |= FOO_CANVAS_UPDATE_DEEP; - + if (child_flags & GCI_UPDATE_MASK) { if (FOO_CANVAS_ITEM_GET_CLASS (item)->update) FOO_CANVAS_ITEM_GET_CLASS (item)->update (item, i2w_dx, i2w_dy, child_flags); } - + /* If this fail you probably forgot to chain up to * FooCanvasItem::update from a derived class */ zMapLogReturnIfFail (!(item->object.flags & FOO_CANVAS_ITEM_NEED_UPDATE)); @@ -2288,22 +2315,22 @@ static void window_canvas_item_invoke_update (FooCanvasItem *item, * The arguments x, y should be in the parent item local coordinates. */ -static double window_canvas_item_invoke_point (FooCanvasItem *item, - double x, double y, +static double window_canvas_item_invoke_point (FooCanvasItem *item, + double x, double y, int cx, int cy, FooCanvasItem **actual_item) { /* Calculate x & y in item local coordinates */ - + if (FOO_CANVAS_ITEM_GET_CLASS (item)->point) return FOO_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy, actual_item); - + return 1e18; } -static gboolean feature_is_drawable(ZMapFeature feature_any, - ZMapFeatureTypeStyle feature_style, +static gboolean feature_is_drawable(ZMapFeature feature_any, + ZMapFeatureTypeStyle feature_style, ZMapStyleMode *mode_to_use, GType *type_to_use) { @@ -2317,7 +2344,7 @@ static gboolean feature_is_drawable(ZMapFeature feature_any, { ZMapFeature feature; feature = (ZMapFeature)feature_any; - + mode = feature->type; mode = zMapStyleGetMode(feature_style); @@ -2346,7 +2373,7 @@ static gboolean feature_is_drawable(ZMapFeature feature_any, type = ZMAP_TYPE_WINDOW_BASIC_FEATURE; break; } - + result = TRUE; } break; @@ -2379,10 +2406,10 @@ static void window_canvas_invoke_set_colours(gpointer list_data, gpointer user_d sub_feature = &local_struct; sub_feature->subpart = ZMAPFEATURE_SUBPART_INVALID; } - + if(interval_data->klass->set_colour) - interval_data->klass->set_colour(interval_data->parent, interval, sub_feature, - interval_data->style_colour_type, + interval_data->klass->set_colour(interval_data->parent, interval, sub_feature, + interval_data->style_colour_type, interval_data->default_fill_colour); } diff --git a/src/zmapWindow/items/zmapWindowCollectionFeature.c b/src/zmapWindow/items/zmapWindowCollectionFeature.c index 70e733b16..3d9516378 100755 --- a/src/zmapWindow/items/zmapWindowCollectionFeature.c +++ b/src/zmapWindow/items/zmapWindowCollectionFeature.c @@ -29,10 +29,11 @@ * HISTORY: * Last edited: Feb 16 10:22 2010 (edgrif) * Created: Wed Dec 3 10:02:22 2008 (rds) - * CVS info: $Id: zmapWindowCollectionFeature.c,v 1.16 2010-02-25 14:14:20 mh17 Exp $ + * CVS info: $Id: zmapWindowCollectionFeature.c,v 1.17 2010-02-26 13:34:51 mh17 Exp $ *------------------------------------------------------------------- */ #include <math.h> +#include <glib.h> #include <zmapWindowCollectionFeature_I.h> typedef enum {FIRST_MATCH, LAST_MATCH} MatchType ; @@ -723,6 +724,10 @@ static void group_remove(gpointer data, gpointer user_data) return ; } + +FooCanvasItem *foo_G[20]; +int n_foo_G = 0; + static void add_colinear_lines(gpointer data, gpointer user_data) { ColinearMarkerData colinear_data = (ColinearMarkerData)user_data; @@ -789,6 +794,22 @@ static void add_colinear_lines(gpointer data, gpointer user_data) "points", &line_points, "fill_color_gdk", draw_colour, NULL); + // canvas_item->debug = 1; + + /* mh17: not sure if this is valid/safe.. + * can't find any definition anywhere of what map and realize signify, + * can only see that they set the MAPPED and REALIZED flags + * However, this causes the underlay and overlay features to draw as required. + * Q: would CollectionFeature be better coded as another layer of CanvasItemGroup? + * then we'd only have one lot of code to debug + */ + // see also gylphs + // these don't work! + if(!(colinear_line->object.flags & FOO_CANVAS_ITEM_REALIZED)) + FOO_CANVAS_ITEM_GET_CLASS(colinear_line)->realize (colinear_line); + if(!(colinear_line->object.flags & FOO_CANVAS_ITEM_MAPPED)) + FOO_CANVAS_ITEM_GET_CLASS(colinear_line)->map (colinear_line); + zmapWindowLongItemCheckPointFull(colinear_line, &line_points, 0.0, 0.0, 0.0, 0.0); } @@ -830,6 +851,7 @@ static void markMatchIfIncomplete(ZMapWindowCanvasItem collection, GdkColor fill,outline ; ZMapStyleGlyphType glyph_style ; ZMapFeatureTypeStyle style ; + FooCanvasItem *foo; /* get from style, default to previous hard coded value ('6') */ glyph_style = zmapWindowCanvasItemGetGlyph(collection); @@ -860,7 +882,7 @@ static void markMatchIfIncomplete(ZMapWindowCanvasItem collection, y_coord = feature->x2 - ((FooCanvasGroup *)collection)->ypos; } - foo_canvas_item_new(FOO_CANVAS_GROUP(collection->items[WINDOW_ITEM_OVERLAY]), + foo = foo_canvas_item_new(FOO_CANVAS_GROUP(collection->items[WINDOW_ITEM_OVERLAY]), zMapWindowGlyphItemGetType(), "x", x_coord, "y", y_coord, @@ -871,6 +893,22 @@ static void markMatchIfIncomplete(ZMapWindowCanvasItem collection, "fill_color_gdk", marker_fill, "outline_color_gdk", marker_border, NULL); + + /* mh17: not sure if this is valid/safe..we're not using the layers that have been set up so carefully + * can't find any definition anywhere of what map and realize signify, + * can only see that they set the MAPPED and REALIZED flags + * However, this causes the underlay and overlay features to draw as required. + * Q: would CollectionFeature be better coded as another layer of CanvasItemGroup? + * then we'd only have one lot of code to debug + */ + // see also colinear lines + // these don't work! + if(!(foo->object.flags & FOO_CANVAS_ITEM_REALIZED)) + FOO_CANVAS_ITEM_GET_CLASS(foo)->realize (foo); + if(!(foo->object.flags & FOO_CANVAS_ITEM_MAPPED)) + FOO_CANVAS_ITEM_GET_CLASS(foo)->map (foo); + + } return ; diff --git a/src/zmapWindow/zmapWindowColBump.c b/src/zmapWindow/zmapWindowColBump.c index 9dbbbdb2d..76b8562d8 100755 --- a/src/zmapWindow/zmapWindowColBump.c +++ b/src/zmapWindow/zmapWindowColBump.c @@ -6,12 +6,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -29,7 +29,7 @@ * HISTORY: * Last edited: Feb 15 11:54 2010 (edgrif) * Created: Tue Sep 4 10:52:09 2007 (edgrif) - * CVS info: $Id: zmapWindowColBump.c,v 1.63 2010-02-16 10:09:23 edgrif Exp $ + * CVS info: $Id: zmapWindowColBump.c,v 1.64 2010-02-26 13:34:51 mh17 Exp $ *------------------------------------------------------------------- */ @@ -40,6 +40,8 @@ #include <zmapWindowContainerFeatureSet_I.h> #include <zmapWindowContainerUtils.h> #include <zmapWindowFeatures.h> +#include <zmapWindowCanvas.h> + typedef struct { @@ -229,9 +231,9 @@ static void printQuarks(gpointer data, gpointer user_data) ; static ZMapStyleBumpMode hack_initial_mode(ZMapFeatureTypeStyle style); #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ -static void invoke_bump_to_initial(ZMapWindowContainerGroup container, FooCanvasPoints *points, +static void invoke_bump_to_initial(ZMapWindowContainerGroup container, FooCanvasPoints *points, ZMapContainerLevelType level, gpointer user_data); -static void invoke_bump_to_unbump(ZMapWindowContainerGroup container, FooCanvasPoints *points, +static void invoke_bump_to_unbump(ZMapWindowContainerGroup container, FooCanvasPoints *points, ZMapContainerLevelType level, gpointer user_data); /* Merely a cover function for the real bumping code function zmapWindowColumnBumpRange(). */ @@ -263,7 +265,7 @@ void zmapWindowContainerShowAllHiddenFeatures(ZMapWindowContainerFeatureSet cont container_set->hidden_bump_features = FALSE ; } - + return ; } @@ -291,8 +293,8 @@ static ColinearityType colinear_compare_features_cb(ZMapFeature feature_a, ComplexCol column_data = (ComplexCol)user_data; ColinearityType type = COLINEAR_INVALID; - type = featureHomolIsColinear(column_data->bump_properties->window, - column_data->bump_properties->match_threshold, + type = featureHomolIsColinear(column_data->bump_properties->window, + column_data->bump_properties->match_threshold, feature_a, feature_b); return type; @@ -335,9 +337,9 @@ static gboolean column_clear_collections(FooCanvasGroup *column_features) if(ZMAP_IS_WINDOW_COLLECTION_FEATURE(list->data)) { ZMapWindowCanvasItem canvas_item; - + canvas_item = ZMAP_CANVAS_ITEM(list->data); - + zMapWindowCollectionFeatureRemoveSubFeatures(canvas_item, FALSE, TRUE); zMapWindowCanvasItemClearOverlay(canvas_item); @@ -359,7 +361,7 @@ static gboolean column_clear_collections(FooCanvasGroup *column_features) * in the column then bumps just features in that column that share the same style. This * allows the user control over whether to bump all features in a column or just some features * in a column. - * + * * NOTE: this function bumps an individual column but it DOES NOT move any other columns, * to do that you need to use zmapWindowColumnReposition(). The split is made because * we don't always want to reposition all the columns following a bump, e.g. when we @@ -463,7 +465,7 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ else zMapLogCritical("Missing style '%s'", g_quark_to_string(feature->style_id)); } - + /* If range set explicitly or a mark is set on the window, then only bump within the range of mark * or the visible section of the window. */ if (compress_mode == ZMAPWINDOW_COMPRESS_INVALID) @@ -481,16 +483,16 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ if (compress_mode == ZMAPWINDOW_COMPRESS_VISIBLE) { double wx1, wy1, wx2, wy2 ; - - - zmapWindowItemGetVisibleCanvas(window, + + + zmapWindowItemGetVisibleCanvas(window, &wx1, &wy1, &wx2, &wy2); - + #ifdef ED_G_NEVER_INCLUDE_THIS_CODE printf("Visible %f, %f -> %f, %f\n", wx1, wy1, wx2, wy2) ; #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ - + /* should really clamp to seq. start/end..... */ start = (int)wy1 ; end = (int)wy2 ; @@ -563,8 +565,8 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ NULL, hashDataDestroyCB) ; - if (bump_mode == ZMAPBUMP_NAME_BEST_ENDS || - bump_mode == ZMAPBUMP_NAME_COLINEAR || + if (bump_mode == ZMAPBUMP_NAME_BEST_ENDS || + bump_mode == ZMAPBUMP_NAME_COLINEAR || bump_mode == ZMAPBUMP_NAME_NO_INTERLEAVE) g_list_foreach(column_features->item_list, makeNameListStrandedCB, &complex) ; else @@ -610,7 +612,7 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ || (bump_mode == ZMAPBUMP_NAME_BEST_ENDS || bump_mode == ZMAPBUMP_NAME_COLINEAR)) { RangeDataStruct range = {FALSE} ; - + range.start = start ; range.end = end ; @@ -619,7 +621,7 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ list_length = g_list_length(names_list) ; - if (compress_mode == ZMAPWINDOW_COMPRESS_VISIBLE || + if (compress_mode == ZMAPWINDOW_COMPRESS_VISIBLE || compress_mode == ZMAPWINDOW_COMPRESS_MARK) { if (removeNameListsByRange(&names_list, start, end)) @@ -677,7 +679,7 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ g_list_foreach(names_list, setOffsetCB, &complex) ; zMapPrintTimer(NULL, "offsets set for subsets of features") ; - + /* we reverse the offsets for reverse strand cols so as to mirror the forward strand. */ @@ -705,7 +707,7 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ #ifdef ED_G_NEVER_INCLUDE_THIS_CODE g_list_foreach(complex.bumpcol_list, addBackgrounds, &container->extra_items) ; #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ - + #ifdef ED_G_NEVER_INCLUDE_THIS_CODE g_list_foreach(complex.bumpcol_list, addMultiBackgrounds, &container->extra_items) ; #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ @@ -732,7 +734,7 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ if (names_list) g_list_free(names_list) ; - + break ; } default: @@ -770,7 +772,7 @@ void zmapWindowColumnBumpAllInitial(FooCanvasItem *column_item) if((container_strand = zmapWindowContainerUtilsItemGetParentLevel(column_item, ZMAPCONTAINER_LEVEL_STRAND))) { /* container execute */ - zmapWindowContainerUtilsExecute(container_strand, + zmapWindowContainerUtilsExecute(container_strand, ZMAPCONTAINER_LEVEL_FEATURESET, invoke_bump_to_initial, NULL); /* happy days */ @@ -788,7 +790,7 @@ void zmapWindowColumnUnbumpAll(FooCanvasItem *column_item) if((container_strand = zmapWindowContainerUtilsItemGetParentLevel(column_item, ZMAPCONTAINER_LEVEL_STRAND))) { /* container execute */ - zmapWindowContainerUtilsExecute(container_strand, + zmapWindowContainerUtilsExecute(container_strand, ZMAPCONTAINER_LEVEL_FEATURESET, invoke_bump_to_unbump, NULL); /* happy days */ @@ -799,7 +801,7 @@ void zmapWindowColumnUnbumpAll(FooCanvasItem *column_item) } -/* +/* * Internal routines. */ #warning this_needs_to_go @@ -817,7 +819,7 @@ static void invoke_realize_and_map(FooCanvasItem *item) } else { - + if( FOO_CANVAS_ITEM_GET_CLASS(item)->realize) FOO_CANVAS_ITEM_GET_CLASS(item)->realize(item); @@ -902,14 +904,14 @@ static void bumpColCB(gpointer data, gpointer user_data) if (feature->x2 < bump_data->start || feature->x1 > bump_data->end) { container->hidden_bump_features = TRUE ; - + foo_canvas_item_hide(item) ; - + proceed = FALSE; } } - if (!(bump_data->bump_prop_data.bump_all) && + if (!(bump_data->bump_prop_data.bump_all) && !(bump_data->bump_prop_data.style_id == feature->style_id)) proceed = FALSE; } @@ -931,37 +933,37 @@ static void bumpColCB(gpointer data, gpointer user_data) case ZMAPBUMP_START_POSITION: { /* Bump features over if they have the same start coord. */ - + y1_ptr = GINT_TO_POINTER((int)y1) ; - + if (g_hash_table_lookup_extended(bump_data->pos_hash, y1_ptr, &key, &value)) { offset = *(double *)value + bump_data->incr ; - + *(double *)value = offset ; } else { value = g_new(double, 1) ; *(double *)value = offset ; - + g_hash_table_insert(bump_data->pos_hash, y1_ptr, value) ; } - + break ; } case ZMAPBUMP_OVERLAP: { /* Bump features over if they overlap at all. */ BumpColRange new_range ; - + new_range = g_new0(BumpColRangeStruct, 1) ; new_range->y1 = y1 ; new_range->y2 = y2 ; new_range->offset = 0.0 ; new_range->incr = bump_data->incr ; new_range->column = 0; - + // g_list_foreach(bump_data->pos_list, compareListOverlapCB, new_range) ; offset = bump_overlap(bump_data,new_range); break ; @@ -971,9 +973,9 @@ static void bumpColCB(gpointer data, gpointer user_data) /* Bump features that have the same name, i.e. are the same feature, so that each * vertical subcolumn is composed of just one feature in different positions. */ ZMapFeature feature ; - + feature = zmapWindowItemGetFeature(item); - + if (g_hash_table_lookup_extended(bump_data->pos_hash, GINT_TO_POINTER(feature->original_id), &key, &value)) { @@ -982,22 +984,22 @@ static void bumpColCB(gpointer data, gpointer user_data) else { offset = bump_data->offset ; - + value = g_new(double, 1) ; *(double *)value = offset ; - + g_hash_table_insert(bump_data->pos_hash, GINT_TO_POINTER(feature->original_id), value) ; - + bump_data->offset += bump_data->incr ; } - + break ; } case ZMAPBUMP_UNBUMP: { offset = bump_data->offset ; bump_data->offset += bump_data->incr ; - + break ; } case ZMAPBUMP_ALL: @@ -1041,7 +1043,7 @@ static void bumpColCB(gpointer data, gpointer user_data) zMapAssertNotReached() ; break ; } /* switch(bump_mode) */ - + } if(proceed) @@ -1053,15 +1055,15 @@ static void bumpColCB(gpointer data, gpointer user_data) * seems inefficient but its a toss up whether it would be quicker to test (dx == 0). */ dx = (zMapStyleGetWidth(style) - (x2 - x1 - 1)) / 2 ; offset += dx ; - } - + } + /* Not having something like this appears to be part of the cause of the oddness. Not all though */ if (offset < 0.0) offset = 0.0; - - /* This does a item_get_bounds... don't we already have them? + + /* This does a item_get_bounds... don't we already have them? * Might be missing something though. Why doesn't the "Bump" bit calculate offsets? */ - my_foo_canvas_item_goto(item, &(offset), NULL) ; + my_foo_canvas_item_goto(item, &(offset), NULL) ; } return ; @@ -1115,13 +1117,13 @@ static void listDataDestroyCB(gpointer data, gpointer user_data) -/* +/* * Functions for the complex bump... - * + * * If you alter this code you should note the careful use of GList**, list addresses * can change so its vital to return the address of the list pointer, not the list * pointer itself. - * + * */ static void make_or_append_in_hash(GHashTable *name_hash, GQuark name_quark, FooCanvasItem *item) { @@ -1171,13 +1173,13 @@ static gboolean can_bump_item(FooCanvasItem *item, ComplexBump complex, ZMapFeat feature = zmapWindowItemGetFeature(item); zMapAssert(feature) ; - + container = complex->bump_properties->container; style = zmapWindowStyleTableFind(container->style_table, feature->style_id) ; if ((!complex->bump_properties->bump_all) && (complex->bump_properties->style_id != feature->style_id)) bump_me = FALSE; - + /* Try doing this here.... */ if((zMapStyleGetMode(style) == ZMAPSTYLE_MODE_ALIGNMENT) && (feature->feature.homol.type == ZMAPHOMOL_X_HOMOL)) @@ -1236,7 +1238,7 @@ static void makeNameListStrandedCB(gpointer data, gpointer user_data) make_or_append_in_hash(name_hash, name_quark, item); g_string_truncate(complex->temp_buffer, 0); - + return ; } @@ -1443,10 +1445,10 @@ static void removeNonColinearExtensions(gpointer data, gpointer user_data) /* Find first and last item(s) that is within the marked range. */ result = findRangeListItems(list_item, mark_start, mark_end, &first_list_item, &last_list_item) ; - /* Logic Error! + /* Logic Error! * zmapWindowColumnBumpRange() doesn't always remove the names lists not within the range. * This means there will be names list not in range therefore not found by findRangeListItems()! - * calling zmapWindowColumnBump(item, ZMAPBUMP_NAME_COLINEAR) when marked is a sure way to + * calling zmapWindowColumnBump(item, ZMAPBUMP_NAME_COLINEAR) when marked is a sure way to * find this out! RDS. */ zMapAssert(result) ; @@ -1469,7 +1471,7 @@ static void removeNonColinearExtensions(gpointer data, gpointer user_data) if (!result) printf("found bad list\n") ; } - + name_list = removeNonColinear(last_list_item, ZMAP_GLIST_FORWARD, bump_data) ; { @@ -1574,12 +1576,12 @@ static void listScoreCB(gpointer data, gpointer user_data) /* Sanity checks... */ feature = zmapWindowItemGetFeature(item); zMapAssert(feature) ; - + /* Can only compare by score if features have a score... */ if (feature->flags.has_score) { score += feature->score ; - + *((double *)user_data) = score ; } } @@ -1627,7 +1629,7 @@ static gint sortByStrandSpanCB(gconstpointer a, gconstpointer b) feature = zmapWindowItemGetFeature(item); zMapAssert(feature) ; list_span_2 = feature->x1 - list_span_2 + 1 ; - + /* Strand first, then span. */ if (strand_1 < strand_2) @@ -1698,7 +1700,7 @@ static gint sortByOverlapCB(gconstpointer a, gconstpointer b, gpointer user_data bot_2 = feature->x2 ; #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ - + /* Strand first, then overlap. */ if (strand_1 < strand_2) @@ -1770,7 +1772,7 @@ static void bestFitCB(gpointer data, gpointer user_data) RangeData range = (RangeData)user_data ; ZMapFeature feature ; int diff ; - + feature = zmapWindowItemGetFeature(item); zMapAssert(feature) ; @@ -1918,7 +1920,7 @@ static void getMaxWidth(gpointer data, gpointer user_data) /* Compare two lists of features, return TRUE if any two features in the two lists overlap, * return FALSE otherwise. - * + * * NOTE that this function _completely_ relies on the two feature lists having been sorted * into ascending order on their coord positions, it will fail dismally if this is not true. * */ @@ -1988,7 +1990,7 @@ static gboolean listsOverlap(GList *curr_features, GList *new_features) /* Compare two lists of features, return TRUE if the two lists of features are interleaved * in position, return FALSE otherwise. - * + * * NOTE that this function _completely_ relies on the two feature lists having been sorted * into ascending order on their coord positions, it will fail dismally if this is not true. * */ @@ -2087,21 +2089,21 @@ static void moveItemsCB(gpointer data, gpointer user_data) { /* Firstly we need to move the parent_item to the same coords as * the first item in feature_list */ - + first_item = FOO_CANVAS_ITEM(col_data->feature_list->data); - + g_object_get(G_OBJECT(first_item), "x", &x, "y", &y, NULL); - + foo_canvas_item_set(FOO_CANVAS_ITEM(col_data->parent_item), "x", x, "y", y, NULL); - + g_list_foreach(col_data->feature_list, reparentItemCB, col_data); - + foo_canvas_item_set(FOO_CANVAS_ITEM(col_data->parent_item), "x", x + col_data->offset, NULL); @@ -2151,7 +2153,7 @@ static void moveItemCB(gpointer data, gpointer user_data) offset = col_data->offset + dx ; if(offset < 0.0) offset = 0.0; - my_foo_canvas_item_goto(item, &offset, NULL) ; + my_foo_canvas_item_goto(item, &offset, NULL) ; return ; @@ -2179,7 +2181,7 @@ static void setStyleBumpCB(ZMapFeatureTypeStyle style, gpointer user_data) #ifdef ED_G_NEVER_INCLUDE_THIS_CODE -/* +/* * debug functions, please leave here for future use. */ @@ -2291,7 +2293,7 @@ static gboolean findRangeListItems(GList *search_start, int seq_start, int seq_e if (feature->x1 <= seq_end) { - prev = list_item ; + prev = list_item ; } else if (feature->x1 > seq_end) { @@ -2379,8 +2381,8 @@ static GList *removeNonColinear(GList *first_list_item, ZMapGListDirection direc curr_feature = tmp ; } - colinearity = featureHomolIsColinear(bump_data->bump_prop_data.window, - bump_data->bump_prop_data.match_threshold, + colinearity = featureHomolIsColinear(bump_data->bump_prop_data.window, + bump_data->bump_prop_data.match_threshold, prev_feature, curr_feature) ; if (colinearity == COLINEAR_INVALID || colinearity == COLINEAR_NOT) @@ -2416,7 +2418,7 @@ static GList *removeNonColinear(GList *first_list_item, ZMapGListDirection direc GList *list_item ; FooCanvasItem *item ; ZMapFeature feature ; - + list_item = next_item ; result = getFeatureFromListItem(list_item, &item, &feature) ; @@ -2428,12 +2430,12 @@ static GList *removeNonColinear(GList *first_list_item, ZMapGListDirection direc foo_canvas_item_hide(curr_item) ; next_item = g_list_delete_link(curr_list_item, curr_list_item) ; next_item = prev_list_item ; - + { GList *list_item ; FooCanvasItem *item ; ZMapFeature feature ; - + list_item = next_item ; result = getFeatureFromListItem(list_item, &item, &feature) ; @@ -2452,21 +2454,21 @@ static GList *removeNonColinear(GList *first_list_item, ZMapGListDirection direc /* Function to check whether the homol blocks for two features are colinear. - * + * * Assumptions: - * + * * - features are in the same feature set. * - features are alignment features and have a match threshold * - features are on same strand * - features are in correct order, i.e. feat_1 is 5' of feat_2 * and they do not overlap in their _reference_ coords. - * + * * Returns COLINEAR_INVALID if the features overlap or feat_2 is 5' of feat_1, * otherwise returns COLINEAR_NOT if homols are not colinear, * COLINEAR_IMPERFECT if they are colinear but there is missing sequence in the match, * COLINEAR_PERFECT if they are colinear and there is no missing sequence within the * threshold given in the style. - * + * * */ static ColinearityType featureHomolIsColinear(ZMapWindow window, unsigned int match_threshold, ZMapFeature feat_1, ZMapFeature feat_2) @@ -2536,7 +2538,7 @@ static ColinearityType featureHomolIsColinear(ZMapWindow window, unsigned int m // (menu item commented out) -static void invoke_bump_to_initial(ZMapWindowContainerGroup container, FooCanvasPoints *points, +static void invoke_bump_to_initial(ZMapWindowContainerGroup container, FooCanvasPoints *points, ZMapContainerLevelType level, gpointer user_data) { @@ -2565,7 +2567,7 @@ static void invoke_bump_to_initial(ZMapWindowContainerGroup container, FooCanvas -static void invoke_bump_to_unbump(ZMapWindowContainerGroup container, FooCanvasPoints *points, +static void invoke_bump_to_unbump(ZMapWindowContainerGroup container, FooCanvasPoints *points, ZMapContainerLevelType level, gpointer user_data) { -- GitLab