From 165716d0ce0d98229b46b57346c3d1a7c763b826 Mon Sep 17 00:00:00 2001 From: rds <rds> Date: Sun, 7 Jun 2009 08:18:56 +0000 Subject: [PATCH] remove old objects now containers used --- src/zmapWindow/zmapWindowItemFeatureBlock.c | 404 ------- src/zmapWindow/zmapWindowItemFeatureBlock.h | 87 -- src/zmapWindow/zmapWindowItemFeatureBlock_I.h | 69 -- src/zmapWindow/zmapWindowItemFeatureSet.c | 1035 ----------------- src/zmapWindow/zmapWindowItemFeatureSet.h | 119 -- src/zmapWindow/zmapWindowItemFeatureSet_I.h | 108 -- 6 files changed, 1822 deletions(-) delete mode 100755 src/zmapWindow/zmapWindowItemFeatureBlock.c delete mode 100755 src/zmapWindow/zmapWindowItemFeatureBlock.h delete mode 100755 src/zmapWindow/zmapWindowItemFeatureBlock_I.h delete mode 100755 src/zmapWindow/zmapWindowItemFeatureSet.c delete mode 100755 src/zmapWindow/zmapWindowItemFeatureSet.h delete mode 100755 src/zmapWindow/zmapWindowItemFeatureSet_I.h diff --git a/src/zmapWindow/zmapWindowItemFeatureBlock.c b/src/zmapWindow/zmapWindowItemFeatureBlock.c deleted file mode 100755 index a5b421361..000000000 --- a/src/zmapWindow/zmapWindowItemFeatureBlock.c +++ /dev/null @@ -1,404 +0,0 @@ -/* File: zmapWindowItemFeatureBlock.c - * Author: Roy Storey (rds@sanger.ac.uk) - * Copyright (c) 2007: Genome Research Ltd. - *------------------------------------------------------------------- - * ZMap is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt - *------------------------------------------------------------------- - * This file is part of the ZMap genome database package - * originally written by: - * - * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, - * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk - * - * Description: - * - * Exported functions: See XXXXXXXXXXXXX.h - * HISTORY: - * Last edited: Apr 20 11:20 2009 (rds) - * Created: Mon Jul 30 13:09:33 2007 (rds) - * CVS info: $Id: zmapWindowItemFeatureBlock.c,v 1.3 2009-04-20 11:05:28 rds Exp $ - *------------------------------------------------------------------- - */ - -#include <ZMap/zmapSeqBitmap.h> -#include <zmapWindowItemFeatureBlock_I.h> -#include <zmapWindowItemFeatureSet.h> -#include <zmapWindow_P.h> /* ITEM_FEATURE_SET_DATA */ - -enum - { - ITEM_FEATURE_BLOCK_0, /* zero == invalid prop value */ - }; - -static ZMapSeqBitmap get_bitmap_for_style(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block, - ZMapFeatureTypeStyle style); -static ZMapSeqBitmap get_bitmap_for_key(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block, - GQuark key); - - -static void zmap_window_item_feature_block_class_init (ZMapWindowItemFeatureBlockDataClass block_data_class); -static void zmap_window_item_feature_block_init (ZMapWindowItemFeatureBlockData block_data); -static void zmap_window_item_feature_block_set_property(GObject *gobject, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void zmap_window_item_feature_block_get_property(GObject *gobject, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void zmap_window_item_feature_block_dispose (GObject *object); -static void zmap_window_item_feature_block_finalize (GObject *object); - - -static GObjectClass *parent_class_G = NULL; - - -GType zmapWindowItemFeatureBlockGetType(void) -{ - static GType group_type = 0; - - if (!group_type) - { - static const GTypeInfo group_info = - { - sizeof (zmapWindowItemFeatureBlockDataClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) zmap_window_item_feature_block_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (zmapWindowItemFeatureBlockData), - 0, /* n_preallocs */ - (GInstanceInitFunc) zmap_window_item_feature_block_init - }; - - group_type = g_type_register_static (G_TYPE_OBJECT, - "zmapWindowItemFeatureBlockData", - &group_info, - 0); - } - - return group_type; -} - - -ZMapWindowItemFeatureBlockData zmapWindowItemFeatureBlockCreate(ZMapWindow window) -{ - ZMapWindowItemFeatureBlockData block_data; - - if((block_data = g_object_new(zmapWindowItemFeatureBlockGetType(), NULL))) - { - block_data->window = window; - } - - return block_data; -} - -void zmapWindowItemFeatureBlockAddCompressedColumn(ZMapWindowItemFeatureBlockData block_data, - FooCanvasGroup *container) -{ - - block_data->compressed_cols = g_list_append(block_data->compressed_cols, container) ; - - return ; -} - -GList *zmapWindowItemFeatureBlockRemoveCompressedColumns(ZMapWindowItemFeatureBlockData block_data) -{ - GList *list = NULL; - - list = block_data->compressed_cols; - block_data->compressed_cols = NULL; - - return list; -} - -void zmapWindowItemFeatureBlockAddBumpedColumn(ZMapWindowItemFeatureBlockData block_data, - FooCanvasGroup *container) -{ - - block_data->bumped_cols = g_list_append(block_data->bumped_cols, container) ; - - return ; -} - -GList *zmapWindowItemFeatureBlockRemoveBumpedColumns(ZMapWindowItemFeatureBlockData block_data) -{ - GList *list = NULL; - - list = block_data->bumped_cols; - block_data->bumped_cols = NULL; - - return list; -} - -ZMapWindow zmapWindowItemFeatureBlockGetWindow(ZMapWindowItemFeatureBlockData block_data) -{ - ZMapWindow window = NULL; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_BLOCK(block_data), window); - - window = block_data->window; - - return window; -} - -void zmapWindowItemFeatureBlockMarkRegion(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block) -{ - ZMapSeqBitmap bitmap; - - if((bitmap = get_bitmap_for_key(block_data, block, block->unique_id))) - { - if(block->features_start == 0) - block->features_start = block->block_to_sequence.q1; - - if(block->features_end == 0) - block->features_end = block->block_to_sequence.q2; - - zmapSeqBitmapMarkRegion(bitmap, block->features_start, block->features_end); - } - - return ; -} - -void zmapWindowItemFeatureBlockMarkRegionForColumn(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block, - ZMapWindowItemFeatureSetData set_data) -{ - ZMapSeqBitmap bitmap; - - if((bitmap = get_bitmap_for_key(block_data, block, set_data->unique_id))) - { - if(block->features_start == 0) - block->features_start = block->block_to_sequence.q1; - - if(block->features_end == 0) - block->features_end = block->block_to_sequence.q2; - - zmapSeqBitmapMarkRegion(bitmap, block->features_start, block->features_end); - } - - return ; -} - -GList *zmapWindowItemFeatureBlockFilterMarkedColumns(ZMapWindowItemFeatureBlockData block_data, - GList *list, int world1, int world2) -{ - GList *key_list; - - key_list = list; - - while(key_list) - { - ZMapSeqBitmap bitmap; - GQuark key; - GList *tmp_list; - - tmp_list = key_list->next; - - key = GPOINTER_TO_UINT(key_list->data); - - /* we don't want to create anything... */ - if((bitmap = get_bitmap_for_key(block_data, NULL, key))) - { - if(zmapSeqBitmapIsRegionFullyMarked(bitmap, world1, world2)) - list = g_list_delete_link(list, key_list); - } - - key_list = tmp_list; - } - - return list; -} - -gboolean zmapWindowItemFeatureBlockIsColumnLoaded(ZMapWindowItemFeatureBlockData block_data, - FooCanvasGroup *column_group, int world1, int world2) -{ - ZMapWindowItemFeatureSetData set_data; - ZMapSeqBitmap bitmap; - gboolean fully_marked = FALSE; - - if((set_data = g_object_get_data(G_OBJECT(column_group), ITEM_FEATURE_SET_DATA))) - { - if((bitmap = get_bitmap_for_key(block_data, NULL, set_data->unique_id))) - { - fully_marked = zmapSeqBitmapIsRegionFullyMarked(bitmap, world1, world2); - } - } - - return fully_marked; -} - -ZMapWindowItemFeatureBlockData zmapWindowItemFeatureBlockDestroy(ZMapWindowItemFeatureBlockData item_feature_block) -{ - g_object_unref(G_OBJECT(item_feature_block)); - - item_feature_block = NULL; - - return item_feature_block; -} - - -/* INTERNAL */ - -static ZMapSeqBitmap get_bitmap_for_style(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block, - ZMapFeatureTypeStyle style) -{ - ZMapSeqBitmap bitmap; - GQuark key; - - key = zMapStyleGetUniqueID(style); - - bitmap = get_bitmap_for_key(block_data, block, key); - - return bitmap; -} - -static ZMapSeqBitmap get_bitmap_for_key(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block, - GQuark key) -{ - ZMapSeqBitmap bitmap = NULL; - - if(!(bitmap = g_hash_table_lookup(block_data->loaded_region_hash, GUINT_TO_POINTER(key)))) - { - if(block) - { - int length; - - length = block->block_to_sequence.q2 - block->block_to_sequence.q1 + 1; - - bitmap = zmapSeqBitmapCreate(block->block_to_sequence.q1, length, 9000); - - g_hash_table_insert(block_data->loaded_region_hash, GUINT_TO_POINTER(key), bitmap); - } - } - - return bitmap; -} - - - -/* Object code */ -static void zmap_window_item_feature_block_class_init(ZMapWindowItemFeatureBlockDataClass block_data_class) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *)block_data_class; - - gobject_class->set_property = zmap_window_item_feature_block_set_property; - gobject_class->get_property = zmap_window_item_feature_block_get_property; - - parent_class_G = g_type_class_peek_parent(block_data_class); - -#ifdef RDS_DONT_INCLUDE - /* width */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_BLOCK_WIDTH, - g_param_spec_double(ZMAPSTYLE_PROPERTY_WIDTH, - ZMAPSTYLE_PROPERTY_WIDTH, - "The minimum width the column should be displayed at.", - 0.0, 32000.00, 16.0, - ZMAP_PARAM_STATIC_RO)); -#endif - - gobject_class->dispose = zmap_window_item_feature_block_dispose; - gobject_class->finalize = zmap_window_item_feature_block_finalize; - - return ; -} - -static void zmap_window_item_feature_block_init(ZMapWindowItemFeatureBlockData block_data) -{ - block_data->loaded_region_hash = g_hash_table_new_full(NULL, NULL, NULL, (GDestroyNotify)zmapSeqBitmapDestroy); - block_data->compressed_cols = NULL; - return ; -} - -static void zmap_window_item_feature_block_set_property(GObject *gobject, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - - switch(param_id) - { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec); - break; - } - - return ; -} - -static void zmap_window_item_feature_block_get_property(GObject *gobject, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - ZMapWindowItemFeatureBlockData block_data; - - block_data = ZMAP_WINDOW_ITEM_FEATURE_BLOCK(gobject); - - switch(param_id) - { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec); - break; - } - - return ; -} - -static void zmap_window_item_feature_block_dispose(GObject *object) -{ - ZMapWindowItemFeatureBlockData block_data; - GObjectClass *gobject_class = G_OBJECT_CLASS(parent_class_G); - - block_data = ZMAP_WINDOW_ITEM_FEATURE_BLOCK(object); - - block_data->window = NULL; /* not ours */ - - /* compressed and bumped columns are not ours. canvas owns them, just free the lists */ - if(block_data->compressed_cols) - g_list_free(block_data->compressed_cols) ; - - if(block_data->bumped_cols) - g_list_free(block_data->bumped_cols); - - if(block_data->loaded_region_hash) - g_hash_table_destroy(block_data->loaded_region_hash); - - if(gobject_class->dispose) - (*gobject_class->dispose)(object); - - return ; -} - -static void zmap_window_item_feature_block_finalize(GObject *object) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(parent_class_G); - - if(gobject_class->finalize) - (*gobject_class->finalize)(object); - - return ; -} - diff --git a/src/zmapWindow/zmapWindowItemFeatureBlock.h b/src/zmapWindow/zmapWindowItemFeatureBlock.h deleted file mode 100755 index d3d07a28d..000000000 --- a/src/zmapWindow/zmapWindowItemFeatureBlock.h +++ /dev/null @@ -1,87 +0,0 @@ -/* File: zmapWindowItemFeatureBlock.h - * Author: Roy Storey (rds@sanger.ac.uk) - * Copyright (c) 2009: Genome Research Ltd. - *------------------------------------------------------------------- - * ZMap is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt - *------------------------------------------------------------------- - * This file is part of the ZMap genome database package - * originally written by: - * - * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, - * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk - * - * Description: - * - * Exported functions: See XXXXXXXXXXXXX.h - * HISTORY: - * Last edited: Apr 16 15:11 2009 (rds) - * Created: Fri Feb 6 15:32:46 2009 (rds) - * CVS info: $Id: zmapWindowItemFeatureBlock.h,v 1.2 2009-04-16 14:37:24 rds Exp $ - *------------------------------------------------------------------- - */ - -#ifndef __ZMAP_WINDOW_ITEM_FEATURE_BLOCK_H__ -#define __ZMAP_WINDOW_ITEM_FEATURE_BLOCK_H__ - -#include <glib.h> -#include <glib-object.h> -#include <ZMap/zmapWindow.h> - -#define ZMAP_TYPE_WINDOW_ITEM_FEATURE_BLOCK (zmapWindowItemFeatureBlockGetType()) -#define ZMAP_WINDOW_ITEM_FEATURE_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_BLOCK, zmapWindowItemFeatureBlockData)) -#define ZMAP_WINDOW_ITEM_FEATURE_BLOCK_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_BLOCK, zmapWindowItemFeatureBlockData const)) -#define ZMAP_WINDOW_ITEM_FEATURE_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), ZMAP_TYPE_WINDOW_ITEM_FEATURE_BLOCK, zmapWindowItemFeatureBlockDataClass)) -#define ZMAP_IS_WINDOW_ITEM_FEATURE_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_BLOCK)) -#define ZMAP_WINDOW_ITEM_FEATURE_BLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_BLOCK, zmapWindowItemFeatureBlockDataClass)) - - -/* Instance */ -typedef struct _zmapWindowItemFeatureBlockDataStruct zmapWindowItemFeatureBlockData, *ZMapWindowItemFeatureBlockData; - -/* Class */ -typedef struct _zmapWindowItemFeatureBlockDataClassStruct zmapWindowItemFeatureBlockDataClass, *ZMapWindowItemFeatureBlockDataClass ; - - - -/* Public funcs */ -GType zmapWindowItemFeatureBlockGetType(void); - -ZMapWindowItemFeatureBlockData zmapWindowItemFeatureBlockCreate(ZMapWindow window); - - -void zmapWindowItemFeatureBlockAddCompressedColumn(ZMapWindowItemFeatureBlockData block_data, - FooCanvasGroup *container); -GList *zmapWindowItemFeatureBlockRemoveCompressedColumns(ZMapWindowItemFeatureBlockData block_data); -void zmapWindowItemFeatureBlockAddBumpedColumn(ZMapWindowItemFeatureBlockData block_data, - FooCanvasGroup *container); -GList *zmapWindowItemFeatureBlockRemoveBumpedColumns(ZMapWindowItemFeatureBlockData block_data); -ZMapWindow zmapWindowItemFeatureBlockGetWindow(ZMapWindowItemFeatureBlockData block_data); -void zmapWindowItemFeatureBlockMarkRegion(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block); -void zmapWindowItemFeatureBlockMarkRegionForStyle(ZMapWindowItemFeatureBlockData block_data, - ZMapFeatureBlock block, - ZMapFeatureTypeStyle style); -GList *zmapWindowItemFeatureBlockFilterMarkedColumns(ZMapWindowItemFeatureBlockData block_data, - GList *list, int world1, int world2); -gboolean zmapWindowItemFeatureBlockIsColumnLoaded(ZMapWindowItemFeatureBlockData block_data, - FooCanvasGroup *column_group, int world1, int world2); - - -ZMapWindowItemFeatureBlockData zmapWindowItemFeatureBlockDestroy(ZMapWindowItemFeatureBlockData block_data); - - - -#endif /* __ZMAP_WINDOW_ITEM_FEATURE_BLOCK_H__ */ diff --git a/src/zmapWindow/zmapWindowItemFeatureBlock_I.h b/src/zmapWindow/zmapWindowItemFeatureBlock_I.h deleted file mode 100755 index 2b8c7165e..000000000 --- a/src/zmapWindow/zmapWindowItemFeatureBlock_I.h +++ /dev/null @@ -1,69 +0,0 @@ -/* File: zmapWindowItemFeatureBlock_I.h - * Author: Roy Storey (rds@sanger.ac.uk) - * Copyright (c) 2009: Genome Research Ltd. - *------------------------------------------------------------------- - * ZMap is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt - *------------------------------------------------------------------- - * This file is part of the ZMap genome database package - * originally written by: - * - * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, - * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk - * - * Description: - * - * Exported functions: See XXXXXXXXXXXXX.h - * HISTORY: - * Last edited: Apr 16 14:59 2009 (rds) - * Created: Fri Feb 6 11:49:03 2009 (rds) - * CVS info: $Id: zmapWindowItemFeatureBlock_I.h,v 1.2 2009-04-16 14:37:29 rds Exp $ - *------------------------------------------------------------------- - */ - -#ifndef __ZMAP_WINDOW_ITEM_FEATURE_BLOCK_I_H__ -#define __ZMAP_WINDOW_ITEM_FEATURE_BLOCK_I_H__ - -#include <zmapWindowItemFeatureBlock.h> - -#define ZMAP_PARAM_STATIC (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) -#define ZMAP_PARAM_STATIC_RW (ZMAP_PARAM_STATIC | G_PARAM_READWRITE) -#define ZMAP_PARAM_STATIC_RO (ZMAP_PARAM_STATIC | G_PARAM_READABLE) - - -#define ZMAP_BIN_MAX_VALUE(BITMAP) ((1 << BITMAP->bin_depth) - 1) - -typedef struct _zmapWindowItemFeatureBlockDataStruct -{ - GObject __parent__; - - ZMapWindow window; - - GList *compressed_cols, *bumped_cols ; - - GHashTable *loaded_region_hash; - -} zmapWindowItemFeatureBlockDataStruct; - - -typedef struct _zmapWindowItemFeatureBlockDataClassStruct -{ - GObjectClass __parent__; - -} zmapWindowItemFeatureBlockDataClassStruct; - - - -#endif /* __ZMAP_WINDOW_ITEM_FEATURE_BLOCK_I_H__ */ diff --git a/src/zmapWindow/zmapWindowItemFeatureSet.c b/src/zmapWindow/zmapWindowItemFeatureSet.c deleted file mode 100755 index e52e0bf2b..000000000 --- a/src/zmapWindow/zmapWindowItemFeatureSet.c +++ /dev/null @@ -1,1035 +0,0 @@ -/* File: zmapWindowItemFeatureSet.c - * Author: Roy Storey (rds@sanger.ac.uk) - * Copyright (c) 2007: Genome Research Ltd. - *------------------------------------------------------------------- - * ZMap is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt - *------------------------------------------------------------------- - * This file is part of the ZMap genome database package - * originally written by: - * - * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, - * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk - * - * Description: - * - * Exported functions: See XXXXXXXXXXXXX.h - * HISTORY: - * Last edited: May 7 16:01 2009 (rds) - * Created: Mon Jul 30 13:09:33 2007 (rds) - * CVS info: $Id: zmapWindowItemFeatureSet.c,v 1.17 2009-05-07 21:35:14 rds Exp $ - *------------------------------------------------------------------- - */ -#include <string.h> /* memset */ - -#include <ZMap/zmapUtils.h> -#include <zmapWindowItemFeatureSet_I.h> -#include <zmapWindowContainer.h> - -enum - { - ITEM_FEATURE_SET_0, /* zero == invalid prop value */ - ITEM_FEATURE_SET_WIDTH, - ITEM_FEATURE_SET_VISIBLE, - ITEM_FEATURE_SET_BUMP_MODE, - ITEM_FEATURE_SET_DEFAULT_BUMP_MODE, - ITEM_FEATURE_SET_FRAME_MODE, - ITEM_FEATURE_SET_SHOW_WHEN_EMPTY, - ITEM_FEATURE_SET_DEFERRED, - ITEM_FEATURE_SET_STRAND_SPECIFIC, - ITEM_FEATURE_SET_BUMP_SPACING, - ITEM_FEATURE_SET_JOIN_ALIGNS, - }; - -typedef struct -{ - GValue *gvalue; - const char *spec_name; - guint param_id; -} ItemFeatureValueDataStruct, *ItemFeatureValueData; - -typedef struct -{ - GList *list; - ZMapFeature feature; -}ListFeatureStruct, *ListFeature; - -typedef struct -{ - GQueue *queue; - ZMapFeature feature; -}QueueFeatureStruct, *QueueFeature; - -static void zmap_window_item_feature_set_class_init (ZMapWindowItemFeatureSetDataClass set_data_class); -static void zmap_window_item_feature_set_init (ZMapWindowItemFeatureSetData set_data); -static void zmap_window_item_feature_set_set_property(GObject *gobject, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void zmap_window_item_feature_set_get_property(GObject *gobject, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void zmap_window_item_feature_set_dispose (GObject *object); -static void zmap_window_item_feature_set_finalize (GObject *object); - - -static void extract_value_from_style_table(gpointer key, gpointer value, gpointer user_data); -static void reset_bump_mode_cb(gpointer key, gpointer value, gpointer user_data); -static void queueRemoveFromList(gpointer queue_data, gpointer user_data); -static void listRemoveFromList(gpointer list_data, gpointer user_data); -static void removeList(gpointer data, gpointer user_data_unused) ; -static void zmap_g_queue_replace(GQueue *queue, gpointer old, gpointer new); - - -static GObjectClass *parent_class_G = NULL; - -gboolean zmap_g_return_moan(char *file, int line) -{ - g_warning("Failed @ %s:%d", file, line); - - return FALSE; -} - -GType zmapWindowItemFeatureSetGetType(void) -{ - static GType group_type = 0; - - if (!group_type) - { - static const GTypeInfo group_info = - { - sizeof (zmapWindowItemFeatureSetDataClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) zmap_window_item_feature_set_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (zmapWindowItemFeatureSetData), - 0, /* n_preallocs */ - (GInstanceInitFunc) zmap_window_item_feature_set_init - }; - - group_type = g_type_register_static (G_TYPE_OBJECT, - "zmapWindowItemFeatureSetData", - &group_info, - 0); - } - - return group_type; -} - - -ZMapWindowItemFeatureSetData zmapWindowItemFeatureSetCreate(ZMapWindow window, - FooCanvasGroup *column_container, - GQuark feature_set_unique_id, - GQuark feature_set_original_id, /* unused! */ - GList *style_list, - ZMapStrand strand, - ZMapFrame frame) -{ - ZMapWindowItemFeatureSetData set_data = NULL; - - g_return_val_if_fail(window != NULL, set_data); - g_return_val_if_fail(column_container != NULL, set_data); - g_return_val_if_fail(feature_set_unique_id != 0, set_data); - - if((set_data = g_object_new(zmapWindowItemFeatureSetGetType(), NULL))) - { - GList *list; - - set_data->window = window; - set_data->strand = strand; - set_data->frame = frame; - /* set_data->style_id = 0;*/ /* feature_set_original_id */ - set_data->unique_id = feature_set_unique_id; - - if((list = g_list_first(style_list))) - { - do - { - ZMapFeatureTypeStyle style; - - style = (ZMapFeatureTypeStyle)(list->data); - - zmapWindowItemFeatureSetStyleFromStyle(set_data, style); - } - while((list = g_list_next(list))); - } - - set_data->column_container = column_container; - - zmapWindowContainerSetVisibility(column_container, FALSE); - - zmapWindowContainerSetData(column_container, ITEM_FEATURE_SET_DATA, set_data); - } - - return set_data; -} - -void zmapWindowItemFeatureSetAttachFeatureSet(ZMapWindowItemFeatureSetData set_data, - ZMapFeatureSet feature_set_to_attach) -{ - - if(feature_set_to_attach && !set_data->settings.has_feature_set) - { - ZMapWindowStats stats = NULL; - - zmapWindowContainerSetData(set_data->column_container, ITEM_FEATURE_DATA, feature_set_to_attach) ; - set_data->settings.has_feature_set = TRUE; - - if((stats = zmapWindowStatsCreate((ZMapFeatureAny)feature_set_to_attach))) - { - zmapWindowContainerSetData(set_data->column_container, ITEM_FEATURE_STATS, stats); - set_data->settings.has_stats = TRUE; - } - } - else - { - /* We don't attach a feature set if there's already one - * attached. This works for the good as the merge will - * create featuresets which get destroyed after drawing - * in the case of a pre-exisiting featureset. We don't - * want these attached, as the original will also get - * destroyed and the one attached will point to a set - * which has been freed! */ - } - - return ; -} - -ZMapFeatureSet zmapWindowItemFeatureSetRecoverFeatureSet(ZMapWindowItemFeatureSetData set_data) -{ - ZMapFeatureSet feature_set = NULL; - - if(set_data->settings.has_feature_set) - { - feature_set = g_object_get_data(G_OBJECT(set_data->column_container), ITEM_FEATURE_DATA); - - if(!feature_set) - { - g_warning("%s", "No Feature Set!"); - set_data->settings.has_feature_set = FALSE; - } - } - - return feature_set; -} - -ZMapWindowStats zmapWindowItemFeatureSetRecoverStats(ZMapWindowItemFeatureSetData set_data) -{ - ZMapWindowStats stats = NULL; - - if(set_data->settings.has_stats) - { - stats = g_object_get_data(G_OBJECT(set_data->column_container), ITEM_FEATURE_STATS); - - if(!stats) - { - g_warning("%s", "No Stats!"); - set_data->settings.has_stats = FALSE; - } - } - - return stats; -} - -/*! - * \brief Gets the style we must use to draw with, given a style - */ -ZMapFeatureTypeStyle zmapWindowItemFeatureSetStyleFromStyle(ZMapWindowItemFeatureSetData set_data, - ZMapFeatureTypeStyle style2copy) -{ - ZMapFeatureTypeStyle duplicated = NULL; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), duplicated); - g_return_val_if_fail(ZMAP_IS_FEATURE_STYLE(style2copy), duplicated); - - if(!(duplicated = zmapWindowStyleTableFind(set_data->style_table, zMapStyleGetUniqueID(style2copy)))) - { - int s = sizeof(set_data->lazy_loaded); - - duplicated = zmapWindowStyleTableAddCopy(set_data->style_table, style2copy); - - memset(&set_data->lazy_loaded, 0, s); - } - - return duplicated; -} - -ZMapFeatureTypeStyle zmapWindowItemFeatureSetStyleFromID(ZMapWindowItemFeatureSetData set_data, - GQuark style_unique_id) -{ - ZMapFeatureTypeStyle duplicated = NULL; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), duplicated); - - if(!(duplicated = zmapWindowStyleTableFind(set_data->style_table, style_unique_id))) - { - zMapAssertNotReached(); - } - - return duplicated; -} - -/* Warning! This is dynamic and will pick the original id over unique id */ -GQuark zmapWindowItemFeatureSetColumnDisplayName(ZMapWindowItemFeatureSetData set_data) -{ - ZMapFeatureSet feature_set; - GQuark display_id = 0; - - if((feature_set = zmapWindowItemFeatureSetRecoverFeatureSet(set_data))) - display_id = feature_set->original_id; - else - display_id = set_data->unique_id; - - return display_id; -} - -ZMapWindow zmapWindowItemFeatureSetGetWindow(ZMapWindowItemFeatureSetData set_data) -{ - ZMapWindow window = NULL; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), window); - - window = set_data->window; - - return window; -} - -ZMapStrand zmapWindowItemFeatureSetGetStrand(ZMapWindowItemFeatureSetData set_data) -{ - ZMapStrand strand = ZMAPSTRAND_NONE; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), strand); - - strand = set_data->strand; - - return strand; -} - -ZMapFrame zmapWindowItemFeatureSetGetFrame (ZMapWindowItemFeatureSetData set_data) -{ - ZMapFrame frame = ZMAPFRAME_NONE; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), frame); - - frame = set_data->frame; - - return frame; -} - - -ZMapFeatureTypeStyle zmapWindowItemFeatureSetGetStyle(ZMapWindowItemFeatureSetData set_data, - ZMapFeature feature) -{ - ZMapFeatureTypeStyle style = NULL; - - style = zmapWindowStyleTableFind(set_data->style_table, set_data->unique_id); - - return style; -} - -double zmapWindowItemFeatureSetGetWidth(ZMapWindowItemFeatureSetData set_data) -{ - double width = 0.0; - - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_WIDTH, &width, - NULL); - - return width; -} - -double zmapWindowItemFeatureGetBumpSpacing(ZMapWindowItemFeatureSetData set_data) -{ - double spacing; - - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_BUMP_SPACING, &spacing, - NULL); - - return spacing; -} - -gboolean zmapWindowItemFeatureSetGetMagValues(ZMapWindowItemFeatureSetData set_data, - double *min_mag_out, double *max_mag_out) -{ - ZMapFeatureTypeStyle style = NULL; - gboolean mag_sens = FALSE; - - if((style = zmapWindowStyleTableFind(set_data->style_table, set_data->unique_id))) - { - double min_mag; - double max_mag; - - min_mag = zMapStyleGetMinMag(style) ; - max_mag = zMapStyleGetMaxMag(style) ; - - if (min_mag != 0.0 || max_mag != 0.0) - mag_sens = TRUE; - - if(min_mag_out) - *min_mag_out = min_mag; - if(max_mag_out) - *max_mag_out = max_mag; - } - - return mag_sens; -} - -ZMapStyleColumnDisplayState zmapWindowItemFeatureSetGetDisplay(ZMapWindowItemFeatureSetData set_data) -{ - ZMapStyleColumnDisplayState display = ZMAPSTYLE_COLDISPLAY_SHOW; - - if(!set_data->lazy_loaded.display_state) - { - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_DISPLAY_MODE, &(set_data->settings.display_state), - NULL); - } - - display = set_data->settings.display_state; - - return display; -} - -void zmapWindowItemFeatureSetDisplay(ZMapWindowItemFeatureSetData set_data, ZMapStyleColumnDisplayState state) -{ - ZMapFeatureTypeStyle style; - - if((style = zmapWindowStyleTableFind(set_data->style_table, set_data->unique_id))) - { - g_object_set(G_OBJECT(style), - ZMAPSTYLE_PROPERTY_DISPLAY_MODE, state, - NULL); - } - - return ; -} - -gboolean zmapWindowItemFeatureSetShowWhenEmpty(ZMapWindowItemFeatureSetData set_data) -{ - gboolean show = FALSE; - - if(!set_data->lazy_loaded.show_when_empty) - { - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_SHOW_WHEN_EMPTY, &(set_data->settings.show_when_empty), - NULL); - set_data->lazy_loaded.show_when_empty = 1; - } - - show = set_data->settings.show_when_empty; - - return show; -} - -ZMapStyle3FrameMode zmapWindowItemFeatureSetGetFrameMode(ZMapWindowItemFeatureSetData set_data) -{ - ZMapStyle3FrameMode frame_mode = ZMAPSTYLE_3_FRAME_INVALID; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), frame_mode); - - if(!set_data->lazy_loaded.frame_mode) - { - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_FRAME_MODE, &(set_data->settings.frame_mode), - NULL); - //set_data->lazy_loaded.frame_mode = 1; - } - - frame_mode = set_data->settings.frame_mode; - - return frame_mode; -} - -gboolean zmapWindowItemFeatureSetIsFrameSpecific(ZMapWindowItemFeatureSetData set_data, - ZMapStyle3FrameMode *frame_mode_out) -{ - ZMapStyle3FrameMode frame_mode = ZMAPSTYLE_3_FRAME_INVALID; - gboolean frame_specific = FALSE; - - g_return_val_if_fail(ZMAP_IS_WINDOW_ITEM_FEATURE_SET(set_data), FALSE); - - if(!set_data->lazy_loaded.frame_specific) - { - frame_mode = zmapWindowItemFeatureSetGetFrameMode(set_data) ; - - //set_data->lazy_loaded.frame_specific = 1; - - if(frame_mode != ZMAPSTYLE_3_FRAME_NEVER) - set_data->settings.frame_specific = TRUE; - - if(frame_mode == ZMAPSTYLE_3_FRAME_INVALID) - { - zMapLogWarning("Frame mode for column %s is invalid.", g_quark_to_string(set_data->unique_id)); - set_data->settings.frame_specific = FALSE; - } - } - - frame_specific = set_data->settings.frame_specific; - - if(frame_mode_out) - *frame_mode_out = frame_mode; - - return frame_specific; -} - -gboolean zmapWindowItemFeatureSetIsStrandSpecific(ZMapWindowItemFeatureSetData set_data) -{ - gboolean strand_specific = FALSE; - - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_STRAND_SPECIFIC, &(set_data->settings.strand_specific), - NULL); - - strand_specific = set_data->settings.strand_specific; - - return strand_specific; -} - -ZMapStyleBumpMode zmapWindowItemFeatureSetGetBumpMode(ZMapWindowItemFeatureSetData set_data) -{ - ZMapStyleBumpMode mode = ZMAPBUMP_UNBUMP; - - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_BUMP_MODE, &(set_data->settings.bump_mode), - NULL); - - mode = set_data->settings.bump_mode; - - return mode; -} - -ZMapStyleBumpMode zmapWindowItemFeatureSetGetDefaultBumpMode(ZMapWindowItemFeatureSetData set_data) -{ - ZMapStyleBumpMode mode = ZMAPBUMP_UNBUMP; - - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_DEFAULT_BUMP_MODE, &(set_data->settings.default_bump_mode), - NULL); - - mode = set_data->settings.default_bump_mode; - - return mode; -} - -ZMapStyleBumpMode zmapWindowItemFeatureSetResetBumpModes(ZMapWindowItemFeatureSetData set_data) -{ - ZMapStyleBumpMode mode = ZMAPBUMP_UNBUMP; - ItemFeatureValueDataStruct value_data = {NULL}; - GValue value = {0}; - - g_value_init(&value, G_TYPE_UINT); - - value_data.spec_name = ZMAPSTYLE_PROPERTY_BUMP_MODE; - value_data.gvalue = &value; - value_data.param_id = ITEM_FEATURE_SET_BUMP_MODE; - - g_hash_table_foreach(set_data->style_table, reset_bump_mode_cb, &value_data); - - mode = g_value_get_uint(&value); - - return mode; -} - -gboolean zmapWindowItemFeatureSetJoinAligns(ZMapWindowItemFeatureSetData set_data, unsigned int *threshold) -{ - gboolean result = FALSE; - unsigned int tmp = 0; - - if(threshold) - { - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_ALIGNMENT_BETWEEN_ERROR, &tmp, - NULL); - - if(tmp != 0) - { - *threshold = tmp; - result = TRUE; - } - } - - return result; -} - -gboolean zmapWindowItemFeatureSetGetDeferred(ZMapWindowItemFeatureSetData set_data) -{ - gboolean is_deferred = FALSE; - - /* Not cached! */ - g_object_get(G_OBJECT(set_data), - ZMAPSTYLE_PROPERTY_DEFERRED, &is_deferred, - NULL); - - return is_deferred; -} - -/* As we keep a list of the item we need to delete them at times. This is actually _not_ - * used ATM (Apr 2008) as the reason it was written turned out to have a better solution - * RT# 63281. Anyway the code is here if needed. - */ -void zmapWindowItemFeatureSetFeatureRemove(ZMapWindowItemFeatureSetData item_feature_set, - ZMapFeature feature) -{ - QueueFeatureStruct queue_feature; - - queue_feature.queue = item_feature_set->user_hidden_stack; - queue_feature.feature = feature; - /* user_hidden_stack is a copy of the list in focus. We need to - * remove items when they get destroyed */ - g_queue_foreach(queue_feature.queue, queueRemoveFromList, &queue_feature); - - return ; -} - - -ZMapWindowItemFeatureSetData zmapWindowItemFeatureSetDestroy(ZMapWindowItemFeatureSetData item_feature_set) -{ - g_object_unref(G_OBJECT(item_feature_set)); - - item_feature_set = NULL; - - return item_feature_set; -} - -/* This function is written the wrong way round. It should be - * re-written, along with extract_value_from_style_table so that - * this function is part of utils and extract_value_from_style_table - * calls it. It wouldn't need to be here then! */ -gboolean zmapWindowStyleListGetSetting(GList *list_of_styles, - char *setting_name, - GValue *value_in_out) -{ - GList *list; - gboolean result = FALSE; - - if(value_in_out && (list = g_list_first(list_of_styles))) - { - ItemFeatureValueDataStruct value_data = {}; - GObjectClass *object_class; - GParamSpec *param_spec; - - object_class = g_type_class_peek(ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET); - - if((param_spec = g_object_class_find_property(object_class, setting_name))) - { - value_data.param_id = param_spec->param_id; - value_data.spec_name = setting_name; - value_data.gvalue = value_in_out; - - result = TRUE; - - do - { - ZMapFeatureTypeStyle style; - GQuark unique_id; - - style = ZMAP_FEATURE_STYLE(list->data); - unique_id = zMapStyleGetUniqueID(style); - extract_value_from_style_table(GINT_TO_POINTER(unique_id), style, &value_data); - } - while((list = g_list_next(list))); - } - } - - return result; -} - - -/* Object code */ -static void zmap_window_item_feature_set_class_init(ZMapWindowItemFeatureSetDataClass set_data_class) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *)set_data_class; - - gobject_class->set_property = zmap_window_item_feature_set_set_property; - gobject_class->get_property = zmap_window_item_feature_set_get_property; - - parent_class_G = g_type_class_peek_parent(set_data_class); - - /* width */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_WIDTH, - g_param_spec_double(ZMAPSTYLE_PROPERTY_WIDTH, - ZMAPSTYLE_PROPERTY_WIDTH, - "The minimum width the column should be displayed at.", - 0.0, 32000.00, 16.0, - ZMAP_PARAM_STATIC_RO)); - /* Bump spacing */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_BUMP_SPACING, - g_param_spec_double(ZMAPSTYLE_PROPERTY_BUMP_SPACING, - ZMAPSTYLE_PROPERTY_BUMP_SPACING, - "The x coord spacing between features when bumping.", - 0.0, 32000.00, 1.0, - ZMAP_PARAM_STATIC_RO)); - /* display mode */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_VISIBLE, - g_param_spec_uint(ZMAPSTYLE_PROPERTY_DISPLAY_MODE, - ZMAPSTYLE_PROPERTY_DISPLAY_MODE, - "[ hide | show_hide | show ]", - ZMAPSTYLE_COLDISPLAY_INVALID, - ZMAPSTYLE_COLDISPLAY_SHOW, - ZMAPSTYLE_COLDISPLAY_INVALID, - ZMAP_PARAM_STATIC_RO)); - - /* bump mode */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_BUMP_MODE, - g_param_spec_uint(ZMAPSTYLE_PROPERTY_BUMP_MODE, - ZMAPSTYLE_PROPERTY_BUMP_MODE, - "The Bump Mode", - ZMAPBUMP_INVALID, - ZMAPBUMP_END, - ZMAPBUMP_INVALID, - ZMAP_PARAM_STATIC_RO)); - /* bump default */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_DEFAULT_BUMP_MODE, - g_param_spec_uint(ZMAPSTYLE_PROPERTY_DEFAULT_BUMP_MODE, - ZMAPSTYLE_PROPERTY_DEFAULT_BUMP_MODE, - "The Default Bump Mode", - ZMAPBUMP_INVALID, - ZMAPBUMP_END, - ZMAPBUMP_INVALID, - ZMAP_PARAM_STATIC_RO)); - /* bump default */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_JOIN_ALIGNS, - g_param_spec_uint(ZMAPSTYLE_PROPERTY_ALIGNMENT_BETWEEN_ERROR, - ZMAPSTYLE_PROPERTY_ALIGNMENT_BETWEEN_ERROR, - "match threshold", - 0, 1000, 0, - ZMAP_PARAM_STATIC_RO)); - /* Frame mode */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_FRAME_MODE, - g_param_spec_uint(ZMAPSTYLE_PROPERTY_FRAME_MODE, - "3 frame display mode", - "Defines frame sensitive display in 3 frame mode.", - ZMAPSTYLE_3_FRAME_INVALID, - ZMAPSTYLE_3_FRAME_ONLY_1, - ZMAPSTYLE_3_FRAME_INVALID, - ZMAP_PARAM_STATIC_RO)); - - /* Strand specific */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_STRAND_SPECIFIC, - g_param_spec_boolean(ZMAPSTYLE_PROPERTY_STRAND_SPECIFIC, - "Strand specific", - "Defines strand sensitive display.", - TRUE, ZMAP_PARAM_STATIC_RO)); - - /* Show when empty */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_SHOW_WHEN_EMPTY, - g_param_spec_boolean(ZMAPSTYLE_PROPERTY_SHOW_WHEN_EMPTY, - ZMAPSTYLE_PROPERTY_SHOW_WHEN_EMPTY, - "Does the Style get shown when empty", - TRUE, ZMAP_PARAM_STATIC_RO)); - - /* Deferred */ - g_object_class_install_property(gobject_class, - ITEM_FEATURE_SET_DEFERRED, - g_param_spec_boolean(ZMAPSTYLE_PROPERTY_DEFERRED, - ZMAPSTYLE_PROPERTY_DEFERRED, - "Is this deferred", - FALSE, ZMAP_PARAM_STATIC_RO)); - - - gobject_class->dispose = zmap_window_item_feature_set_dispose; - gobject_class->finalize = zmap_window_item_feature_set_finalize; - - return ; -} - -static void zmap_window_item_feature_set_init(ZMapWindowItemFeatureSetData set_data) -{ - - set_data->style_table = zmapWindowStyleTableCreate(); - set_data->user_hidden_stack = g_queue_new(); - - return ; -} - -static void zmap_window_item_feature_set_set_property(GObject *gobject, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - - switch(param_id) - { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec); - break; - } - - return ; -} - -static void zmap_window_item_feature_set_get_property(GObject *gobject, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - ZMapWindowItemFeatureSetData set_data; - - set_data = ZMAP_WINDOW_ITEM_FEATURE_SET(gobject); - - switch(param_id) - { - case ITEM_FEATURE_SET_BUMP_SPACING: - case ITEM_FEATURE_SET_WIDTH: - case ITEM_FEATURE_SET_VISIBLE: - case ITEM_FEATURE_SET_BUMP_MODE: - case ITEM_FEATURE_SET_DEFAULT_BUMP_MODE: - case ITEM_FEATURE_SET_FRAME_MODE: - case ITEM_FEATURE_SET_SHOW_WHEN_EMPTY: - case ITEM_FEATURE_SET_DEFERRED: - case ITEM_FEATURE_SET_STRAND_SPECIFIC: - case ITEM_FEATURE_SET_JOIN_ALIGNS: - { - ItemFeatureValueDataStruct value_data = {NULL}; - - value_data.spec_name = g_param_spec_get_name(pspec); - value_data.gvalue = value; - value_data.param_id = param_id; - - g_hash_table_foreach(set_data->style_table, extract_value_from_style_table, &value_data); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, param_id, pspec); - break; - } - - return ; -} - -static void zmap_window_item_feature_set_dispose(GObject *object) -{ - ZMapWindowItemFeatureSetData set_data; - GObjectClass *gobject_class = G_OBJECT_CLASS(parent_class_G); - - set_data = ZMAP_WINDOW_ITEM_FEATURE_SET(object); - - set_data->window = NULL; /* not ours */ - - if(set_data->style_table) - { - zmapWindowStyleTableDestroy(set_data->style_table); - set_data->style_table = NULL; - } - - if(set_data->user_hidden_stack) - { - if(!g_queue_is_empty(set_data->user_hidden_stack)) - g_queue_foreach(set_data->user_hidden_stack, removeList, NULL) ; - - g_queue_free(set_data->user_hidden_stack); - - set_data->user_hidden_stack = NULL; - } - - if(gobject_class->dispose) - (*gobject_class->dispose)(object); - - return ; -} - -static void zmap_window_item_feature_set_finalize(GObject *object) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(parent_class_G); - - if(gobject_class->finalize) - (*gobject_class->finalize)(object); - - return ; -} - - -/* INTERNAL */ - -static void extract_value_from_style_table(gpointer key, gpointer value, gpointer user_data) -{ - ItemFeatureValueData value_data; - ZMapFeatureTypeStyle style; - GQuark style_id; - - style_id = GPOINTER_TO_INT(key); - style = ZMAP_FEATURE_STYLE(value); - value_data = (ItemFeatureValueData)user_data; - - switch(value_data->param_id) - { - case ITEM_FEATURE_SET_BUMP_SPACING: - case ITEM_FEATURE_SET_WIDTH: - { - double tmp_width, style_width; - - tmp_width = g_value_get_double(value_data->gvalue); - - g_object_get(G_OBJECT(style), - value_data->spec_name, &style_width, - NULL); - - if(style_width > tmp_width) - g_value_set_double(value_data->gvalue, style_width); - } - break; - case ITEM_FEATURE_SET_STRAND_SPECIFIC: - case ITEM_FEATURE_SET_SHOW_WHEN_EMPTY: - case ITEM_FEATURE_SET_DEFERRED: - { - gboolean style_version = FALSE, current; - - current = g_value_get_boolean(value_data->gvalue); - - if(!current) - { - g_object_get(G_OBJECT(style), - value_data->spec_name, &style_version, - NULL); - - if(style_version) - g_value_set_boolean(value_data->gvalue, style_version); - } - } - break; - case ITEM_FEATURE_SET_FRAME_MODE: - case ITEM_FEATURE_SET_VISIBLE: - case ITEM_FEATURE_SET_BUMP_MODE: - case ITEM_FEATURE_SET_DEFAULT_BUMP_MODE: - { - guint style_version = 0, current; - - current = g_value_get_uint(value_data->gvalue); - - if(!current) - { - g_object_get(G_OBJECT(style), - value_data->spec_name, &style_version, - NULL); - - if(style_version) - g_value_set_uint(value_data->gvalue, style_version); - } - } - break; - case ITEM_FEATURE_SET_JOIN_ALIGNS: - { - guint style_version = 0, current; - - current = g_value_get_uint(value_data->gvalue); - - if(!current) - { - if(zMapStyleGetJoinAligns(style, &style_version)) - { - g_value_set_uint(value_data->gvalue, style_version); - } - } - } - break; - default: - break; - } - - return ; -} - -static void reset_bump_mode_cb(gpointer key, gpointer value, gpointer user_data) -{ - ZMapFeatureTypeStyle style; - - style = ZMAP_FEATURE_STYLE(value); - - zMapStyleResetBumpMode(style); - - extract_value_from_style_table(key, value, user_data); - - return ; -} - -static void removeList(gpointer data, gpointer user_data_unused) -{ - GList *user_hidden_items = (GList *)data ; - - g_list_free(user_hidden_items) ; - - return ; -} - -static void queueRemoveFromList(gpointer queue_data, gpointer user_data) -{ - GList *item_list = (GList *)queue_data; - QueueFeature queue_feature = (QueueFeature)user_data; - ListFeatureStruct list_feature; - - list_feature.list = item_list; - list_feature.feature = (ZMapFeature)queue_feature->feature; - - g_list_foreach(item_list, listRemoveFromList, &list_feature); - - if(list_feature.list != item_list) - zmap_g_queue_replace(queue_feature->queue, item_list, list_feature.list); - - return; -} - - - -static void listRemoveFromList(gpointer list_data, gpointer user_data) -{ - ListFeature list_feature = (ListFeature)user_data; - ZMapFeature item_feature; - FooCanvasItem *item; - - zMapAssert(FOO_IS_CANVAS_ITEM(list_data)); - - item = FOO_CANVAS_ITEM(list_data); - item_feature = g_object_get_data(G_OBJECT(item), ITEM_FEATURE_DATA); - zMapAssert(item_feature); - - if(item_feature == list_feature->feature) - list_feature->list = g_list_remove(list_feature->list, item); - - return ; -} - -static void zmap_g_queue_replace(GQueue *queue, gpointer old, gpointer new) -{ - int length, index; - - if((length = g_queue_get_length(queue))) - { - if((index = g_queue_index(queue, old)) != -1) - { - gpointer popped = g_queue_pop_nth(queue, index); - zMapAssert(popped == old); - g_queue_push_nth(queue, new, index); - } - } - else - g_queue_push_head(queue, new); - - return ; -} diff --git a/src/zmapWindow/zmapWindowItemFeatureSet.h b/src/zmapWindow/zmapWindowItemFeatureSet.h deleted file mode 100755 index 878d2fb69..000000000 --- a/src/zmapWindow/zmapWindowItemFeatureSet.h +++ /dev/null @@ -1,119 +0,0 @@ -/* File: zmapWindowItemFeatureSet.h - * Author: Roy Storey (rds@sanger.ac.uk) - * Copyright (c) 2009: Genome Research Ltd. - *------------------------------------------------------------------- - * ZMap is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt - *------------------------------------------------------------------- - * This file is part of the ZMap genome database package - * originally written by: - * - * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, - * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk - * - * Description: - * - * Exported functions: See XXXXXXXXXXXXX.h - * HISTORY: - * Last edited: May 7 22:36 2009 (rds) - * Created: Fri Feb 6 15:32:46 2009 (rds) - * CVS info: $Id: zmapWindowItemFeatureSet.h,v 1.10 2009-05-07 21:36:12 rds Exp $ - *------------------------------------------------------------------- - */ - -#ifndef __ZMAP_WINDOW_ITEM_FEATURE_SET_H__ -#define __ZMAP_WINDOW_ITEM_FEATURE_SET_H__ - -#include <glib.h> -#include <glib-object.h> - - -#define ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET (zmapWindowItemFeatureSetGetType()) -#define ZMAP_WINDOW_ITEM_FEATURE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET, zmapWindowItemFeatureSetData)) -#define ZMAP_WINDOW_ITEM_FEATURE_SET_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET, zmapWindowItemFeatureSetData const)) -#define ZMAP_WINDOW_ITEM_FEATURE_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET, zmapWindowItemFeatureSetDataClass)) -#define ZMAP_IS_WINDOW_ITEM_FEATURE_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET) || zmap_g_return_moan(__FILE__, __LINE__) ) -#define ZMAP_WINDOW_ITEM_FEATURE_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ZMAP_TYPE_WINDOW_ITEM_FEATURE_SET, zmapWindowItemFeatureSetDataClass)) - - -/* Instance */ -typedef struct _zmapWindowItemFeatureSetDataStruct zmapWindowItemFeatureSetData, *ZMapWindowItemFeatureSetData; - -/* Class */ -typedef struct _zmapWindowItemFeatureSetDataClassStruct zmapWindowItemFeatureSetDataClass, *ZMapWindowItemFeatureSetDataClass ; - - -gboolean zmap_g_return_moan(char *file, int line); - - -/* Public funcs */ -GType zmapWindowItemFeatureSetGetType(void); - - -ZMapWindowItemFeatureSetData zmapWindowItemFeatureSetCreate(ZMapWindow window, - FooCanvasGroup *column_container, - GQuark feature_set_unique_id, - GQuark feature_set_original_id, - GList *style_list, - ZMapStrand strand, - ZMapFrame frame); - -void zmapWindowItemFeatureSetAttachFeatureSet(ZMapWindowItemFeatureSetData set_data, - ZMapFeatureSet feature_set_to_attach); -ZMapFeatureSet zmapWindowItemFeatureSetRecoverFeatureSet(ZMapWindowItemFeatureSetData set_data); -//ZMapWindowStats zmapWindowItemFeatureSetRecoverStats(ZMapWindowItemFeatureSetData set_data); -ZMapFeatureTypeStyle zmapWindowItemFeatureSetStyleFromStyle(ZMapWindowItemFeatureSetData set_data, - ZMapFeatureTypeStyle style2copy); -ZMapFeatureTypeStyle zmapWindowItemFeatureSetStyleFromID(ZMapWindowItemFeatureSetData set_data, - GQuark style_unique_id); -GQuark zmapWindowItemFeatureSetColumnDisplayName(ZMapWindowItemFeatureSetData set_data); -ZMapWindow zmapWindowItemFeatureSetGetWindow(ZMapWindowItemFeatureSetData set_data); -ZMapStrand zmapWindowItemFeatureSetGetStrand(ZMapWindowItemFeatureSetData set_data); -ZMapFrame zmapWindowItemFeatureSetGetFrame (ZMapWindowItemFeatureSetData set_data); - -ZMapFeatureTypeStyle zmapWindowItemFeatureSetGetStyle(ZMapWindowItemFeatureSetData set_data, - ZMapFeature feature); - - -double zmapWindowItemFeatureSetGetWidth(ZMapWindowItemFeatureSetData set_data); -double zmapWindowItemFeatureGetBumpSpacing(ZMapWindowItemFeatureSetData set_data); - -gboolean zmapWindowItemFeatureSetGetMagValues(ZMapWindowItemFeatureSetData set_data, - double *min_mag_out, double *max_mag_out); - -ZMapStyleColumnDisplayState zmapWindowItemFeatureSetGetDisplay(ZMapWindowItemFeatureSetData set_data); -void zmapWindowItemFeatureSetDisplay(ZMapWindowItemFeatureSetData set_data, ZMapStyleColumnDisplayState state); - -gboolean zmapWindowItemFeatureSetShowWhenEmpty(ZMapWindowItemFeatureSetData set_data); -ZMapStyle3FrameMode zmapWindowItemFeatureSetGetFrameMode(ZMapWindowItemFeatureSetData set_data); -gboolean zmapWindowItemFeatureSetIsFrameSpecific(ZMapWindowItemFeatureSetData set_data, - ZMapStyle3FrameMode *frame_mode_out); -gboolean zmapWindowItemFeatureSetIsStrandSpecific(ZMapWindowItemFeatureSetData set_data); -ZMapStyleBumpMode zmapWindowItemFeatureSetGetBumpMode(ZMapWindowItemFeatureSetData set_data); -ZMapStyleBumpMode zmapWindowItemFeatureSetGetDefaultBumpMode(ZMapWindowItemFeatureSetData set_data); -ZMapStyleBumpMode zmapWindowItemFeatureSetResetBumpModes(ZMapWindowItemFeatureSetData set_data); -gboolean zmapWindowItemFeatureSetJoinAligns(ZMapWindowItemFeatureSetData set_data, unsigned int *threshold); -gboolean zmapWindowItemFeatureSetGetDeferred(ZMapWindowItemFeatureSetData set_data); -void zmapWindowItemFeatureSetFeatureRemove(ZMapWindowItemFeatureSetData item_feature_set, - ZMapFeature feature); - -ZMapWindowItemFeatureSetData zmapWindowItemFeatureSetDestroy(ZMapWindowItemFeatureSetData item_feature_set); - -gboolean zmapWindowStyleListGetSetting(GList *list_of_styles, - char *setting_name, - GValue *value_in_out); - - -#endif /* __ZMAP_WINDOW_ITEM_FEATURE_SET_H__ */ diff --git a/src/zmapWindow/zmapWindowItemFeatureSet_I.h b/src/zmapWindow/zmapWindowItemFeatureSet_I.h deleted file mode 100755 index 513bf50c9..000000000 --- a/src/zmapWindow/zmapWindowItemFeatureSet_I.h +++ /dev/null @@ -1,108 +0,0 @@ -/* File: zmapWindowItemFeatureSet_I.h - * Author: Roy Storey (rds@sanger.ac.uk) - * Copyright (c) 2009: Genome Research Ltd. - *------------------------------------------------------------------- - * ZMap is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt - *------------------------------------------------------------------- - * This file is part of the ZMap genome database package - * originally written by: - * - * Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk, - * Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk - * - * Description: - * - * Exported functions: See XXXXXXXXXXXXX.h - * HISTORY: - * Last edited: Apr 27 11:46 2009 (edgrif) - * Created: Fri Feb 6 11:49:03 2009 (rds) - * CVS info: $Id: zmapWindowItemFeatureSet_I.h,v 1.7 2009-04-28 14:33:41 edgrif Exp $ - *------------------------------------------------------------------- - */ - -#ifndef __ZMAP_WINDOW_ITEM_FEATURE_SET_I_H__ -#define __ZMAP_WINDOW_ITEM_FEATURE_SET_I_H__ - -#include <ZMap/zmapStyle.h> -#include <zmapWindow_P.h> -#include <zmapWindowItemFeatureSet.h> - -#define ZMAP_PARAM_STATIC (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) -#define ZMAP_PARAM_STATIC_RW (ZMAP_PARAM_STATIC | G_PARAM_READWRITE) -#define ZMAP_PARAM_STATIC_RO (ZMAP_PARAM_STATIC | G_PARAM_READABLE) - - - -typedef struct _zmapWindowItemFeatureSetDataStruct -{ - GObject __parent__; - - ZMapWindow window; - ZMapStrand strand ; - ZMapFrame frame ; - GHashTable *style_table ; - - FooCanvasGroup *column_container; - - //GQuark style_id; - GQuark unique_id; - - /* We keep the features sorted by position and size so we can cursor through them... */ - gboolean sorted ; - - /* Features hidden by user, should stay hidden. */ - GQueue *user_hidden_stack ; - - /* These fields are used for some of the more exotic column bumping. */ - gboolean hidden_bump_features ; /* Features were hidden because they - * are out of the marked range. */ - GList *extra_items ; /* Match backgrounds etc. */ - - GList *gaps_added_items ; /* List of features where gap data was added. */ - - struct - { - unsigned int frame_mode : 1; - unsigned int frame_specific : 1; - unsigned int display_state : 1; - unsigned int show_when_empty : 1; - }lazy_loaded; - - struct - { - gboolean has_feature_set; - gboolean has_stats; - gboolean show_when_empty; - gboolean frame_specific; - gboolean strand_specific; - ZMapStyle3FrameMode frame_mode; - ZMapStyleColumnDisplayState display_state; - ZMapStyleBumpMode bump_mode; - ZMapStyleBumpMode default_bump_mode; - }settings; - -} zmapWindowItemFeatureSetDataStruct; - - -typedef struct _zmapWindowItemFeatureSetDataClassStruct -{ - GObjectClass __parent__; - -} zmapWindowItemFeatureSetDataClassStruct; - - - -#endif /* __ZMAP_WINDOW_ITEM_FEATURE_SET_I_H__ */ -- GitLab