diff --git a/src/zmapWindow/Makefile.am b/src/zmapWindow/Makefile.am index 8612a1c23d3094f05ff50503f25d3d6cf9191dae..c831d58a17d83d17a85e2c34e19a28276c693840 100755 --- a/src/zmapWindow/Makefile.am +++ b/src/zmapWindow/Makefile.am @@ -111,8 +111,9 @@ items/zmapWindowContainerUtils.h \ items/zmapWindowGlyphItem.c \ items/zmapWindowGlyphItem.h \ items/zmapWindowGlyphItem_I.h \ -items/zmapWindowLong_Items.c \ -items/zmapWindowLong_Items_P.h \ +items/zmapWindowLongItem.c \ +items/zmapWindowLongItem_I.h \ +items/zmapWindowLongItem.h \ items/zmapWindowSequenceFeature.c \ items/zmapWindowSequenceFeature.h \ items/zmapWindowSequenceFeature_I.h \ diff --git a/src/zmapWindow/zmapWindow.c b/src/zmapWindow/zmapWindow.c index 4883a93e16b7209779a5f333f62f34773cb3805b..0bed39632f4ec5537cee4ed18456fe127175fa37 100755 --- a/src/zmapWindow/zmapWindow.c +++ b/src/zmapWindow/zmapWindow.c @@ -26,9 +26,9 @@ * * Exported functions: See ZMap/zmapWindow.h * HISTORY: - * Last edited: Jun 15 15:20 2009 (rds) + * Last edited: Jul 9 15:57 2009 (rds) * Created: Thu Jul 24 14:36:27 2003 (edgrif) - * CVS info: $Id: zmapWindow.c,v 1.287 2009-06-19 11:15:56 rds Exp $ + * CVS info: $Id: zmapWindow.c,v 1.288 2009-07-27 03:15:09 rds Exp $ *------------------------------------------------------------------- */ @@ -1232,8 +1232,8 @@ void zmapWindowSetScrollRegion(ZMapWindow window, * */ void zMapWindowUpdateInfoPanel(ZMapWindow window, ZMapFeature feature_arg, - FooCanvasItem *item, - FooCanvasItem *highlight_item, + FooCanvasItem *sub_item, + FooCanvasItem *full_item, gboolean replace_highlight_item, gboolean highlight_same_names) { @@ -1243,9 +1243,12 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, ZMapWindowSelectStruct select = {0} ; ZMapFeatureSet set; FooCanvasGroup *feature_group; + ZMapFeatureSubPartSpan sub_feature; + ZMapStrand query_strand = ZMAPSTRAND_NONE; + char *feature_term, *sub_feature_term; int feature_start, feature_end, feature_length, query_start, query_end ; int sub_feature_start, sub_feature_end, sub_feature_length; - int selected_start, selected_end, selected_length ; + int query_length ; select.type = ZMAPWINDOW_SELECT_SINGLE; @@ -1257,22 +1260,24 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, return ; } - canvas_item = zMapWindowCanvasItemIntervalGetObject(item); + canvas_item = zMapWindowCanvasItemIntervalGetObject(sub_item); zMapAssert(ZMAP_IS_CANVAS_ITEM(canvas_item)); + sub_feature = zMapWindowCanvasItemIntervalGetData(sub_item); + feature = zMapWindowCanvasItemGetFeature(canvas_item); zMapAssert(feature_arg == feature); - top_canvas_item = zMapWindowCanvasItemIntervalGetTopLevelObject(item); + top_canvas_item = zMapWindowCanvasItemIntervalGetTopLevelObject(sub_item); - feature_group = zmapWindowItemGetParentContainer(FOO_CANVAS_ITEM(top_canvas_item)) ; + feature_group = zmapWindowItemGetParentContainer(FOO_CANVAS_ITEM(top_canvas_item)) ; - style = zmapWindowContainerFeatureSetStyleFromID((ZMapWindowContainerFeatureSet)feature_group, feature->style_id) ; + style = zmapWindowContainerFeatureSetStyleFromID((ZMapWindowContainerFeatureSet)feature_group, + feature->style_id) ; select.feature_desc.struct_type = feature->struct_type ; select.feature_desc.type = feature->type ; - select.feature_desc.feature_description = zmapWindowFeatureDescription(feature) ; zmapWindowFeatureGetSetTxt(feature, @@ -1283,39 +1288,83 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, &(select.feature_desc.feature_source), &(select.feature_desc.feature_source_description)) ; - if (possiblyPopulateWithChildData(window, item, highlight_item, - &sub_feature_start, &sub_feature_end, - &sub_feature_length, &(select.feature_desc.subpart_type), - &query_start, &query_end, - &selected_start, &selected_end, - &selected_length)) + /* zero all of this. */ + feature_start = feature_end = feature_length = query_start = query_end = + sub_feature_start = sub_feature_end = sub_feature_length = query_length = 0; + + feature_term = sub_feature_term = NULL; + + if(zMapFeatureGetInfo(feature, NULL, + "start", &feature_start, + "end", &feature_end, + "length", &feature_length, + "term", &feature_term, + NULL)) + { + select.feature_desc.feature_start = g_strdup_printf("%d", feature_start) ; + select.feature_desc.feature_end = g_strdup_printf("%d", feature_end) ; + select.feature_desc.feature_length = g_strdup_printf("%d", feature_length) ; + select.feature_desc.feature_strand = zMapFeatureStrand2Str(feature->strand) ; + select.feature_desc.feature_term = feature_term; + } + + if(zMapFeatureGetInfo(feature, NULL, + "query-start", &query_start, + "query-end", &query_end, + "query-length", &query_length, + "query-strand", &query_strand, + NULL)) { - select.feature_desc.sub_feature_start = g_strdup_printf("%d", sub_feature_start) ; - select.feature_desc.sub_feature_end = g_strdup_printf("%d", sub_feature_end) ; + select.feature_desc.feature_query_start = g_strdup_printf("%d", query_start) ; + select.feature_desc.feature_query_end = g_strdup_printf("%d", query_end) ; + select.feature_desc.feature_query_length = g_strdup_printf("%d", query_length) ; + select.feature_desc.feature_query_strand = zMapFeatureStrand2Str(query_strand) ; + } - if (feature->type == ZMAPSTYLE_MODE_ALIGNMENT) + if(sub_feature) /* If sub_feature == NULL we'll only get the same as previous! */ + { + feature_start = feature_end = feature_length = query_start = query_end = + sub_feature_start = sub_feature_end = sub_feature_length = query_length = 0; + + if(zMapFeatureGetInfo(feature, sub_feature, + "start", &sub_feature_start, + "end", &sub_feature_end, + "length", &sub_feature_length, + "term", &sub_feature_term, + NULL)) + { + select.feature_desc.sub_feature_start = g_strdup_printf("%d", sub_feature_start) ; + select.feature_desc.sub_feature_end = g_strdup_printf("%d", sub_feature_end) ; + select.feature_desc.sub_feature_length = g_strdup_printf("%d", sub_feature_length) ; + select.feature_desc.sub_feature_term = sub_feature_term ; + } + + if(zMapFeatureGetInfo(feature, sub_feature, + "query-start", &query_start, + "query-end", &query_end, + "query-length", &query_length, + NULL)) { select.feature_desc.sub_feature_query_start = g_strdup_printf("%d", query_start) ; select.feature_desc.sub_feature_query_end = g_strdup_printf("%d", query_end) ; } - - select.feature_desc.sub_feature_length = g_strdup_printf("%d", sub_feature_length) ; } else + select.feature_desc.sub_feature_term = "-"; + + if (feature->type == ZMAPSTYLE_MODE_ALIGNMENT) { - if (feature->type == ZMAPSTYLE_MODE_ALIGNMENT) - { - if (feature_arg->feature.homol.align) - select.feature_desc.sub_feature_none_txt = g_strdup("<GAPS NOT SHOWN>") ; - else - select.feature_desc.sub_feature_none_txt = g_strdup("<UNGAPPED ALIGNMENT>") ; - } - else if (feature->type == ZMAPSTYLE_MODE_TRANSCRIPT) - select.feature_desc.sub_feature_none_txt = g_strdup("<NO INTRONS>") ; + if (feature_arg->feature.homol.align) + select.feature_desc.sub_feature_none_txt = g_strdup("<GAPS NOT SHOWN>") ; + else + select.feature_desc.sub_feature_none_txt = g_strdup("<UNGAPPED ALIGNMENT>") ; } - - if (feature->locus_id) - select.feature_desc.feature_locus = (char *)g_quark_to_string(feature->locus_id) ; + else if (feature->type == ZMAPSTYLE_MODE_TRANSCRIPT) + select.feature_desc.sub_feature_none_txt = g_strdup("<NO INTRONS>") ; + + zMapFeatureGetInfo(feature, NULL, + "locus", &(select.feature_desc.feature_locus), + NULL); /* Need to replicate this ... */ /* Sequence:"Em:BC043419.2" 166314 167858 (1545) vertebrate_mRNA 96.9 (1 - 1547) Em:BC043419.2 */ @@ -1327,25 +1376,6 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, else if (feature->type == ZMAPSTYLE_MODE_TRANSCRIPT && feature->feature.transcript.known_name) select.feature_desc.feature_known_name = (char *)g_quark_to_string(feature->feature.transcript.known_name) ; - if (possiblyPopulateWithFullData(window, feature, item, highlight_item, - &feature_start, &feature_end, - &feature_length, - &selected_start, &selected_end, - &selected_length)) - { - select.feature_desc.feature_start = g_strdup_printf("%d", feature_start) ; - select.feature_desc.feature_end = g_strdup_printf("%d", feature_end) ; - select.feature_desc.feature_length = g_strdup_printf("%d", feature_length) ; - - if (feature->type == ZMAPSTYLE_MODE_ALIGNMENT) - { - select.feature_desc.feature_query_start = g_strdup_printf("%d", feature->feature.homol.y1) ; - select.feature_desc.feature_query_end = g_strdup_printf("%d", feature->feature.homol.y2) ; - select.feature_desc.feature_query_strand = zMapFeatureStrand2Str(feature->strand) ; - if (feature->feature.homol.length) - select.feature_desc.feature_query_length = g_strdup_printf("%d", feature->feature.homol.length) ; - } - } select.feature_desc.feature_strand = zMapFeatureStrand2Str(feature->strand) ; @@ -1360,12 +1390,10 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, if ((set = (ZMapFeatureSet)zMapFeatureGetParentGroup((ZMapFeatureAny)feature, ZMAPFEATURE_STRUCT_FEATURESET))) select.feature_desc.feature_set = (char *)g_quark_to_string(set->original_id) ; - select.feature_desc.feature_style = zMapStyleGetName(style) ; - - if (highlight_item) - select.highlight_item = highlight_item ; + if (full_item) + select.highlight_item = full_item ; else - select.highlight_item = item ; + select.highlight_item = sub_item ; select.replace_highlight_item = replace_highlight_item ; @@ -1377,7 +1405,7 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, /* We wait until here to do this so we are only setting the * clipboard text once. i.e. for this window. And so that we have * updated the focus object correctly. */ - select.secondary_text = makePrimarySelectionText(window, highlight_item); + select.secondary_text = makePrimarySelectionText(window, full_item); zMapGUISetClipboard(window->toplevel, select.secondary_text); @@ -1395,7 +1423,7 @@ void zMapWindowUpdateInfoPanel(ZMapWindow window, g_free(select.feature_desc.feature_length) ; g_free(select.feature_desc.feature_description) ; - g_free(select.secondary_text) ; + //g_free(select.secondary_text) ; return ; } @@ -4575,8 +4603,7 @@ static gboolean possiblyPopulateWithChildData(ZMapWindow window, int *selected_start, int *selected_end, int *selected_length) { - ZMapWindowItemFeature item_data; - ZMapWindowItemFeatureType type ; + ZMapFeatureSubPartSpan item_data; int fstart, fend, flength; int sstart, send, slength; gboolean populated = FALSE; @@ -4587,55 +4614,50 @@ static gboolean possiblyPopulateWithChildData(ZMapWindow window, selected_start && selected_end && selected_length && sub_feature_length && sub_type); - type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(feature_item), ITEM_FEATURE_TYPE)) ; - if (type == ITEM_FEATURE_CHILD) + if (window->display_forward_coords) { - item_data = g_object_get_data(G_OBJECT(feature_item), ITEM_SUBFEATURE_DATA) ; - zMapAssert(item_data) ; - - if (window->display_forward_coords) - { - fstart = zmapWindowCoordToDisplay(window, item_data->start) ; - fend = zmapWindowCoordToDisplay(window, item_data->end) ; - } - else - { - fstart = item_data->start ; - fend = item_data->end ; - } - - flength = (item_data->end - item_data->start + 1) ; - - /* ignore_this_restriction added as the makePrimarySelectionText was - * getting uninitialised values for selected_* when selecting multiple - * exons. I'm not sure the reason for the equality check so I've left - * it incase we want to parameterise ignore_this_restriction ;) */ - - /* If the canvas item's match... */ - if (feature_item == highlight_item || ignore_this_restriction) - { - sstart = fstart ; - send = fend ; - slength = flength ; - } - - if ((populated = TRUE)) - { - *sub_feature_start = fstart; - *sub_feature_end = fend; - *sub_feature_length = flength; - *query_start = item_data->query_start; - *query_end = item_data->query_end; - *selected_start = sstart; - *selected_end = send; - *selected_length = slength; - *sub_type = item_data->subpart; - } + fstart = zmapWindowCoordToDisplay(window, item_data->start) ; + fend = zmapWindowCoordToDisplay(window, item_data->end) ; + } + else + { + fstart = item_data->start ; + fend = item_data->end ; + } + + flength = (item_data->end - item_data->start + 1) ; + + /* ignore_this_restriction added as the makePrimarySelectionText was + * getting uninitialised values for selected_* when selecting multiple + * exons. I'm not sure the reason for the equality check so I've left + * it incase we want to parameterise ignore_this_restriction ;) */ + + /* If the canvas item's match... */ + if (feature_item == highlight_item || ignore_this_restriction) + { + sstart = fstart ; + send = fend ; + slength = flength ; + } + + if ((populated = TRUE)) + { + *sub_feature_start = fstart; + *sub_feature_end = fend; + *sub_feature_length = flength; +#ifdef FEATURE_FUNCTION_NEEDED_HERE + *query_start = item_data->query_start; + *query_end = item_data->query_end; +#endif /* FEATURE_FUNCTION_NEEDED_HERE */ + + *selected_start = sstart; + *selected_end = send; + *selected_length = slength; + *sub_type = item_data->subpart; } - return populated; } @@ -4648,9 +4670,9 @@ static gboolean possiblyPopulateWithFullData(ZMapWindow window, int *selected_start, int *selected_end, int *selected_length) { - ZMapWindowItemFeatureType type; gboolean populated = TRUE; - + int type; + zMapAssert(feature_start && feature_end && selected_start && selected_end && feature_length && selected_length); @@ -4686,7 +4708,7 @@ static gboolean possiblyPopulateWithFullData(ZMapWindow window, break ; } - if (type != ITEM_FEATURE_CHILD || feature_item != highlight_item) + if (type != 1 || feature_item != highlight_item) { if(window->display_forward_coords) { @@ -4723,7 +4745,7 @@ static char *makePrimarySelectionText(ZMapWindow window, item = FOO_CANVAS_ITEM(selected->data); item_feature = zmapWindowItemGetFeature(item); - +#ifdef RDS_DONT_INCLUDE /* Conditionally get the the full data if we don't get child data. * i.e. if the item is not a ITEM_FEATURE_CHILD */ if(!(possiblyPopulateWithChildData(window, item, highlight_item, @@ -4733,7 +4755,7 @@ static char *makePrimarySelectionText(ZMapWindow window, possiblyPopulateWithFullData(window, item_feature, item, highlight_item, &dummy, &dummy, &dummy, &selected_start, &selected_end, &selected_length); - +#endif g_string_append_printf(text, "\"%s\" %d %d (%d)%s", (char *)g_quark_to_string(item_feature->original_id), selected_start, selected_end, selected_length, diff --git a/src/zmapWindow/zmapWindowColBump.c b/src/zmapWindow/zmapWindowColBump.c index 094e371c2b8c9f753ba1e440bd58e2e667bfb4c5..70cf775aac3edb9979ae1c85d0996b88c0f46a26 100755 --- a/src/zmapWindow/zmapWindowColBump.c +++ b/src/zmapWindow/zmapWindowColBump.c @@ -27,9 +27,9 @@ * * Exported functions: See zmapWindow_P.h * HISTORY: - * Last edited: Jun 12 23:09 2009 (rds) + * Last edited: Jun 24 16:27 2009 (rds) * Created: Tue Sep 4 10:52:09 2007 (edgrif) - * CVS info: $Id: zmapWindowColBump.c,v 1.46 2009-06-19 11:15:47 rds Exp $ + * CVS info: $Id: zmapWindowColBump.c,v 1.47 2009-07-27 03:15:11 rds Exp $ *------------------------------------------------------------------- */ @@ -395,6 +395,8 @@ void zmapWindowColumnBumpRange(FooCanvasItem *bump_item, ZMapStyleBumpMode bump_ zmapWindowContainerShowAllHiddenFeatures(container); + zmapWindowContainerFeatureSetSortFeatures(container, 0); + bump_properties.container = container ; bump_properties.window = window = container->window; bump_properties.overlap_mode = bump_mode; @@ -2064,7 +2066,8 @@ static void moveItemCB(gpointer data, gpointer user_data) dx = (((width) * COMPLEX_BUMP_COMPRESS) - (x2 - x1)) / 2 ; offset = col_data->offset + dx ; - + if(offset < 0.0) + offset = 0.0; my_foo_canvas_item_goto(item, &offset, NULL) ; diff --git a/src/zmapWindow/zmapWindowDrawFeatures.c b/src/zmapWindow/zmapWindowDrawFeatures.c index 5e63fef5d4e83aaa76380219a3dbfcf08d15c27f..8bd56f9a240f22716676460e60299e11d8866f96 100755 --- a/src/zmapWindow/zmapWindowDrawFeatures.c +++ b/src/zmapWindow/zmapWindowDrawFeatures.c @@ -26,9 +26,9 @@ * * Exported functions: * HISTORY: - * Last edited: Jun 12 08:47 2009 (rds) + * Last edited: Jun 24 10:05 2009 (rds) * Created: Thu Jul 29 10:45:00 2004 (rnc) - * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.248 2009-06-19 11:16:02 rds Exp $ + * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.249 2009-07-27 03:15:11 rds Exp $ *------------------------------------------------------------------- */ @@ -1783,10 +1783,6 @@ static FooCanvasGroup *createColumnFull(ZMapWindowContainerFeatures parent_group /* This will create the stats if feature_set != NULL */ zmapWindowContainerAttachFeatureAny(container, (ZMapFeatureAny)feature_set); - /* Add an overlay manager */ - if((overlay_manager = zmapWindowOverlayCreate(FOO_CANVAS_ITEM(container), NULL))) - g_object_set_data(G_OBJECT(container), ITEM_FEATURE_OVERLAY_DATA, overlay_manager); - g_signal_connect(G_OBJECT(container), "destroy", G_CALLBACK(containerDestroyCB), (gpointer)window) ; g_signal_connect(G_OBJECT(container), "event", G_CALLBACK(columnBoundingBoxEventCB), (gpointer)window) ; @@ -2391,14 +2387,7 @@ static gboolean containerDestroyCB(FooCanvasItem *item, gpointer user_data) /* If the focus column goes then so should the focus items as they should be in step. */ if (zmapWindowFocusGetHotColumn(window->focus) == group) zmapWindowFocusReset(window->focus) ; - - /* get rid of the overlay manager */ - if((overlay_manager = g_object_get_data(G_OBJECT(group), ITEM_FEATURE_OVERLAY_DATA))) - { - /* making sure we clear any references to it as well. */ - zmapWindowFocusRemoveOverlayManager(window->focus, overlay_manager); - overlay_manager = zmapWindowOverlayDestroy(overlay_manager); - } + } break ; default: @@ -2406,9 +2395,13 @@ static gboolean containerDestroyCB(FooCanvasItem *item, gpointer user_data) zMapAssertNotReached() ; } } - +#ifdef RDS_REMOVED + /* It's not possible to check status as the parent containers + * get destroyed first, which call FToIRemove, leading to the + * removal of all the child hashes */ if(!status) - zMapLogCritical("containerDestroyCB (%p): remove failed", group); + zMapLogCritical("containerDestroyCB (%p): %s remove failed", group, G_OBJECT_TYPE_NAME(item)); +#endif /* RDS_REMOVED */ } else { diff --git a/src/zmapWindow/zmapWindowDump.c b/src/zmapWindow/zmapWindowDump.c index 278f1b9ea112ea612132ff103e53f64b03d079bc..0aef595a51b6c7726ebe83bb7b412810d70ea196 100755 --- a/src/zmapWindow/zmapWindowDump.c +++ b/src/zmapWindow/zmapWindowDump.c @@ -27,9 +27,9 @@ * * Exported functions: See ZMap/zmapWindow.h * HISTORY: - * Last edited: Jun 12 09:04 2009 (rds) + * Last edited: Jun 19 13:38 2009 (rds) * Created: Thu Mar 30 16:48:34 2006 (edgrif) - * CVS info: $Id: zmapWindowDump.c,v 1.8 2009-06-19 11:15:17 rds Exp $ + * CVS info: $Id: zmapWindowDump.c,v 1.9 2009-07-27 03:15:12 rds Exp $ *------------------------------------------------------------------- */ @@ -783,12 +783,12 @@ static void itemCB(gpointer data, gpointer user_data) static void dumpFeature(FooCanvasItem *item, gpointer user_data) { DumpOptions cb_data = (DumpOptions)user_data ; - ZMapWindowItemFeatureType type ; + int type ; if (zmapWindowItemIsShown(item) && ((type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), ITEM_FEATURE_TYPE))) - != ITEM_FEATURE_BOUNDING_BOX) - && (!(type == ITEM_FEATURE_GROUP_BACKGROUND && !FOO_IS_CANVAS_LINE(item)))) + != 7) + && (!(type == 2 && !FOO_IS_CANVAS_LINE(item)))) { guint composite ; int fill_colour = 0 ; /* default to white. */ diff --git a/src/zmapWindow/zmapWindowFeature.c b/src/zmapWindow/zmapWindowFeature.c index 1aee2f274e1d5b6031061ab5c9a92011a7690ad3..352ac7cac2ff13c55736cc989ea28554981e7e3d 100755 --- a/src/zmapWindow/zmapWindowFeature.c +++ b/src/zmapWindow/zmapWindowFeature.c @@ -28,9 +28,9 @@ * * Exported functions: See zmapWindow_P.h * HISTORY: - * Last edited: Jun 23 14:50 2009 (rds) + * Last edited: Jul 17 12:05 2009 (rds) * Created: Mon Jan 9 10:25:40 2006 (edgrif) - * CVS info: $Id: zmapWindowFeature.c,v 1.163 2009-06-23 15:42:00 rds Exp $ + * CVS info: $Id: zmapWindowFeature.c,v 1.164 2009-07-27 03:15:12 rds Exp $ *------------------------------------------------------------------- */ @@ -163,7 +163,6 @@ static gboolean factoryFeatureSizeReq(ZMapFeature feature, double *points_array_inout, gpointer handler_data); -static void cleanUpFeatureCB(gpointer data, gpointer user_data) ; @@ -746,28 +745,12 @@ static gboolean canvasItemDestroyCB(FooCanvasItem *feature_item, gpointer data) -static void cleanUpFeatureCB(gpointer data, gpointer user_data) -{ - FooCanvasItem *feature_item = FOO_CANVAS_ITEM(data) ; - ZMapWindow window = (ZMapWindow)user_data ; - ZMapWindowItemFeature item_data ; - - if((item_data = g_object_get_data(G_OBJECT(feature_item), ITEM_SUBFEATURE_DATA))) - g_free(item_data) ; - - /* Check to see if there is an entry in long items for this feature.... */ - zmapWindowLongItemRemove(window->long_items, feature_item) ; /* Ignore boolean result. */ - - zmapWindowFocusRemoveFocusItem(window->focus, feature_item); - - return ; -} static void featureCopySelectedItem(ZMapFeature feature_in, ZMapFeature feature_out, FooCanvasItem *selected) { - ZMapWindowItemFeature item_feature_data; + ZMapFeatureSubPartSpan item_feature_data; ZMapSpanStruct span = {0}; ZMapAlignBlockStruct alignBlock = {0}; @@ -820,6 +803,7 @@ static gboolean canvasItemEventCB(FooCanvasItem *item, GdkEvent *event, gpointer case GDK_2BUTTON_PRESS: { GdkEventButton *but_event = (GdkEventButton *)event ; + ZMapFeatureSubPartSpan sub_feature; ZMapWindowCanvasItem canvas_item; FooCanvasItem *sub_item = NULL ; FooCanvasItem *highlight_item = NULL ; @@ -835,7 +819,11 @@ static gboolean canvasItemEventCB(FooCanvasItem *item, GdkEvent *event, gpointer /* Get the feature attached to the item, checking that its type is valid */ feature = zMapWindowCanvasItemGetFeature(canvas_item); - sub_item = zMapWindowCanvasItemGetInterval(canvas_item, but_event->x, but_event->y); + sub_item = zMapWindowCanvasItemGetInterval(canvas_item, but_event->x, but_event->y, &sub_feature); + + if(!g_type_class_peek(ZMAP_TYPE_FEATURE_DATA)) + g_type_class_ref(ZMAP_TYPE_FEATURE_DATA); + if (but_event->type == GDK_BUTTON_PRESS) { @@ -1109,55 +1097,6 @@ void zmapMakeItemMenu(GdkEventButton *button_event, ZMapWindow window, FooCanvas } -#ifdef ED_G_NEVER_INCLUDE_THIS_CODE -static void makeTextItemMenu(GdkEventButton *button_event, ZMapWindow window, FooCanvasItem *item) -{ - static ZMapGUIMenuItemStruct separator[] = - { - {ZMAPGUI_MENU_SEPARATOR, NULL, 0, NULL, NULL}, - {ZMAPGUI_MENU_NONE, NULL, 0, NULL, NULL} - } ; - char *menu_title ; - GList *menu_sets = NULL ; - ItemMenuCBData menu_data ; - ZMapFeature feature ; - ZMapFeatureTypeStyle style ; - - - /* Some parts of the menu are feature type specific so retrieve the feature item info - * from the canvas item. */ - feature = zmapWindowItemGetFeature(item); - zMapAssert(feature) ; - - style = zmapWindowItemGetStyle(item) ; - zMapAssert(style) ; - - menu_title = zMapFeatureName((ZMapFeatureAny)feature) ; - - /* Call back stuff.... */ - menu_data = g_new0(ItemMenuCBDataStruct, 1) ; - menu_data->item_cb = TRUE ; - menu_data->window = window ; - menu_data->item = item ; - - /* Make up the menu. */ - - /* The select all, None, Copy... */ - menu_sets = g_list_append(menu_sets, makeMenuTextSelectOps(NULL, NULL, menu_data)) ; - - menu_sets = g_list_append(menu_sets, separator) ; - - - /* General */ - menu_sets = g_list_append(menu_sets, makeMenuGeneralOps(NULL, NULL, menu_data)) ; - - /* DNA Search ????????????????? */ - - zMapGUIMakeMenu(menu_title, menu_sets, button_event) ; - - return ; -} -#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ @@ -1987,7 +1926,7 @@ static gboolean factoryTopItemCreated(FooCanvasItem *top_item, break; } - if(ZMAP_IS_WINDOW_SEQUENCE_FEATURE(top_item)) + if(0 && ZMAP_IS_WINDOW_SEQUENCE_FEATURE(top_item)) g_signal_connect(G_OBJECT(top_item), "sequence-selected", G_CALLBACK(sequence_selection_cb), handler_data); diff --git a/src/zmapWindow/zmapWindowItem.c b/src/zmapWindow/zmapWindowItem.c index df8886bef08fe76110401c37169e27f13c76ffec..0ab43ca8cc700b897700a3c6277038662371da75 100755 --- a/src/zmapWindow/zmapWindowItem.c +++ b/src/zmapWindow/zmapWindowItem.c @@ -26,9 +26,9 @@ * * Exported functions: See zmapWindow_P.h * HISTORY: - * Last edited: Jun 15 11:27 2009 (rds) + * Last edited: Jul 16 08:41 2009 (rds) * Created: Thu Sep 8 10:37:24 2005 (edgrif) - * CVS info: $Id: zmapWindowItem.c,v 1.115 2009-06-19 11:14:59 rds Exp $ + * CVS info: $Id: zmapWindowItem.c,v 1.116 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -315,14 +315,12 @@ void zmapWindowHighlightObject(ZMapWindow window, FooCanvasItem *item, gboolean replace_highlight_item, gboolean highlight_same_names) { ZMapFeature feature ; - ZMapWindowItemFeatureType item_feature_type ; GList *set_items ; FooCanvasItem *dna_item, *framed_3ft; /* Retrieve the feature item info from the canvas item. */ feature = zmapWindowItemGetFeature(item); zMapAssert(feature) ; - item_feature_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), ITEM_FEATURE_TYPE)) ; /* If any other feature(s) is currently in focus, revert it to its std colours */ @@ -368,19 +366,7 @@ void zmapWindowHighlightObject(ZMapWindow window, FooCanvasItem *item, zmapWindowFocusClearOverlayManagers(window->focus); - if((dna_item = zmapWindowItemGetDNAItem(window, item))) - { - ZMapWindowOverlay overlay_manager; - FooCanvasGroup *container; - - container = (FooCanvasGroup *)zmapWindowContainerCanvasItemGetContainer(dna_item); - - if((overlay_manager = g_object_get_data(G_OBJECT(container), ITEM_FEATURE_OVERLAY_DATA))) - { - zmapWindowOverlaySetLimitItem(overlay_manager, NULL); - zmapWindowFocusAddOverlayManager(window->focus, overlay_manager); - } - } + zmapWindowItemHighlightDNARegion(window, item, feature->x1, feature->x2); { int frame_itr; @@ -388,20 +374,12 @@ void zmapWindowHighlightObject(ZMapWindow window, FooCanvasItem *item, { if((framed_3ft = zmapWindowItemGetTranslationItemFromItemFrame(window, item, frame_itr))) { - ZMapWindowOverlay overlay_manager; FooCanvasGroup *container; container = (FooCanvasGroup *)zmapWindowContainerCanvasItemGetContainer(framed_3ft); - if((overlay_manager = g_object_get_data(G_OBJECT(container), ITEM_FEATURE_OVERLAY_DATA))) - { - zmapWindowOverlaySetLimitItem(overlay_manager, framed_3ft); - - zmapWindowOverlaySetSubTypeMask(overlay_manager, ZMAPFEATURE_SUBPART_EXON_CDS | ZMAPFEATURE_SUBPART_EXON | ZMAPFEATURE_SUBPART_MATCH); - - zmapWindowFocusAddOverlayManager(window->focus, overlay_manager); - } } + } } @@ -468,25 +446,6 @@ void zmapUnHighlightColumn(ZMapWindow window, FooCanvasGroup *column) -gboolean zmapWindowItemIsCompound(FooCanvasItem *item) -{ - gboolean result = FALSE ; - - if (FOO_IS_CANVAS_GROUP(item)) - { - ZMapWindowItemFeatureType item_feature_type ; - - /* Retrieve the feature item info from the canvas item. */ - item_feature_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), ITEM_FEATURE_TYPE)) ; - zMapAssert(item_feature_type == ITEM_FEATURE_PARENT) ; - - result = TRUE ; - } - - return result ; -} - - /* Get "parent" item of feature, for simple features, this is just the item itself but * for compound features we need the parent group. * */ @@ -589,28 +548,44 @@ FooCanvasItem *zmapWindowItemGetDNAParentItem(ZMapWindow window, FooCanvasItem * FooCanvasItem *zmapWindowItemGetDNATextItem(ZMapWindow window, FooCanvasItem *item) { FooCanvasItem *dna_item = NULL; + ZMapFeature feature = NULL; + ZMapFeatureBlock block = NULL; + GQuark dna_set_id = 0; + + feature = zmapWindowItemGetFeature(item); - if ((dna_item = zmapWindowItemGetDNAParentItem(window, item)) - && FOO_IS_CANVAS_GROUP(dna_item) - && FOO_CANVAS_GROUP(dna_item)->item_list) + if(feature != NULL) + block = zMapFeatureGetParentGroup((ZMapFeatureAny)feature, ZMAPFEATURE_STRUCT_BLOCK); + + if(block != NULL) { - dna_item = FOO_CANVAS_ITEM(FOO_CANVAS_GROUP(dna_item)->item_list->data); - - if (!FOO_IS_CANVAS_ZMAP_TEXT(dna_item)) - dna_item = NULL; - else if (!(FOO_CANVAS_ITEM(dna_item)->object.flags & FOO_CANVAS_ITEM_VISIBLE)) - dna_item = NULL; + GQuark dna_id = 0; + char *feature_name = NULL; + + dna_set_id = zMapFeatureSetCreateID(ZMAP_FIXED_STYLE_DNA_NAME); + + dna_id = zMapFeatureDNAFeatureID(block); + + dna_item = zmapWindowFToIFindItemFull(window->context_to_item, + block->parent->unique_id, + block->unique_id, + dna_set_id, + ZMAPSTRAND_FORWARD, /* STILL ALWAYS FORWARD */ + ZMAPFRAME_NONE,/* NO STRAND */ + dna_id); + if(dna_item != NULL) + { + if(!(FOO_CANVAS_ITEM(dna_item)->object.flags & FOO_CANVAS_ITEM_VISIBLE)) + dna_item = NULL; + } + + if(feature_name) + g_free(feature_name); } return dna_item; } -FooCanvasItem *zmapWindowItemGetDNAItem(ZMapWindow window, FooCanvasItem *item) -{ - /* lazy! */ - return zmapWindowItemGetDNATextItem(window, item); -} - /* highlights the dna given any foocanvasitem (with a feature) and a start and end */ /* This _only_ highlights in the current window! */ void zmapWindowItemHighlightDNARegion(ZMapWindow window, @@ -618,33 +593,20 @@ void zmapWindowItemHighlightDNARegion(ZMapWindow window, int region_start, int region_end) { + ZMapWindowSequenceFeature sequence_feature; FooCanvasItem *dna_item = NULL; + ZMapFeature feature; - if((dna_item = zmapWindowItemGetDNAItem(window, item))) + if((dna_item = zmapWindowItemGetDNATextItem(window, item))) { - ZMapWindowOverlay overlay_manager; - FooCanvasGroup *container; - - container = (FooCanvasGroup *)zmapWindowContainerCanvasItemGetContainer(dna_item); - - /* Check the column is visible, otherwise failure is imminent. */ - if((FOO_CANVAS_ITEM(container)->object.flags & FOO_CANVAS_ITEM_VISIBLE) && - (overlay_manager = g_object_get_data(G_OBJECT(container), ITEM_FEATURE_OVERLAY_DATA))) - { - StartEndTextHighlightStruct data = {0}; + if(ZMAP_IS_WINDOW_SEQUENCE_FEATURE(dna_item) && item != dna_item) + { + feature = zmapWindowItemGetFeature(item); - data.start = region_start; - data.end = region_end; - data.item = dna_item; + sequence_feature = (ZMapWindowSequenceFeature)dna_item; - zmapWindowOverlayUnmaskAll(overlay_manager); - if(window->highlights_set.item) - zmapWindowOverlaySetGdkColorFromGdkColor(overlay_manager, &(window->colour_item_highlight)); - zmapWindowOverlaySetLimitItem(overlay_manager, NULL); - zmapWindowOverlaySetSubject(overlay_manager, item); - zmapWindowOverlayMaskFull(overlay_manager, simple_highlight_region, &data); - } - + zMapWindowSequenceFeatureSelectByRegion(sequence_feature, region_start, region_end, 0); + } } return ; @@ -699,11 +661,12 @@ void zmapWindowItemHighlightTranslationRegion(ZMapWindow window, FooCanvasItem * if((translation_item = zmapWindowItemGetTranslationItemFromItemFrame(window, item, required_frame))) { - ZMapWindowOverlay overlay_manager; FooCanvasGroup *container; container = (FooCanvasGroup *)zmapWindowContainerCanvasItemGetContainer(translation_item); - + + /* we just want to call sequenceSelect() */ +#ifdef RDS_REMOVED if((overlay_manager = g_object_get_data(G_OBJECT(container), ITEM_FEATURE_OVERLAY_DATA))) { StartEndTextHighlightStruct data = {0}; @@ -719,7 +682,7 @@ void zmapWindowItemHighlightTranslationRegion(ZMapWindow window, FooCanvasItem * zmapWindowOverlaySetSubject(overlay_manager, item); zmapWindowOverlayMaskFull(overlay_manager, simple_highlight_region, &data); } - +#endif /* RDS_REMOVED */ } return ; @@ -727,7 +690,7 @@ void zmapWindowItemHighlightTranslationRegion(ZMapWindow window, FooCanvasItem * ZMapFrame zmapWindowItemFeatureFrame(FooCanvasItem *item) { - ZMapWindowItemFeature item_subfeature_data ; + ZMapFeatureSubPartSpan item_subfeature_data ; ZMapFeature feature; ZMapFrame frame = ZMAPFRAME_NONE; @@ -914,27 +877,24 @@ FooCanvasItem *zmapWindowItemGetTranslationItemFromItem(ZMapWindow window, FooCa return translation; } - - -/* Returns a features style. We need this function because we only attach the style - * to the top item of the feature. It is a fatal error if a feature does not have a - * style so this function will always return a valid style or it will abort. - * - * */ -ZMapFeatureTypeStyle zmapWindowItemGetStyle(FooCanvasItem *feature_item) +#ifdef RDS_NEVER +ZMapFeatureTypeStyle zmapWindowItemGetStyle(ZMapWindow window, FooCanvasItem *item) { - ZMapFeatureTypeStyle style = NULL ; - FooCanvasItem *parent_item = NULL ; + ZMapWindowCanvasItem canvas_item = NULL; + ZMapFeatureTypeStyle style = NULL; + ZMapFeature feature = NULL; - parent_item = feature_item; - - style = g_object_get_data(G_OBJECT(parent_item), ITEM_FEATURE_ITEM_STYLE); + canvas_item = zMapWindowCanvasItemIntervalGetTopLevelObject(item); + + if((canvas_item != NULL) && + (feature = zMapWindowCanvasItemGetFeature(canvas_item))) + { + style = zMapFindStyle(window->display_styles, feature->style_id); + } return style; } - - - +#endif @@ -966,10 +926,10 @@ FooCanvasItem *zMapWindowFindFeatureItemByItem(ZMapWindow window, FooCanvasItem feature) ; if(FALSE) { - ZMapWindowItemFeature item_subfeature_data ; + ZMapFeatureSubPartSpan item_subfeature_data ; - item_subfeature_data = (ZMapWindowItemFeature)g_object_get_data(G_OBJECT(item), - ITEM_SUBFEATURE_DATA) ; + item_subfeature_data = (ZMapFeatureSubPartSpan)g_object_get_data(G_OBJECT(item), + ITEM_SUBFEATURE_DATA) ; matching_item = zmapWindowFToIFindItemChild(window->context_to_item, container->strand, container->frame, @@ -1325,43 +1285,6 @@ gboolean zMapWindowScrollToItem(ZMapWindow window, FooCanvasItem *item) } -void zmapWindowShowItem(FooCanvasItem *item) -{ - /* Looks like old code and we're changing the style stuff. Yes I'm being lazy... */ - g_return_if_fail(item == NULL); - -#ifdef OLD_CODE__ - ZMapFeature feature ; - ZMapWindowItemFeatureType item_feature_type ; - ZMapWindowItemFeature item_subfeature_data ; - - /* Retrieve the feature item info from the canvas item. */ - feature = zmapWindowItemGetFeature(item); - zMapAssert(feature) ; - - item_feature_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), - ITEM_FEATURE_TYPE)) ; - - item_subfeature_data = g_object_get_data(G_OBJECT(item), ITEM_SUBFEATURE_DATA) ; - - - printf("\nItem:\n" - "Name: %s, type: %s, style: %s, x1: %d, x2: %d, " - "item_x1: %d, item_x1: %d\n", - (char *)g_quark_to_string(feature->original_id), - - zMapStyleMode2ExactStr(zMapStyleGetMode(feature->style)), - - zMapStyleGetName(zMapFeatureGetStyle((ZMapFeatureAny)feature)), - feature->x1, - feature->x2, - item_subfeature_data->start, item_subfeature_data->end) ; - -#endif /* OLD_CODE__ */ - - return ; -} - /* Prints out an items coords in local coords, good for debugging.... */ void zmapWindowPrintLocalCoords(char *msg_prefix, FooCanvasItem *item) @@ -1463,106 +1386,6 @@ void zMapWindowMoveItem(ZMapWindow window, ZMapFeature origFeature, } -void zMapWindowMoveSubFeatures(ZMapWindow window, - ZMapFeature originalFeature, - ZMapFeature modifiedFeature, - GArray *origArray, GArray *modArray, - gboolean isExon) -{ - FooCanvasItem *item = NULL, *intron, *intron_box; - FooCanvasPoints *points ; - ZMapSpanStruct origSpan, modSpan; - ZMapWindowItemFeatureType itemFeatureType; - int i, offset; - double top, bottom, left, right, middle; - double x1, y1, x2, y2, transcriptOrigin, transcriptBottom; - ZMapWindowItemFeature box_data, intron_data ; - - - offset = ((ZMapFeatureBlock)(modifiedFeature->parent->parent))->block_to_sequence.q1; - transcriptOrigin = modifiedFeature->x1; - transcriptBottom = modifiedFeature->x2; - zmapWindowSeq2CanOffset(&transcriptOrigin, &transcriptBottom, offset); - - for (i = 0; i < modArray->len; i++) - { - /* get the FooCanvasItem using original feature */ - origSpan = g_array_index(origArray, ZMapSpanStruct, i); - - - /* needs changing....to accept frame/strand.... */ - -#warning "code needs changing for strand/frame" -#ifdef ED_G_NEVER_INCLUDE_THIS_CODE - - item = zmapWindowFToIFindItemChild(window->context_to_item, - originalFeature, origSpan.x1, origSpan.x2); -#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ - - - - - - /* coords are relative to start of transcript. */ - modSpan = g_array_index(modArray, ZMapSpanStruct, i); - top = (double)modSpan.x1 - transcriptOrigin; - bottom = (double)modSpan.x2 - transcriptOrigin; - - if (isExon) - { - foo_canvas_item_set(item, "y1", top, "y2", bottom, NULL); - - box_data = g_object_get_data(G_OBJECT(item), ITEM_SUBFEATURE_DATA); - box_data->start = top + transcriptOrigin; - box_data->end = bottom + transcriptOrigin; - } - else - { - itemFeatureType = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), ITEM_FEATURE_TYPE)); - - if (itemFeatureType == ITEM_FEATURE_BOUNDING_BOX) - { - intron_box = item; - foo_canvas_item_get_bounds(item, &x1, &y1, &x2, &y2); - box_data = g_object_get_data(G_OBJECT(intron_box), ITEM_SUBFEATURE_DATA); - intron = box_data->twin_item; - - box_data->start = top + transcriptOrigin; - box_data->end = bottom + transcriptOrigin; - } - else - { - intron = item; - intron_data = g_object_get_data(G_OBJECT(item), ITEM_SUBFEATURE_DATA); - intron_box = intron_data->twin_item; - foo_canvas_item_get_bounds(intron_box, &x1, &y1, &x2, &y2); - - intron_data->start = top + transcriptOrigin; - intron_data->end = bottom + transcriptOrigin; - } - - points = foo_canvas_points_new(ZMAP_WINDOW_INTRON_POINTS) ; - - left = (x2 - x1)/2; - right = x2; - middle = top + (bottom - top + 1)/2; - - points->coords[0] = left; - points->coords[1] = top; - points->coords[2] = right; - points->coords[3] = middle; - points->coords[4] = left; - points->coords[5] = bottom; - - foo_canvas_item_set(intron_box, "y1", top, "y2", bottom, NULL); - foo_canvas_item_set(intron, "points", points, NULL); - - foo_canvas_points_free(points); - } - } - return; -} - /* Returns the sequence coords that correspond to the given _world_ foocanvas coords. * * NOTE that although we only return y coords, we need the world x coords as input diff --git a/src/zmapWindow/zmapWindowItemFactory.c b/src/zmapWindow/zmapWindowItemFactory.c index 4e954b001a05347059fc1d8c9b2e1c111a066095..aa669f3c7e428d4b5a10e1d91ea2fb4c77f40b57 100755 --- a/src/zmapWindow/zmapWindowItemFactory.c +++ b/src/zmapWindow/zmapWindowItemFactory.c @@ -28,9 +28,9 @@ * * Exported functions: See zmapWindowItemFactory.h * HISTORY: - * Last edited: Jun 19 12:13 2009 (rds) + * Last edited: Jul 17 12:07 2009 (rds) * Created: Mon Sep 25 09:09:52 2006 (rds) - * CVS info: $Id: zmapWindowItemFactory.c,v 1.62 2009-06-19 11:14:12 rds Exp $ + * CVS info: $Id: zmapWindowItemFactory.c,v 1.63 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -64,9 +64,6 @@ typedef struct _ZMapWindowFToIFactoryStruct { guint line_width; /* window->config.feature_line_width */ ZMapWindowFToIFactoryMethodsStruct *methods; - ZMapWindowFToIFactoryMethodsStruct *basic_methods; - ZMapWindowFToIFactoryMethodsStruct *text_methods; - ZMapWindowFToIFactoryMethodsStruct *graph_methods; GHashTable *ftoi_hash; ZMapWindowLongItems long_items; ZMapWindowFToIFactoryProductionTeam user_funcs; @@ -95,14 +92,6 @@ static void copyCheckMethodTable(const ZMapWindowFToIFactoryMethodsStruct *tabl ZMapWindowFToIFactoryMethodsStruct **table_out) ; static void datalistRun(gpointer key, gpointer list_data, gpointer user_data); -inline -static void callItemHandler(ZMapWindowFToIFactory factory, - FooCanvasItem *new_item, - ZMapWindowItemFeatureType new_item_type, - ZMapFeature full_feature, - ZMapWindowItemFeature sub_feature, - double new_item_y1, - double new_item_y2); /* ZMapWindowFToIFactoryInternalMethod prototypes */ static FooCanvasItem *invalidFeature(RunSet run_data, ZMapFeature feature, @@ -113,6 +102,10 @@ static FooCanvasItem *drawSimpleFeature(RunSet run_data, ZMapFeature feature, double feature_offset, double x1, double y1, double x2, double y2, ZMapFeatureTypeStyle style); +static FooCanvasItem *drawAssemblyFeature(RunSet run_data, ZMapFeature feature, + double feature_offset, + double x1, double y1, double x2, double y2, + ZMapFeatureTypeStyle style); static FooCanvasItem *drawGlyphFeature(RunSet run_data, ZMapFeature feature, double feature_offset, double x1, double y1, double x2, double y2, @@ -156,13 +149,6 @@ static void GapAlignBlockFromAdjacentBlocks2(ZMapAlignBlock block_a, ZMapAlignBl gboolean *t_indel_gt_1, gboolean *q_indel_gt_1); -static void null_item_created(FooCanvasItem *new_item, - ZMapWindowItemFeatureType new_item_type, - ZMapFeature full_feature, - ZMapWindowItemFeature sub_feature, - double new_item_y1, - double new_item_y2, - gpointer handler_data); static gboolean null_top_item_created(FooCanvasItem *top_item, ZMapFeatureContext context, ZMapFeatureAlignment align, @@ -193,56 +179,13 @@ const static ZMapWindowFToIFactoryMethodsStruct factory_methods_G[] = { {ZMAPSTYLE_MODE_TRANSCRIPT, drawTranscriptFeature}, {ZMAPSTYLE_MODE_RAW_SEQUENCE, drawSeqFeature}, {ZMAPSTYLE_MODE_PEP_SEQUENCE, drawPepFeature}, - {ZMAPSTYLE_MODE_ASSEMBLY_PATH, drawSimpleFeature}, - {ZMAPSTYLE_MODE_TEXT, drawSimpleAsTextFeature}, - {ZMAPSTYLE_MODE_GRAPH, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_GLYPH, drawGlyphFeature}, - {-1, NULL} -}; - -const static ZMapWindowFToIFactoryMethodsStruct factory_text_methods_G[] = { - {ZMAPSTYLE_MODE_INVALID, invalidFeature}, - {ZMAPSTYLE_MODE_BASIC, drawSimpleAsTextFeature}, - {ZMAPSTYLE_MODE_ALIGNMENT, drawAlignFeature}, - {ZMAPSTYLE_MODE_TRANSCRIPT, drawTranscriptFeature}, - {ZMAPSTYLE_MODE_RAW_SEQUENCE, drawSeqFeature}, - {ZMAPSTYLE_MODE_PEP_SEQUENCE, drawPepFeature}, - {ZMAPSTYLE_MODE_ASSEMBLY_PATH, drawSimpleFeature}, - {ZMAPSTYLE_MODE_TEXT, drawSimpleAsTextFeature}, - {ZMAPSTYLE_MODE_GRAPH, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_GLYPH, drawGlyphFeature}, - {-1, NULL} -}; - -const static ZMapWindowFToIFactoryMethodsStruct factory_graph_methods_G[] = { - {ZMAPSTYLE_MODE_INVALID, invalidFeature}, - {ZMAPSTYLE_MODE_BASIC, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_ALIGNMENT, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_TRANSCRIPT, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_RAW_SEQUENCE, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_PEP_SEQUENCE, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_ASSEMBLY_PATH, drawSimpleFeature}, - {ZMAPSTYLE_MODE_TEXT, drawSimpleAsTextFeature}, - {ZMAPSTYLE_MODE_GRAPH, drawSimpleGraphFeature}, - {ZMAPSTYLE_MODE_GLYPH, drawGlyphFeature}, - {-1, NULL} -}; - -const static ZMapWindowFToIFactoryMethodsStruct factory_basic_methods_G[] = { - {ZMAPSTYLE_MODE_INVALID, invalidFeature}, - {ZMAPSTYLE_MODE_BASIC, drawSimpleFeature}, - {ZMAPSTYLE_MODE_ALIGNMENT, drawSimpleFeature}, - {ZMAPSTYLE_MODE_TRANSCRIPT, drawSimpleFeature}, - {ZMAPSTYLE_MODE_RAW_SEQUENCE, drawSimpleFeature}, - {ZMAPSTYLE_MODE_PEP_SEQUENCE, drawSimpleFeature}, - {ZMAPSTYLE_MODE_ASSEMBLY_PATH, drawSimpleFeature}, + {ZMAPSTYLE_MODE_ASSEMBLY_PATH, drawAssemblyFeature}, {ZMAPSTYLE_MODE_TEXT, drawSimpleAsTextFeature}, {ZMAPSTYLE_MODE_GRAPH, drawSimpleGraphFeature}, {ZMAPSTYLE_MODE_GLYPH, drawGlyphFeature}, {-1, NULL} }; - ZMapWindowFToIFactory zmapWindowFToIFactoryOpen(GHashTable *feature_to_item_hash, ZMapWindowLongItems long_items) { @@ -257,14 +200,7 @@ ZMapWindowFToIFactory zmapWindowFToIFactoryOpen(GHashTable *feature_to_item_hash copyCheckMethodTable(&(factory_methods_G[0]), &(factory->methods)); - copyCheckMethodTable(&(factory_basic_methods_G[0]), - &(factory->basic_methods)); - copyCheckMethodTable(&(factory_text_methods_G[0]), - &(factory->text_methods)); - copyCheckMethodTable(&(factory_graph_methods_G[0]), - &(factory->graph_methods)); - - user_funcs->item_created = null_item_created; + user_funcs->top_item_created = null_top_item_created; user_funcs->feature_size_request = null_feature_size_request; factory->user_funcs = user_funcs; @@ -280,9 +216,6 @@ void zmapWindowFToIFactorySetup(ZMapWindowFToIFactory factory, { zMapAssert(signal_handlers); - if(signal_handlers->item_created) - factory->user_funcs->item_created = signal_handlers->item_created; - if(signal_handlers->top_item_created) factory->user_funcs->top_item_created = signal_handlers->top_item_created; @@ -342,7 +275,6 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, zMapAssert(factory->user_funcs && - factory->user_funcs->item_created && factory->user_funcs->top_item_created); #ifdef RDS_REMOVED ZMapWindowItemFeatureSetData set_data = NULL; @@ -417,7 +349,7 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, stats->features++ ; stats->items++ ; #endif - method_table = factory->basic_methods; + method_table = factory->methods; if(feature->flags.has_score) zmapWindowGetPosFromScore(style, feature->score, &(points[0]), &(points[2])) ; @@ -485,7 +417,7 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, stats->features++ ; stats->items++ ; #endif - method_table = factory->text_methods; + method_table = factory->methods; method = &(method_table[style_mode]); @@ -500,7 +432,7 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, stats->features++ ; stats->items++ ; #endif - method_table = factory->graph_methods; + method_table = factory->methods; method = &(method_table[style_mode]); @@ -700,38 +632,6 @@ static void datalistRun(gpointer key, gpointer list_data, gpointer user_data) return ; } -inline -static void callItemHandler(ZMapWindowFToIFactory factory, - FooCanvasItem *new_item, - ZMapWindowItemFeatureType new_item_type, - ZMapFeature full_feature, - ZMapWindowItemFeature sub_feature, - double new_item_y1, - double new_item_y2) -{ - /* what was the non signal part of attachDataToItem. _ALL_ our canvas feature MUST have these */ -#ifdef RDS_DONT_INCLUDE - g_object_set_data(G_OBJECT(new_item), ITEM_FEATURE_TYPE, GINT_TO_POINTER(new_item_type)) ; - - g_object_set_data(G_OBJECT(new_item), ITEM_FEATURE_DATA, full_feature) ; -#endif - - if(sub_feature != NULL) - g_object_set_data(G_OBJECT(new_item), ITEM_SUBFEATURE_DATA, sub_feature); - else - zMapAssert(new_item_type != ITEM_FEATURE_CHILD && - new_item_type != ITEM_FEATURE_BOUNDING_BOX); - - if(factory->long_items && 0) - zmapWindowLongItemCheck(factory->long_items, new_item, new_item_y1, new_item_y2); - - (factory->user_funcs->item_created)(new_item, new_item_type, full_feature, sub_feature, - new_item_y1, new_item_y2, factory->user_data); - - return ; -} - - static double getWidthFromScore(ZMapFeatureTypeStyle style, double score) { @@ -793,8 +693,6 @@ static FooCanvasItem *drawSimpleFeature(RunSet run_data, ZMapFeature feature, if((new_canvas_item = zMapWindowCanvasItemCreate(parent, y1, feature, style))) { - zMapWindowCanvasItemSetIntervalType(new_canvas_item, ZMAP_WINDOW_BASIC_BOX); - zMapWindowCanvasItemAddInterval(new_canvas_item, NULL, 0.0, y2 - y1, x1, x2); feature_item = FOO_CANVAS_ITEM(new_canvas_item); @@ -803,6 +701,133 @@ static FooCanvasItem *drawSimpleFeature(RunSet run_data, ZMapFeature feature, return feature_item ; } +static FooCanvasItem *drawAssemblyFeature(RunSet run_data, ZMapFeature feature, + double feature_offset,/* item offset from block */ + double x1, double y1, double x2, double y2, + ZMapFeatureTypeStyle style) +{ + FooCanvasGroup *parent = run_data->container; + FooCanvasItem *feature_item = NULL; + ZMapWindowCanvasItem new_canvas_item; + double canvas_item_position; + gboolean debug_assembly_drawing = FALSE; + + canvas_item_position = y1 - feature_offset; + + if(debug_assembly_drawing) + { + printf("->drawAssemblyFeature(feature=%p, feature_offset=%f, x1=%f, y1=%f, x2=%f, y2=%f)\n", + feature, feature_offset, x1, y1, x2, y2); + printf("y1=%f, drawing@%f\n", y1, canvas_item_position); + } + + if((new_canvas_item = zMapWindowCanvasItemCreate(parent, canvas_item_position, feature, style))) + { + ZMapFeatureSubPartSpanStruct sub_feature = {}; + ZMapAssemblyPath assembly_path; + ZMapSpan golden_span; + double item_start, item_end; + + assembly_path = &(feature->feature.assembly_path); + + /* or should this be feature_offset += item_start [feature->x1 - feature_offset in seq2can()] */ + feature_offset += canvas_item_position; /* the "new" offset of the items */ + + if(debug_assembly_drawing) + g_object_set(G_OBJECT(new_canvas_item), "debug", debug_assembly_drawing, NULL); + + if(assembly_path->path) + { + int i = 0; + + golden_span = &(g_array_index(assembly_path->path, ZMapSpanStruct, i)); + + sub_feature.subpart = ZMAPFEATURE_SUBPART_MATCH; + sub_feature.start = item_start = golden_span->x1; + sub_feature.end = item_end = golden_span->x2; + + if(clip_feature_coords(run_data->factory, feature, feature_offset, + &item_start, &item_end)) + { + zMapWindowCanvasItemAddInterval(new_canvas_item, &sub_feature, + item_start, item_end, + x1, x2); + } + + if(feature->x1 != golden_span->x1) + { + sub_feature.subpart = ZMAPFEATURE_SUBPART_GAP; + sub_feature.start = item_start = feature->x1; + sub_feature.end = item_end = golden_span->x1 - 1; + + if(clip_feature_coords(run_data->factory, feature, feature_offset, + &item_start, &item_end)) + { + zMapWindowCanvasItemAddInterval(new_canvas_item, &sub_feature, + item_start, item_end, + x1, x2); + } + + } + + for(i = 1; i < assembly_path->path->len; i++) + { + int prev_start, prev_end; + + /* record the previous match to draw the gap later */ + prev_start = golden_span->x1; + prev_end = golden_span->x2; + /* get the current match */ + golden_span = &(g_array_index(assembly_path->path, ZMapSpanStruct, i)); + + sub_feature.subpart = ZMAPFEATURE_SUBPART_MATCH; + sub_feature.start = item_start = golden_span->x1; + sub_feature.end = item_end = golden_span->x2; + /* possibly draw the current match */ + if(clip_feature_coords(run_data->factory, feature, feature_offset, + &item_start, &item_end)) + { + zMapWindowCanvasItemAddInterval(new_canvas_item, &sub_feature, + item_start, item_end, + x1, x2); + } + + /* now for the gap */ + sub_feature.subpart = ZMAPFEATURE_SUBPART_GAP; + sub_feature.start = item_start = prev_end + 1; + sub_feature.end = item_end = golden_span->x1 - 1; + /* possibly draw.... */ + if(clip_feature_coords(run_data->factory, feature, feature_offset, + &item_start, &item_end)) + { + zMapWindowCanvasItemAddInterval(new_canvas_item, &sub_feature, + item_start, item_end, + x1, x2); + } + } + + if(feature->x2 != golden_span->x2) + { + sub_feature.subpart = ZMAPFEATURE_SUBPART_GAP; + sub_feature.start = item_start = golden_span->x2 + 1; + sub_feature.end = item_end = feature->x2; + + if(clip_feature_coords(run_data->factory, feature, feature_offset, + &item_start, &item_end)) + { + zMapWindowCanvasItemAddInterval(new_canvas_item, &sub_feature, + item_start, item_end, + x1, x2); + } + } + } + + feature_item = FOO_CANVAS_ITEM(new_canvas_item); + } + + return feature_item ; +} + static FooCanvasItem *drawGlyphFeature(RunSet run_data, ZMapFeature feature, double feature_offset, @@ -903,12 +928,7 @@ static FooCanvasItem *drawGlyphFeature(RunSet run_data, ZMapFeature feature, #endif if((new_canvas_item = zMapWindowCanvasItemCreate(parent, y1, feature, style))) { - int interval_type; - /* interval_type = style->interval_type; ... */ - interval_type = ZMAP_WINDOW_BASIC_BOX; - zMapWindowCanvasItemSetIntervalType(new_canvas_item, interval_type); - zMapWindowCanvasItemAddInterval(new_canvas_item, NULL, 0.0, y2 - y1, x1, x2); feature_item = FOO_CANVAS_ITEM(new_canvas_item); @@ -960,20 +980,11 @@ static FooCanvasItem *drawAlignFeature(RunSet run_data, ZMapFeature feature, ZMapWindowCanvasItem new_canvas_item; ZMapWindowFToIFactory factory = run_data->factory; ZMapFeatureBlock block = run_data->block; - GdkColor *outline = NULL, *foreground = NULL, *background = NULL ; guint match_threshold = 0, line_width = 0; - gboolean status ; - - /* Get the colours, it's an error at this stage if none set we don't draw. */ - /* We could speed performance by caching these colours and only changing them when the style - * quark changes. */ - status = zMapStyleGetColours(style, ZMAPSTYLE_COLOURTARGET_NORMAL, ZMAPSTYLE_COLOURTYPE_NORMAL, - &background, &foreground, &outline) ; - zMapAssert(status) ; /* If we are here, style should be ok for display. */ - - if (!zMapStyleIsAlignGaps(style) || !(feature->feature.homol.align)) + //zMapStyleSetGappedAligns(style, 1.0, 1.0); + if ((!zMapStyleIsAlignGaps(style) || !(feature->feature.homol.align))) { double feature_start, feature_end; feature_start = feature->x1; @@ -991,8 +1002,6 @@ static FooCanvasItem *drawAlignFeature(RunSet run_data, ZMapFeature feature, zMapWindowCanvasItemClear(new_canvas_item); } - zMapWindowCanvasItemSetIntervalType(new_canvas_item, ZMAP_WINDOW_ALIGNMENT_NO_GAPS); - zmapWindowExt2Zero(&feature_start, &feature_end); zMapWindowCanvasItemAddInterval(new_canvas_item, NULL, feature_start, feature_end, x1, x2); @@ -1077,7 +1086,7 @@ static FooCanvasItem *drawAlignFeature(RunSet run_data, ZMapFeature feature, /* Do any more we have... */ for (i = 1; prev_match_block && i < feature->feature.homol.align->len ; i++) { - ZMapWindowItemFeature gap_data, align_data ; + ZMapFeatureSubPartSpanStruct gap_data, align_data ; ZMapAlignBlockStruct gap_block, *match_block; FooCanvasItem *match; double item_top, item_bottom; @@ -1164,32 +1173,30 @@ static FooCanvasItem *drawAlignFeature(RunSet run_data, ZMapFeature feature, FooCanvasItem *gap; double gap_top, gap_bottom; - gap_data = g_new0(ZMapWindowItemFeatureStruct, 1) ; - gap_data->subpart = ZMAPFEATURE_SUBPART_GAP ; - gap_data->start = gap_block.t1; - gap_data->end = gap_block.t2; + gap_data.subpart = ZMAPFEATURE_SUBPART_GAP ; + gap_data.start = gap_block.t1; + gap_data.end = gap_block.t2; +#ifdef NO_NEED gap_data->query_start = 0; gap_data->query_end = 0; - if(q_indel_set) { gap_data->query_start = gap_block.q1; gap_data->query_end = gap_block.q2; } +#endif gap_top = gap_block.t1; gap_bottom = gap_block.t2; /* we don't need to clip check here, but item that do have feature_offset seq2can so add here. */ zmapWindowSeq2CanOffset(&gap_top, &gap_bottom, feature_start + feature_offset); - zMapWindowCanvasItemSetIntervalType(new_canvas_item, ZMAP_WINDOW_ALIGNMENT_GAP); #ifdef DEBUG_COORDS printf("\tgap %f, %f\n", gap_top, gap_bottom); #endif /* DEBUG_COORDS */ - gap = zMapWindowCanvasItemAddInterval(new_canvas_item, gap_data, + gap = zMapWindowCanvasItemAddInterval(new_canvas_item, &gap_data, gap_top, gap_bottom, x1, x2); - g_object_set_data(G_OBJECT(gap), ITEM_SUBFEATURE_DATA, gap_data); #ifdef RDS_BREAKING_STUFF if(q_indel - 1 > match_threshold) @@ -1198,20 +1205,18 @@ static FooCanvasItem *drawAlignFeature(RunSet run_data, ZMapFeature feature, } - align_data = g_new0(ZMapWindowItemFeatureStruct, 1) ; - align_data->subpart = ZMAPFEATURE_SUBPART_MATCH ; - align_data->start = match_block->t1 ; - align_data->end = match_block->t2 ; + align_data.subpart = ZMAPFEATURE_SUBPART_MATCH ; + align_data.start = match_block->t1 ; + align_data.end = match_block->t2 ; +#ifdef NO_NEED align_data->query_start = match_block->q1 ; align_data->query_end = match_block->q2 ; +#endif - zMapWindowCanvasItemSetIntervalType(new_canvas_item, ZMAP_WINDOW_ALIGNMENT_MATCH); #ifdef DEBUG_COORDS printf("\tmatch %f, %f\n", item_top, item_bottom); #endif /* DEBUG_COORDS */ - match = zMapWindowCanvasItemAddInterval(new_canvas_item, align_data, item_top, item_bottom, x1, x2); - - g_object_set_data(G_OBJECT(match), ITEM_SUBFEATURE_DATA, align_data); + match = zMapWindowCanvasItemAddInterval(new_canvas_item, &align_data, item_top, item_bottom, x1, x2); /* Save this block for next iteration... Incl. the * Seq2CanOffset of the Bottom of this drawn align box */ @@ -1223,18 +1228,17 @@ static FooCanvasItem *drawAlignFeature(RunSet run_data, ZMapFeature feature, if(first_match_block) { FooCanvasItem *match; - ZMapWindowItemFeature align_data; + ZMapFeatureSubPartSpanStruct align_data; - align_data = g_new0(ZMapWindowItemFeatureStruct, 1) ; - align_data->subpart = ZMAPFEATURE_SUBPART_MATCH ; - align_data->start = first_match_block->t1 ; - align_data->end = first_match_block->t2 ; + align_data.subpart = ZMAPFEATURE_SUBPART_MATCH ; + align_data.start = first_match_block->t1 ; + align_data.end = first_match_block->t2 ; +#ifdef NO_NEED align_data->query_start = first_match_block->q1 ; align_data->query_end = first_match_block->q2 ; - - match = zMapWindowCanvasItemAddInterval(new_canvas_item, align_data, +#endif + match = zMapWindowCanvasItemAddInterval(new_canvas_item, &align_data, first_item_top, first_item_bottom, x1, x2); - g_object_set_data(G_OBJECT(match), ITEM_SUBFEATURE_DATA, align_data); #ifdef DEBUG_COORDS printf("\t1st %f, %f\n", first_item_top, first_item_bottom); #endif /* DEBUG_COORDS */ @@ -1327,12 +1331,11 @@ static void new_draw_feature_exon(FooCanvasItem *feature_item, for(j = last; j >= first; --j) { FooCanvasItem *exon_item = NULL; - ZMapWindowItemFeature exon_data; + ZMapFeatureSubPartSpanStruct exon_data; - exon_data = g_new0(ZMapWindowItemFeatureStruct, 1); /* actual start will be canvas coord + feature_offset */ - exon_data->start = regions[j].x1 + feature_offset; - exon_data->end = regions[j].x2; + exon_data.start = regions[j].x1 + feature_offset; + exon_data.end = regions[j].x2; /* we have to translate these to the feature_item coord space */ regions[j].x2 -= top; regions[j].x1 -= top; @@ -1340,17 +1343,15 @@ static void new_draw_feature_exon(FooCanvasItem *feature_item, /* Do something about data here... */ if(j == cds_idx) { - exon_data->subpart = ZMAPFEATURE_SUBPART_EXON_CDS; - zMapWindowCanvasItemSetIntervalType(canvas_item, ZMAP_WINDOW_TRANSCRIPT_EXON_CDS); + exon_data.subpart = ZMAPFEATURE_SUBPART_EXON_CDS; } else { - exon_data->subpart = ZMAPFEATURE_SUBPART_EXON; - zMapWindowCanvasItemSetIntervalType(canvas_item, ZMAP_WINDOW_TRANSCRIPT_EXON); + exon_data.subpart = ZMAPFEATURE_SUBPART_EXON; } exon_item = zMapWindowCanvasItemAddInterval(canvas_item, - exon_data, + &exon_data, (double)(regions[j].x1), (double)(regions[j].x2), (double)0.0, @@ -1470,11 +1471,9 @@ static FooCanvasItem *drawTranscriptFeature(RunSet run_data, ZMapFeature featur parent_ypos = FOO_CANVAS_GROUP(feature_item)->ypos; - zMapWindowCanvasItemSetIntervalType(canvas_item, ZMAP_WINDOW_TRANSCRIPT_INTRON); - for (i = 0 ; i < feature->feature.transcript.introns->len ; i++) { - ZMapWindowItemFeature intron; + ZMapFeatureSubPartSpanStruct intron; FooCanvasItem *intron_line ; double item_top, item_bottom ; ZMapSpan intron_span ; @@ -1489,10 +1488,18 @@ static FooCanvasItem *drawTranscriptFeature(RunSet run_data, ZMapFeature featur continue; /* set up the item sub feature data */ - intron = g_new0(ZMapWindowItemFeatureStruct, 1); - intron->start = intron_span->x1; - intron->end = intron_span->x2; - intron->subpart = ZMAPFEATURE_SUBPART_INTRON; + intron.start = intron_span->x1; + intron.end = intron_span->x2; + + if(has_cds) + { + if(!((item_bottom < cds_start) || (item_top > cds_end))) + intron.subpart = ZMAPFEATURE_SUBPART_INTRON_CDS; + else + intron.subpart = ZMAPFEATURE_SUBPART_INTRON; + } + else + intron.subpart = ZMAPFEATURE_SUBPART_INTRON; /* this is a sub item we're drawing _within_ the feature_item, * so we need to zero in its space. new_draw_feature_exon does @@ -1501,7 +1508,7 @@ static FooCanvasItem *drawTranscriptFeature(RunSet run_data, ZMapFeature featur item_bottom -= parent_ypos; /* And draw the item. */ - intron_line = zMapWindowCanvasItemAddInterval(canvas_item, intron, + intron_line = zMapWindowCanvasItemAddInterval(canvas_item, &intron, item_top, item_bottom, item_left, item_right); } @@ -1717,7 +1724,7 @@ static gint canvas_allocate_dna_cb(FooCanvasItem *item, buffer_size = zMapWindowTextItemCalculateZoomBufferSize(item, draw_data, buffer_size); - return buffer_size; + return buffer_size + 1; } static gint canvas_fetch_feature_text_cb(FooCanvasItem *text_item, @@ -1823,194 +1830,6 @@ static gint canvas_fetch_feature_text_cb(FooCanvasItem *text_item, } -static gboolean item_to_char_cell_coords2(FooCanvasPoints **points_out, - FooCanvasItem *subject, - gpointer user_data) -{ - FooCanvasItem *overlay_item; - FooCanvasGroup *overlay_group, *container; - ZMapFeature subject_feature, overlay_feature; - FooCanvasPoints *points; - double first[ITEMTEXT_CHAR_BOUND_COUNT], last[ITEMTEXT_CHAR_BOUND_COUNT]; - int index1, index2; - gboolean first_found, last_found; - gboolean do_overlay = FALSE; - gboolean redraw = FALSE; - - if(FOO_IS_CANVAS_ITEM(user_data) && - FOO_IS_CANVAS_GROUP(user_data)) - { - overlay_group = FOO_CANVAS_GROUP(user_data); - overlay_item = FOO_CANVAS_ITEM(overlay_group->item_list->data); - - container = (FooCanvasGroup *)zmapWindowContainerCanvasItemGetContainer(overlay_item); - - do_overlay = (gboolean)(FOO_CANVAS_ITEM(container)->object.flags & FOO_CANVAS_ITEM_VISIBLE); - } - - if(do_overlay) - { - ZMapWindowItemFeatureType feature_type; - ZMapFrame subject_frame, overlay_frame; -#ifdef RDS_DONT_INCLUDE - subject_feature = g_object_get_data(G_OBJECT(subject), - ITEM_FEATURE_DATA); - overlay_feature = g_object_get_data(G_OBJECT(overlay_group), - ITEM_FEATURE_DATA); - feature_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(subject), - ITEM_FEATURE_TYPE)); -#endif - index1 = subject_feature->x1; - index2 = subject_feature->x2; - do_overlay = FALSE; - - if(feature_type == ITEM_FEATURE_CHILD) - { - ZMapWindowItemFeature sub_feature_data; - - sub_feature_data = g_object_get_data(G_OBJECT(subject), - ITEM_SUBFEATURE_DATA); - switch(sub_feature_data->subpart) - { - case ZMAPFEATURE_SUBPART_EXON: - case ZMAPFEATURE_SUBPART_EXON_CDS: - { - gboolean select_only_matching_frame = FALSE; - index1 = sub_feature_data->start; - index2 = sub_feature_data->end; - do_overlay = TRUE; - - if(overlay_feature->type == ZMAPSTYLE_MODE_PEP_SEQUENCE) - { - if(sub_feature_data->subpart == ZMAPFEATURE_SUBPART_EXON_CDS) - { - subject_frame = zMapFeatureTranscriptFrame(subject_feature); - subject_frame = zMapFeatureSubPartFrame(subject_feature, index1); - } - else - subject_frame = zMapFeatureFrame(subject_feature); - - overlay_frame = zMapFeatureFrame(overlay_feature); - - if(select_only_matching_frame && - subject_frame != overlay_frame) - do_overlay = FALSE; - else - { - int cds_index1, cds_index2; - int end_phase = 0, start_phase = 0; - - /* We can't highlight the phase codons accurately... */ - - /* I'm fairly sure what we need is zMapFeatureTranslationStartCoord(feature) */ - - /* These come back 1 based. */ - zMapFeatureWorld2CDS(subject_feature, index1, index2, - &cds_index1, &cds_index2); - /* Coord space: 1 2 3 | 4 5 6 | 7 8 9 | . . . */ - /* Exon coords: ^ ^ ^ ^ */ - /* Start phase: 1-1%3=0 - - 6-1%3=2 (dashes=missing bases) */ - - /* missing start bases, need to skip forward to get codon start */ - start_phase = (cds_index1 - 1) % 3; - /* missing end bases, need to skip backward to get full codon */ - end_phase = (cds_index2 % 3); -#ifdef RDS_DONT_INCLUDE - printf("indices are %d %d\n", index1, index2); - printf("phases are %d %d\n", start_phase, end_phase); -#endif - if(start_phase != 0) - index1 += 3 - start_phase; - if(end_phase != 0) - index2 -= end_phase; -#ifdef RDS_DONT_INCLUDE - printf("indices are %d %d\n", index1, index2); -#endif - } - } - } - break; - case ZMAPFEATURE_SUBPART_MATCH: - { - index1 = sub_feature_data->start; - index2 = sub_feature_data->end; - do_overlay = TRUE; - - if(overlay_feature->type == ZMAPSTYLE_MODE_PEP_SEQUENCE) - { - subject_frame = zMapFeatureFrame(subject_feature); - overlay_frame = zMapFeatureFrame(overlay_feature); - if(subject_frame != overlay_frame) - do_overlay = FALSE; - } - } - break; - default: - break; - } - } - else if(feature_type == ITEM_FEATURE_SIMPLE) - { - switch(subject_feature->type) - { - case ZMAPSTYLE_MODE_ALIGNMENT: - do_overlay = TRUE; - if(overlay_feature->type == ZMAPSTYLE_MODE_PEP_SEQUENCE) - { - subject_frame = zMapFeatureFrame(subject_feature); - overlay_frame = zMapFeatureFrame(overlay_feature); - if(subject_frame != overlay_frame) - do_overlay = FALSE; - } - break; - case ZMAPSTYLE_MODE_GRAPH: - case ZMAPSTYLE_MODE_TEXT: - case ZMAPSTYLE_MODE_BASIC: - do_overlay = TRUE; - break; - default: - break; - } - } - } - - if(do_overlay) - { - if(index1 > index2) - ZMAP_SWAP_TYPE(int, index1, index2); - - /* From the text indices, get the bounds of that char */ - first_found = zmapWindowItemTextIndex2Item(overlay_item, index1, &first[0]); - last_found = zmapWindowItemTextIndex2Item(overlay_item, index2, &last[0]); - - if(first_found && last_found) - { - double minx, maxx; - foo_canvas_item_get_bounds(overlay_item, &minx, NULL, &maxx, NULL); - - points = foo_canvas_points_new(8); - - zmapWindowItemTextOverlayFromCellBounds(points, - &first[0], - &last[0], - minx, maxx); - zmapWindowItemTextOverlayText2Overlay(overlay_item, points); - - /* set the points */ - if(points_out) - { - *points_out = points; - /* record such */ - redraw = TRUE; - } - else - foo_canvas_points_free(points); - } - } - - return redraw; -} - /* item_to_char_cell_coords: This is a ZMapWindowOverlaySizeRequestCB callback * The overlay code calls this function to request whether to draw an overlay * on a region and specifically where to draw it. returns TRUE to make the @@ -2103,13 +1922,12 @@ static FooCanvasItem *drawSimpleGraphFeature(RunSet run_data, ZMapFeature featur ZMapFeatureTypeStyle style) { ZMapWindowFToIFactory factory = run_data->factory ; - gboolean status ; FooCanvasGroup *parent = run_data->container ; FooCanvasItem *feature_item ; - GdkColor *outline = NULL, *foreground = NULL, *background = NULL ; guint line_width ; double numerator, denominator, dx ; double width, max_score, min_score ; + ZMapWindowCanvasItem canvas_item; width = zMapStyleGetWidth(style) ; min_score = zMapStyleGetMinScore(style) ; @@ -2119,10 +1937,6 @@ static FooCanvasItem *drawSimpleGraphFeature(RunSet run_data, ZMapFeature featur zmapWindowSeq2CanOffset(&y1, &y2, feature_offset) ; /* Make sure we cover the whole last base. */ - status = zMapStyleGetColours(style, ZMAPSTYLE_COLOURTARGET_NORMAL, ZMAPSTYLE_COLOURTYPE_NORMAL, - &background, &foreground, &outline) ; - zMapAssert(status) ; - numerator = feature->score - min_score ; denominator = max_score - min_score ; @@ -2155,16 +1969,12 @@ static FooCanvasItem *drawSimpleGraphFeature(RunSet run_data, ZMapFeature featur x2 = tmp ; } - { - ZMapWindowCanvasItem canvas_item; - - canvas_item = zMapWindowCanvasItemCreate(parent, y1, feature, style); - - zMapWindowCanvasItemAddInterval(canvas_item, NULL, 0.0, y2 - y1, x1, x2); - - feature_item = (FooCanvasItem *)canvas_item; - } + canvas_item = zMapWindowCanvasItemCreate(parent, y1, feature, style); + zMapWindowCanvasItemAddInterval(canvas_item, NULL, 0.0, y2 - y1, x1, x2); + + feature_item = (FooCanvasItem *)canvas_item; + return feature_item ; } @@ -2400,17 +2210,6 @@ static FooCanvasItem *invalidFeature(RunSet run_data, ZMapFeature feature, return NULL; } -static void null_item_created(FooCanvasItem *new_item, - ZMapWindowItemFeatureType new_item_type, - ZMapFeature full_feature, - ZMapWindowItemFeature sub_feature, - double new_item_y1, - double new_item_y2, - gpointer handler_data) -{ - return ; -} - static gboolean null_top_item_created(FooCanvasItem *top_item, ZMapFeatureContext context, ZMapFeatureAlignment align, diff --git a/src/zmapWindow/zmapWindowItemFactory.h b/src/zmapWindow/zmapWindowItemFactory.h index bf8fc78107e35307fd22a853899264ad891648d0..d3d02e1f46e63326631d0465e14bf1fc5531a5f2 100755 --- a/src/zmapWindow/zmapWindowItemFactory.h +++ b/src/zmapWindow/zmapWindowItemFactory.h @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Dec 10 10:43 2008 (rds) + * Last edited: Jun 19 13:37 2009 (rds) * Created: Mon Sep 25 09:09:52 2006 (rds) - * CVS info: $Id: zmapWindowItemFactory.h,v 1.7 2009-06-05 13:35:05 rds Exp $ + * CVS info: $Id: zmapWindowItemFactory.h,v 1.8 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -41,13 +41,6 @@ -typedef void (*ZMapWindowFToIFactoryItemCreated)(FooCanvasItem *new_item, - ZMapWindowItemFeatureType new_item_type, - ZMapFeature full_feature, - ZMapWindowItemFeature sub_feature, - double new_item_y1, - double new_item_y2, - gpointer handler_data); typedef gboolean (*ZMapWindowFToIFactoryTopItemCreated)(FooCanvasItem *top_item, ZMapFeatureContext context, @@ -64,7 +57,6 @@ typedef gboolean (*ZMapWindowFToIFactoryItemFeatureSizeRequest)(ZMapFeature feat typedef struct { - ZMapWindowFToIFactoryItemCreated item_created; ZMapWindowFToIFactoryTopItemCreated top_item_created; ZMapWindowFToIFactoryItemFeatureSizeRequest feature_size_request; }ZMapWindowFToIFactoryProductionTeamStruct, *ZMapWindowFToIFactoryProductionTeam; diff --git a/src/zmapWindow/zmapWindowItemHash.c b/src/zmapWindow/zmapWindowItemHash.c index 6938a366b48e2220c72b7ac80c89f4bae7efdce3..260aac9b3874e861c41676e7d410b99eba647876 100755 --- a/src/zmapWindow/zmapWindowItemHash.c +++ b/src/zmapWindow/zmapWindowItemHash.c @@ -29,9 +29,9 @@ * * Exported functions: See zMapWindow_P.h * HISTORY: - * Last edited: Jun 12 09:21 2009 (rds) + * Last edited: Jul 3 15:19 2009 (rds) * Created: Mon Jun 13 10:06:49 2005 (edgrif) - * CVS info: $Id: zmapWindowItemHash.c,v 1.44 2009-06-19 11:16:09 rds Exp $ + * CVS info: $Id: zmapWindowItemHash.c,v 1.45 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -39,6 +39,7 @@ #include <ZMap/zmapUtils.h> #include <ZMap/zmapFeature.h> #include <zmapWindow_P.h> +#include <zmapWindowCanvasItem.h> /* zMapWindowCanvasItemIntevalGetData() */ #define zmapWindowFToIFindAlignById(FTOI_HASH, ID) \ @@ -1160,24 +1161,20 @@ static void childSearchCB(gpointer data, gpointer user_data) { FooCanvasItem *item = (FooCanvasItem *)data ; ChildSearch child_search = (ChildSearch)user_data ; - ZMapWindowItemFeatureType item_feature_type ; /* We take the first match we find so this function does nothing if we have already * found matching child item. */ if (!(child_search->child_item)) { - item_feature_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), - ITEM_FEATURE_TYPE)) ; - if (item_feature_type == ITEM_FEATURE_CHILD) + ZMapFeatureSubPartSpan item_subfeature_data ; + + if((item_subfeature_data = zMapWindowCanvasItemIntervalGetData(item))) { - ZMapWindowItemFeature item_subfeature_data ; - - item_subfeature_data = (ZMapWindowItemFeature)g_object_get_data(G_OBJECT(item), - ITEM_SUBFEATURE_DATA) ; - - if (item_subfeature_data->start == child_search->child_start - && item_subfeature_data->end == child_search->child_end) - child_search->child_item = item ; + if (item_subfeature_data->start == child_search->child_start && + item_subfeature_data->end == child_search->child_end) + { + child_search->child_item = item ; + } } } diff --git a/src/zmapWindow/zmapWindowItemText.c b/src/zmapWindow/zmapWindowItemText.c index c3d9bb7f38ccb7e06aa46beacbf2d2ec6218764c..1c142630bd6035388c38ecfba0cb244402afdc6f 100755 --- a/src/zmapWindow/zmapWindowItemText.c +++ b/src/zmapWindow/zmapWindowItemText.c @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 12 09:24 2009 (rds) + * Last edited: Jun 25 08:56 2009 (rds) * Created: Mon Apr 2 09:35:42 2007 (rds) - * CVS info: $Id: zmapWindowItemText.c,v 1.21 2009-06-19 11:16:17 rds Exp $ + * CVS info: $Id: zmapWindowItemText.c,v 1.22 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -1271,31 +1271,20 @@ static FooCanvasItem *draw_show_translation(FooCanvasGroup *container_features, &text_width, &text_height); } - - if((item = foo_canvas_item_new(FOO_CANVAS_GROUP(feature_parent), - foo_canvas_zmap_text_get_type(), - "x", 0.0, - "y", 0.0, - "anchor", GTK_ANCHOR_NW, - "font_desc", font_desc, - "full-width", 30.0 + SHOW_TRANSLATION_COUNTER_LENGTH, - "wrap-mode", PANGO_WRAP_CHAR, - "fill_color_gdk", foreground, - "allocate_func", canvas_allocate_show_translation_cb, - "fetch_text_func", canvas_fetch_show_transaltion_text_cb, - "callback_data", feature, - NULL))) - { - ZMapWindowItemFeature sub_feature = NULL; -#ifdef RDS_DONT_INCLUDE - g_object_set_data(G_OBJECT(item), ITEM_FEATURE_TYPE, - GINT_TO_POINTER(ITEM_FEATURE_CHILD)) ; - g_object_set_data(G_OBJECT(item), ITEM_FEATURE_DATA, - feature) ; -#endif - if(sub_feature != NULL) - g_object_set_data(G_OBJECT(item), ITEM_SUBFEATURE_DATA, sub_feature); - } +#warning should use zmapwindowcanvasitem code + item = foo_canvas_item_new(FOO_CANVAS_GROUP(feature_parent), + foo_canvas_zmap_text_get_type(), + "x", 0.0, + "y", 0.0, + "anchor", GTK_ANCHOR_NW, + "font_desc", font_desc, + "full-width", 30.0 + SHOW_TRANSLATION_COUNTER_LENGTH, + "wrap-mode", PANGO_WRAP_CHAR, + "fill_color_gdk", foreground, + "allocate_func", canvas_allocate_show_translation_cb, + "fetch_text_func", canvas_fetch_show_transaltion_text_cb, + "callback_data", feature, + NULL); return item; } diff --git a/src/zmapWindow/zmapWindowMenus.c b/src/zmapWindow/zmapWindowMenus.c index d0be8b6416009d24744358568931562c22f4aac0..ffe1761761f1411acf74c817c207a38d1acca79f 100755 --- a/src/zmapWindow/zmapWindowMenus.c +++ b/src/zmapWindow/zmapWindowMenus.c @@ -27,9 +27,9 @@ * Exported functions: ZMap/zmapWindows.h * * HISTORY: - * Last edited: Jun 12 09:46 2009 (rds) + * Last edited: Jul 3 16:54 2009 (rds) * Created: Thu Mar 10 07:56:27 2005 (edgrif) - * CVS info: $Id: zmapWindowMenus.c,v 1.61 2009-06-19 11:16:43 rds Exp $ + * CVS info: $Id: zmapWindowMenus.c,v 1.62 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -1062,16 +1062,29 @@ static void blixemMenuCB(int menu_item_id, gpointer callback_data) { ItemMenuCBData menu_data = (ItemMenuCBData)callback_data ; ZMapWindowCallbackCommandAlignStruct align ; + ZMapFeatureAny feature_any; ZMapFeature feature ; ZMapWindowCallbacks window_cbs_G = zmapWindowGetCBs() ; - feature = zmapWindowItemGetFeature(menu_data->item); - zMapAssert(feature) ; /* something badly wrong if no feature. */ - if(feature->struct_type == ZMAPFEATURE_STRUCT_FEATURESET) + feature_any = zmapWindowItemGetFeatureAny(menu_data->item); + zMapAssert(feature_any) ; /* something badly wrong if no feature. */ + + switch(feature_any->struct_type) { - /* need to fix implicit dec here! */ - feature = zMap_g_hash_table_nth(((ZMapFeatureSet)feature)->features, 0); + case ZMAPFEATURE_STRUCT_FEATURESET: + { + ZMapFeatureSet feature_set; + feature_set = (ZMapFeatureSet)feature_any; + /* need to fix implicit dec here! */ + feature = zMap_g_hash_table_nth(feature_set->features, 0); + } + break; + case ZMAPFEATURE_STRUCT_FEATURE: + feature = (ZMapFeature)feature_any; + break; + default: + break; } align.cmd = ZMAPWINDOW_CMD_SHOWALIGN ; diff --git a/src/zmapWindow/zmapWindowOverlays.c b/src/zmapWindow/zmapWindowOverlays.c index f92f7465846d477cd649b4514e14e1b6f4542eb6..a6e9d47d2f9de0128740e97dd80e9f456f0dd728 100755 --- a/src/zmapWindow/zmapWindowOverlays.c +++ b/src/zmapWindow/zmapWindowOverlays.c @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 4 21:23 2009 (rds) + * Last edited: Jun 19 13:47 2009 (rds) * Created: Mon Mar 12 12:28:18 2007 (rds) - * CVS info: $Id: zmapWindowOverlays.c,v 1.11 2009-06-05 13:36:36 rds Exp $ + * CVS info: $Id: zmapWindowOverlays.c,v 1.12 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ #include <zmapWindowContainerUtils.h> #include <ZMap/zmapUtils.h> -#define OVERLAY_DEFAULT_ITEM_TYPE_MASK (ITEM_FEATURE_SIMPLE | ITEM_FEATURE_CHILD) +#define OVERLAY_DEFAULT_ITEM_TYPE_MASK (1 | 2)//(ITEM_FEATURE_SIMPLE | ITEM_FEATURE_CHILD) #define OVERLAY_DEFAULT_SUB_TYPE_MASK (ZMAPFEATURE_SUBPART_EXON_CDS | ZMAPFEATURE_SUBPART_EXON | ZMAPFEATURE_SUBPART_MATCH) diff --git a/src/zmapWindow/zmapWindow_P.h b/src/zmapWindow/zmapWindow_P.h index be977c58f77a8fb89eea1d4e43e7dca9af2aebf5..6a4937d44703541ee9403f26f82a737645668b8d 100755 --- a/src/zmapWindow/zmapWindow_P.h +++ b/src/zmapWindow/zmapWindow_P.h @@ -25,9 +25,9 @@ * Description: Defines internal interfaces/data structures of zMapWindow. * * HISTORY: - * Last edited: Jun 12 13:50 2009 (rds) + * Last edited: Jul 15 08:13 2009 (rds) * Created: Fri Aug 1 16:45:58 2003 (edgrif) - * CVS info: $Id: zmapWindow_P.h,v 1.245 2009-06-12 12:51:02 rds Exp $ + * CVS info: $Id: zmapWindow_P.h,v 1.246 2009-07-27 03:15:13 rds Exp $ *------------------------------------------------------------------- */ #ifndef ZMAP_WINDOW_P_H @@ -192,29 +192,7 @@ typedef struct #define ITEM_FEATURE_ITEM_STYLE ZMAP_WINDOW_P_H "item_feature_item_style" #define ITEM_FEATURE_TYPE ZMAP_WINDOW_P_H "item_feature_type" -#define ITEM_SUBFEATURE_DATA ZMAP_WINDOW_P_H "item_subfeature_data" -#define ITEM_FEATURE_TEXT_DATA ZMAP_WINDOW_P_H "item_feature_text_data" - -#define ITEM_FEATURE_OVERLAY_DATA ZMAP_WINDOW_P_H "item_feature_overlay_data" - -typedef enum - { - ITEM_FEATURE_INVALID = 0, - - /* Item is a group of features. */ - ITEM_FEATURE_GROUP = 1 << 0, /* Parent group for features. */ - ITEM_FEATURE_GROUP_BACKGROUND = 1 << 1, /* background for group. */ - - /* Item is the whole feature. */ - ITEM_FEATURE_SIMPLE = 1 << 2, - - /* Item is a compound feature composed of subparts, e.g. exons, introns etc. */ - ITEM_FEATURE_PARENT = 1 << 3, /* Item is parent group of compound feature. */ - ITEM_FEATURE_CHILD = 1 << 4, /* Item is child/subpart of feature. */ - ITEM_FEATURE_BOUNDING_BOX = 1 << 5 /* Item is invisible bounding box of - feature or subpart of feature. */ - } ZMapWindowItemFeatureType ; @@ -432,31 +410,6 @@ typedef struct -/* Probably will need to expand this to be a union as we come across more features that need - * different information recording about them. - * The intent of this structure is to hold information for items that are subparts of features, - * e.g. exons, where it is tedious/error prone to recover the information from the feature and - * canvas item. */ -typedef struct -{ - - /* I'm not completely sure this is a good idea but somehow we do need to be able to find out - * whether something is in intron/exon or whatever.... */ - ZMapFeatureSubpartType subpart ; /* Exon, Intron etc. */ - - int start, end ; /* start/end of subpart in sequence coords. */ - - int query_start, query_end ; /* For alignments. */ - - FooCanvasItem *twin_item ; /* Some features need to be drawn with - two canvas items, an example is - introns which need an invisible - bounding box for sensible user - interaction. */ - -} ZMapWindowItemFeatureStruct, *ZMapWindowItemFeature ; - - typedef void (*ZMapWindowRulerCanvasCallback)(gpointer data, gpointer user_data); @@ -751,15 +704,6 @@ typedef GHashTable * (*ZMapWindowListGetFToIHash)(gpointer user_data); typedef GList * (*ZMapWindowListSearchHashFunc)(GHashTable *hash_table, gpointer user_data); -/* Handler to set stuff after an item has been drawn. */ -typedef void (*ZMapWindowFeaturePostItemDrawHandler)(FooCanvasItem *new_item, - ZMapWindowItemFeatureType new_item_type, - ZMapFeature full_feature, - ZMapWindowItemFeature sub_feature, - double new_item_y1, - double new_item_y2, - gpointer handler_data); - ZMapWindowCallbacks zmapWindowGetCBs() ; @@ -941,7 +885,7 @@ FooCanvasGroup *zmapWindowItemGetParentContainer(FooCanvasItem *feature_item) ; gboolean zmapWindowItemIsGetSize(FooCanvasItem *item) ; #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ -FooCanvasItem *zmapWindowItemGetDNAItem(ZMapWindow window, FooCanvasItem *item); +FooCanvasItem *zmapWindowItemGetDNATextItem(ZMapWindow window, FooCanvasItem *item); void zmapWindowItemHighlightDNARegion(ZMapWindow window, FooCanvasItem *any_item, int region_start, int region_end); FooCanvasGroup *zmapWindowItemGetTranslationColumnFromBlock(ZMapWindow window, ZMapFeatureBlock block); FooCanvasItem *zmapWindowItemGetTranslationItemFromItem(ZMapWindow window, FooCanvasItem *item); @@ -1157,11 +1101,6 @@ ZMapFrame zmapWindowFeatureFrame(ZMapFeature feature) ; FooCanvasItem *zmapWindowFeatureDraw(ZMapWindow window, ZMapFeatureTypeStyle style, FooCanvasGroup *set_group, ZMapFeature feature) ; -FooCanvasItem *zmapWindowFeatureDrawScaled(ZMapWindow window, - FooCanvasGroup *set_group, - ZMapFeature feature, - double scale_factor, - ZMapWindowFeaturePostItemDrawHandler handler); char *zmapWindowFeatureSetDescription(ZMapFeatureSet feature_set) ; char *zmapWindowFeatureSourceDescription(ZMapFeature feature) ;