diff --git a/src/include/ZMap/zmapWindow.h b/src/include/ZMap/zmapWindow.h index ac060397f512e1b65ca88b28f3bdff0be7716ade..490b5c9ed8c8a527598becdc208c35076299cd1c 100755 --- a/src/include/ZMap/zmapWindow.h +++ b/src/include/ZMap/zmapWindow.h @@ -27,9 +27,9 @@ * window displaying genome data. * * HISTORY: - * Last edited: Jul 13 15:49 2004 (edgrif) + * Last edited: Jul 15 10:26 2004 (rnc) * Created: Thu Jul 24 15:21:56 2003 (edgrif) - * CVS info: $Id: zmapWindow.h,v 1.9 2004-07-14 09:02:38 edgrif Exp $ + * CVS info: $Id: zmapWindow.h,v 1.10 2004-07-15 16:27:58 rnc Exp $ *------------------------------------------------------------------- */ #ifndef ZMAP_WINDOW_H @@ -133,7 +133,8 @@ void zMapRegionFreeDNA (ZMapRegion *region); -void zmapWindowDrawFeatures (ZMapFeatureContext feature_context); +void zmapWindowDrawFeatures (FooCanvas *canvas, + ZMapFeatureContext feature_context); /* TEST SCAFFOLDING............... */ diff --git a/src/zmapControl/zmapControlNavigator.c b/src/zmapControl/zmapControlNavigator.c index 79bba86f5e6bafd5ddb698ebfc1b2cccd4801a92..d1ce6a336d946c8047803a6201903f03bde4db31 100755 --- a/src/zmapControl/zmapControlNavigator.c +++ b/src/zmapControl/zmapControlNavigator.c @@ -26,9 +26,9 @@ * * Exported functions: See zmapControl_P.h * HISTORY: - * Last edited: Jul 15 15:51 2004 (edgrif) + * Last edited: Jul 15 17:12 2004 (rnc) * Created: Thu Jul 8 12:54:27 2004 (edgrif) - * CVS info: $Id: zmapControlNavigator.c,v 1.2 2004-07-15 15:06:52 edgrif Exp $ + * CVS info: $Id: zmapControlNavigator.c,v 1.3 2004-07-15 16:30:14 rnc Exp $ *------------------------------------------------------------------- */ @@ -141,15 +141,15 @@ void navScale(FooCanvas *canvas, float offset, int start, int end) for (x = start, count = 1 ; x < end ; x += 10, count++) { - drawLine(FOO_CANVAS_GROUP(group), offset-5, x, offset, x, "black", 1.0); + zmapDrawLine(FOO_CANVAS_GROUP(group), offset-5, x, offset, x, "black", 1.0); char text[25]; sprintf(text,"%dk", x); if (count == 1) - displayText(FOO_CANVAS_GROUP(group), text, offset + 20, x); + zmapDisplayText(FOO_CANVAS_GROUP(group), text, offset + 20, x); if (count > 9) count = 0; } - drawLine(FOO_CANVAS_GROUP(group), offset+1, 0, offset+1, end, "black", 1.0); + zmapDrawLine(FOO_CANVAS_GROUP(group), offset+1, 0, offset+1, end, "black", 1.0); return; } diff --git a/src/zmapControl/zmapControlWindowButtons.c b/src/zmapControl/zmapControlWindowButtons.c index f28660171a8bf38efb1e6d8c79d69b06d45676fc..38a1366ce3c786d53c8e2a552e81a4190b8d9b29 100755 --- a/src/zmapControl/zmapControlWindowButtons.c +++ b/src/zmapControl/zmapControlWindowButtons.c @@ -27,9 +27,9 @@ * * Exported functions: See zmapControl_P.h * HISTORY: - * Last edited: Jul 15 15:51 2004 (edgrif) + * Last edited: Jul 15 17:15 2004 (rnc) * Created: Thu Jul 24 14:36:27 2003 (edgrif) - * CVS info: $Id: zmapControlWindowButtons.c,v 1.9 2004-07-15 15:10:17 edgrif Exp $ + * CVS info: $Id: zmapControlWindowButtons.c,v 1.10 2004-07-15 16:31:14 rnc Exp $ *------------------------------------------------------------------- */ @@ -54,7 +54,8 @@ GtkWidget *zmapControlWindowMakeButtons(ZMap zmap) { GtkWidget *frame ; GtkWidget *hbox, *new_button, *load_button, *stop_button, *quit_button, - *hsplit_button, *vsplit_button, *zoomin_button, *zoomout_button ; + *hsplit_button, *vsplit_button, *zoomin_button, *zoomout_button, + *close_button ; frame = gtk_frame_new(NULL); gtk_container_border_width(GTK_CONTAINER(frame), 5); @@ -97,7 +98,12 @@ GtkWidget *zmapControlWindowMakeButtons(ZMap zmap) gtk_signal_connect(GTK_OBJECT(zoomout_button), "clicked", GTK_SIGNAL_FUNC(zoomOutCB), (gpointer)zmap); gtk_box_pack_start(GTK_BOX(hbox), zoomout_button, FALSE, FALSE, 0) ; - + /* + close_button = gtk_button_new_with_label("Close\nPane") ; + gtk_signal_connect(GTK_OBJECT(close_button), "clicked", + GTK_SIGNAL_FUNC(closePane), (gpointer)zmap) ; + gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0) ; + */ quit_button = gtk_button_new_with_label("Quit") ; gtk_signal_connect(GTK_OBJECT(quit_button), "clicked", GTK_SIGNAL_FUNC(quitCB), (gpointer)zmap) ; @@ -117,8 +123,9 @@ GtkWidget *zmapControlWindowMakeButtons(ZMap zmap) /* * ------------------- Internal functions ------------------- */ +static void testfunc(GQuark key_id, gpointer data, gpointer user_data); -/* These callbacks simple make calls to routines in zmapControl.c, this is because I want all +/* These callbacks simply make calls to routines in zmapControl.c, this is because I want all * the state handling etc. to be in one file so that its easier to work on. */ static void loadCB(GtkWidget *widget, gpointer cb_data) { diff --git a/src/zmapControl/zmapControl_P.h b/src/zmapControl/zmapControl_P.h index 55b10eed68c338922cabe5ef98426abeafef1bc9..ec83726fd95606e026651b12f8c10e0ec0b47011 100755 --- a/src/zmapControl/zmapControl_P.h +++ b/src/zmapControl/zmapControl_P.h @@ -25,9 +25,9 @@ * Description: Private header for interface that creates/manages/destroys * instances of ZMaps. * HISTORY: - * Last edited: Jul 15 15:52 2004 (edgrif) + * Last edited: Jul 15 17:16 2004 (rnc) * Created: Thu Jul 24 14:39:06 2003 (edgrif) - * CVS info: $Id: zmapControl_P.h,v 1.6 2004-07-15 15:11:25 edgrif Exp $ + * CVS info: $Id: zmapControl_P.h,v 1.7 2004-07-15 16:31:50 rnc Exp $ *------------------------------------------------------------------- */ #ifndef ZMAP_CONTROL_P_H @@ -58,14 +58,13 @@ typedef enum { * this top level window there will be one or more zmap "Views". */ typedef struct _ZMapStruct { - gchar *zmap_id ; /* unique for each zmap.... */ + gchar *zmap_id ; /* unique for each zmap.... */ - ZmapState state ; /* state of this zmap. */ + ZmapState state ; gboolean firstTime; - GdkAtom zmap_atom ; /* Used for communicating with zmap - windows. */ + GdkAtom zmap_atom ; /* Used for communicating with zmap */ void *app_data ; /* Data passed back to all callbacks registered for this ZMap. */ @@ -80,9 +79,12 @@ typedef struct _ZMapStruct /* The navigator. */ GtkWidget *navigator ; FooCanvas *navcanvas ; + GtkWidget *navHBox, *navVBox; /* The panes and views. */ + // GtkWidget *displayvbox; + // GtkWidget *hbox; /* I'm not completely sure this is necessary....revisit this later.... */ GtkWidget *pane_vbox ; @@ -90,6 +92,7 @@ typedef struct _ZMapStruct ZMapPane focuspane ; GNode *panesTree ; + // ZMapView curr_view ; /* List of views in this zmap. */ GList *view_list ; @@ -118,7 +121,6 @@ typedef struct _ZMapPaneStruct } ZMapPaneStruct ; - /* Functions internal to zmapControl. */ gboolean zmapControlWindowCreate (ZMap zmap) ; GtkWidget *zmapControlWindowMakeMenuBar(ZMap zmap) ; diff --git a/src/zmapWindow/GFF_scaffold.c b/src/zmapWindow/GFF_scaffold.c index 49028e479590cde98d415989bc14c1ba0295aa09..145b9fea77a4b1dd63fc91e4a31d5421a47da56c 100755 --- a/src/zmapWindow/GFF_scaffold.c +++ b/src/zmapWindow/GFF_scaffold.c @@ -1,4 +1,4 @@ -/* Last edited: Jun 25 12:13 2004 (edgrif) */ +/* Last edited: Jul 8 12:21 2004 (rnc) */ /* This is a temporary file only to help with testing....it will go once GFF code is combined * into the threads etc. code proper.... */ @@ -9,6 +9,7 @@ static ZMapFeatureContext parseGFF(char *filename) ; +static void testfunc(GQuark key_id, gpointer data, gpointer user_data); ZMapFeatureContext testGetGFF(void) @@ -107,11 +108,9 @@ static ZMapFeatureContext parseGFF(char *filename) /* Try getting the features. */ feature_context = zmapGFFGetFeatures(parser) ; - zMapGFFSetFreeOnDestroy(parser, free_arrays) ; zMapGFFDestroyParser(parser) ; - - + if (status == G_IO_STATUS_EOF) { if (g_io_channel_shutdown(gff_file, FALSE, &gff_file_err) != G_IO_STATUS_NORMAL) @@ -125,11 +124,28 @@ static ZMapFeatureContext parseGFF(char *filename) printf("Error reading lines from gff file\n") ; exit(-1) ; } - + } - return feature_context ; } +static void testfunc(GQuark key_id, gpointer data, gpointer user_data) +{ + ZMapFeatureSet zMapFeatureSet = (ZMapFeatureSet)data; + ZMapFeature zMapFeature; + int i; + + printf("GFF_scaffold.c; call %s\n", (char*)user_data); + + for (i=0; i<zMapFeatureSet->features->len; i++) + { + zMapFeature = &g_array_index(zMapFeatureSet->features, ZMapFeatureStruct, i); + printf("processing %s, x1 is %d, x2 is %d\n", zMapFeature->name, zMapFeature->x1, zMapFeature->x2); + } + return; +} + + + diff --git a/src/zmapWindow/zmapWindowDrawFeatures.c b/src/zmapWindow/zmapWindowDrawFeatures.c index 96d93078791703c5cc9b87fd65606d15ede1028c..b3c32cc6fe7185081c37cdf659c5705585a0c5af 100755 --- a/src/zmapWindow/zmapWindowDrawFeatures.c +++ b/src/zmapWindow/zmapWindowDrawFeatures.c @@ -27,41 +27,184 @@ * * Exported functions: * HISTORY: - * Last edited: Jul 2 18:09 2004 (edgrif) + * Last edited: Jul 15 16:02 2004 (rnc) * Created: Thu Jul 29 10:45:00 2004 (rnc) - * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.2 2004-07-02 18:24:54 edgrif Exp $ + * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.3 2004-07-15 16:34:51 rnc Exp $ *------------------------------------------------------------------- */ #include <zmapWindow_P.h> +#include <ZMap/zmapDraw.h> +typedef struct _ParamStruct { + FooCanvas *thisCanvas; + int height; + int length; +} ParamStruct; -static void zmapWindowProcessArray(GQuark key_id, gpointer data, gpointer user_data); +static void zmapWindowProcessFeatureSet(GQuark key_id, gpointer data, gpointer user_data); -void zmapWindowDrawFeatures(ZMapFeatureContext feature_context) + +void zmapWindowDrawFeatures(FooCanvas *canvas, ZMapFeatureContext feature_context) { - float column_spacing = 10.0; + float offset = 20.0; + float result; + double x1, x2, y1, y2; + GtkWidget *parent, *label, *vbox, *vscale, *frame; + GtkRequisition req; + ParamStruct params; + int ticks; // number of tickmarks on scale + int scaleUnit = 100; // spacing of tickmarks on scalebar + int seqUnit; // spacing, in bases of tickmarks + int type; // nomial, ie whether in K, M, etc. + int unitType; + int seqPos; + int scalePos; + int height, width; + char cp[20], unitName[] = { 0, 'k', 'M', 'G', 'T', 'P' }, buf[2] ; + GtkWidget *box; + + // parent = gtk_widget_get_parent(GTK_WIDGET(canvas)); + // gtk_widget_size_request(parent, &req); + foo_canvas_get_scroll_region(canvas, &x1, &y1, &x2, &y2); // for display panel + // gtk_widget_size_request(navHBox, &req); // for navigator + + params.thisCanvas = canvas; + params.height = y2 - y1; + params.length = feature_context->sequence_to_parent.c2 - feature_context->sequence_to_parent.c1; + + // Draw the navigator vscale + // how many tickmarks do we want? + // ticks = req.height/scaleUnit; + //what is their spacing in bases + // seqUnit = (feature_context->sequence_to_parent.c2 - feature_context->sequence_to_parent.c1)/ticks; + // are we working in K, M, or what? + // for (type = 1, unitType = 0 ; + // seqUnit > 0 && 1000 * type < seqUnit && unitType < 5; + // unitType++, type *= 1000) ; + // round seqUnit sensibly + // seqUnit = ((seqUnit + type/2)/type) * type; + + // a vbox to hold all the scale numbers packed in + // vbox = gtk_vbox_new(TRUE, 0); + // gtk_box_pack_start(GTK_BOX(navHBox), vbox, FALSE, FALSE, 0); + + // mark up the scale + /* for (scalePos = 0, seqPos = feature_context->sequence_to_parent.c1; + scalePos < req.height; + scalePos += scaleUnit, seqPos += seqUnit) + { + buf[0] = unitName[unitType] ; buf[1] = 0 ; + sprintf (cp, "%d%s", seqPos/type, buf) ; + if (width < strlen (cp)) + width = strlen (cp) ; + box = gtk_hbox_new(TRUE, 0); + label = gtk_label_new(cp); + gtk_container_add(GTK_CONTAINER(box), label); + gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0); + } + */ + // just trying out the vscale in case it's useful + // vscale = gtk_vscale_new_with_range(0, req.height, scaleUnit); + // gtk_box_pack_start(GTK_BOX(navHBox), vscale, FALSE, FALSE, 0); + + result = zmapDrawScale(canvas , offset, + feature_context->sequence_to_parent.c1, + feature_context->sequence_to_parent.c2); if (feature_context) - g_datalist_foreach(&(feature_context->features), zmapWindowProcessArray, &column_spacing); + g_datalist_foreach(&(feature_context->features), zmapWindowProcessFeatureSet, ¶ms); + // gtk_widget_show_all(navHBox); return; } -static void zmapWindowProcessArray(GQuark key_id, gpointer data, gpointer user_data) +static void zmapWindowProcessFeatureSet(GQuark key_id, gpointer data, gpointer user_data) { ZMapFeatureSet zMapFeatureSet = (ZMapFeatureSet)data; - float *column_spacing = (float*)user_data; - int i; + ZMapFeature zMapFeature; + ZMapSpan zMapSpan, prevSpan; + ZMapAlignBlock *zMapAlign, *prevAlign; + ParamStruct *params = (ParamStruct*)user_data; + int i, j; + double offset = 40.0, column_spacing = 40.0, column_position; + double box_width = 10.0; + FooCanvasItem *group; + int x1, x2, y0, y1, y2; + float middle, line_width = 1.0; + + // NB for each column we create a new canvas group, with the initial y coordinate set to + // 5.0 to just drop it a teeny bit from the top of the window. All items live in the group. for (i = 0; i < zMapFeatureSet->features->len; i++) { - // printf("processing %s\n", zMapFeatureSet->features->name); - } + column_position = offset + column_spacing; + + zMapFeature = &g_array_index(zMapFeatureSet->features, ZMapFeatureStruct, i); + + switch (zMapFeature->type) + { + case ZMAPFEATURE_HOMOL: /* type 1 is a homol */ + group = foo_canvas_item_new(foo_canvas_root(params->thisCanvas), + foo_canvas_group_get_type(), + "x",(double)column_position, + "y",(double)5.0, + NULL); + + zmapDrawBox(group, column_position, (zMapFeature->feature.homol.y1 * params->height / params->length), + column_position + box_width, (zMapFeature->feature.homol.y2 * params->height / params->length), + "black", "green"); + break; + case ZMAPFEATURE_TRANSCRIPT: /* type 4 is a transcript */ + column_position = offset; + group = foo_canvas_item_new(foo_canvas_root(params->thisCanvas), + foo_canvas_group_get_type(), + "x",(double)column_position, + "y",(double)5.0, + NULL); + + for (j = 1; j < zMapFeature->feature.transcript.exons->len; j++) + { + zMapSpan = &g_array_index(zMapFeature->feature.transcript.exons, ZMapSpanStruct, j); + prevSpan = &g_array_index(zMapFeature->feature.transcript.exons, ZMapSpanStruct, j-1); + middle = ((prevSpan->x2 + zMapSpan->x1)/2) * params->height/params->length; + y0 = prevSpan->x1 * params->height/params->length; // y coord of preceding exon + y1 = prevSpan->x2 * params->height/params->length; + y2 = zMapSpan->x1 * params->height/params->length; + + // skip this intron if its preceding exon is too small to draw. We use + // y0 and y1 since they are screen coordinates independent of magnification. + // Note this is a kludge which will meet its come-uppance during zooming + // because zooming doesn't revisit this block of code, so tiny exons will + // appear when zoomed, but the intervening introns will be lost forever. + + if (y2 > y1 && y0 +2 <= y1) + { + zmapDrawLine(FOO_CANVAS_GROUP(group), column_position + box_width/2, y1, + column_position + box_width, middle, "blue", line_width); + zmapDrawLine(FOO_CANVAS_GROUP(group), column_position + box_width, middle, + column_position + box_width/2, y2, "blue", line_width); + } + } + for (j = 0; j < zMapFeature->feature.transcript.exons->len; j++) + { + zMapSpan = &g_array_index(zMapFeature->feature.transcript.exons, ZMapSpanStruct, j); + + zmapDrawBox(group, column_position, (zMapSpan->x1 * params->height / params->length), + column_position + box_width, (zMapSpan->x2 * params->height / params->length), + "black", "blue"); + } + break; + + default: + break; + } + } + return; } /****************** end of file ************************************/