From 33d5a8be6a5bbeb6ff5f784005687f2713450b4e Mon Sep 17 00:00:00 2001
From: mh17 <mh17>
Date: Tue, 19 Jan 2010 12:36:53 +0000
Subject: [PATCH] unsorted featuresets on new feature added to try to fix
 overlap bug - displayed format is now stable from first display. Difficult to
 test as cannot create overlap on demand

---
 src/zmapFeature/zmapFeature.c                   |  9 ++++++---
 .../items/zmapWindowContainerFeatureSet.c       | 16 +++++++++++++++-
 .../items/zmapWindowContainerFeatureSet.h       |  4 +++-
 src/zmapWindow/items/zmapWindowContainerUtils.c | 12 +++++++++++-
 src/zmapWindow/zmapWindowItem.c                 | 17 +++++++++++++----
 5 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/src/zmapFeature/zmapFeature.c b/src/zmapFeature/zmapFeature.c
index ccd9c847c..6c0f1e793 100755
--- a/src/zmapFeature/zmapFeature.c
+++ b/src/zmapFeature/zmapFeature.c
@@ -29,7 +29,7 @@
  * HISTORY:
  * Last edited: Dec 14 11:20 2009 (edgrif)
  * Created: Fri Jul 16 13:05:58 2004 (edgrif)
- * CVS info:   $Id: zmapFeature.c,v 1.119 2009-12-16 10:54:35 edgrif Exp $
+ * CVS info:   $Id: zmapFeature.c,v 1.120 2010-01-19 12:36:53 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -2275,7 +2275,9 @@ static ZMapFeatureContextExecuteStatus mergePreCB(GQuark key,
 
 		featureAnyAddToDestroyList(merge_data->diff_context, diff_feature_any);
 	      }
-
+            // mh17: 
+            // 1) featureAnyAddFeature checks to see if it's there first, which we just did :-(
+            // 2) look at the comment 25 lines above about not using featureAnyAddFeature
 	    featureAnyAddFeature(*diff_path_parent_ptr, diff_feature_any);
 
 	    /* update the path */
@@ -2285,6 +2287,7 @@ static ZMapFeatureContextExecuteStatus mergePreCB(GQuark key,
 	    if(new)
 	      (*diff_path_ptr)->parent = *view_path_parent_ptr;
 
+
 	    if (feature_any->struct_type == ZMAPFEATURE_STRUCT_BLOCK &&
 		(*view_path_ptr)->unique_id == feature_any->unique_id)
 	      {
@@ -2294,7 +2297,7 @@ static ZMapFeatureContextExecuteStatus mergePreCB(GQuark key,
 	  }
 
 	/* general code stop */
-
+      
 
 #ifdef NO_IDEA_WHAT_SHOULD_HAPPEN_HERE
 	/* possibly nothing... unsure where the master alignment status [will] comes from. */
diff --git a/src/zmapWindow/items/zmapWindowContainerFeatureSet.c b/src/zmapWindow/items/zmapWindowContainerFeatureSet.c
index f17447185..0c300c075 100755
--- a/src/zmapWindow/items/zmapWindowContainerFeatureSet.c
+++ b/src/zmapWindow/items/zmapWindowContainerFeatureSet.c
@@ -29,7 +29,7 @@
  * HISTORY:
  * Last edited: Oct 27 11:53 2009 (edgrif)
  * Created: Mon Jul 30 13:09:33 2007 (rds)
- * CVS info:   $Id: zmapWindowContainerFeatureSet.c,v 1.15 2010-01-19 06:29:59 rds Exp $
+ * CVS info:   $Id: zmapWindowContainerFeatureSet.c,v 1.16 2010-01-19 12:36:53 mh17 Exp $
  *-------------------------------------------------------------------
  */
 #include <string.h>		/* memset */
@@ -979,6 +979,20 @@ void zmapWindowContainerFeatureSetSortFeatures(ZMapWindowContainerFeatureSet con
   return ;
 }
 
+/*!
+ * \brief Unset the sorted flag for the featureset to force a re-sort on display eg after adding a feature
+ *
+ * \param container  The container to be sorted
+ *
+ * \return nothing
+ */
+
+void zMapWindowContainerFeatureSetMarkUnsorted(ZMapWindowContainerFeatureSet container_set)
+{
+      container_set->sorted = FALSE;
+}
+
+
 /*!
  * \brief Time to free the memory associated with the ZMapWindowContainerFeatureSet.
  * 
diff --git a/src/zmapWindow/items/zmapWindowContainerFeatureSet.h b/src/zmapWindow/items/zmapWindowContainerFeatureSet.h
index e7a1218ea..c4bf74fe1 100755
--- a/src/zmapWindow/items/zmapWindowContainerFeatureSet.h
+++ b/src/zmapWindow/items/zmapWindowContainerFeatureSet.h
@@ -29,7 +29,7 @@
  * HISTORY:
  * Last edited: Nov  6 17:59 2009 (edgrif)
  * Created: Wed Dec  3 08:21:03 2008 (rds)
- * CVS info:   $Id: zmapWindowContainerFeatureSet.h,v 1.7 2009-12-15 13:49:12 mh17 Exp $
+ * CVS info:   $Id: zmapWindowContainerFeatureSet.h,v 1.8 2010-01-19 12:36:53 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -123,6 +123,8 @@ void zmapWindowContainerFeatureSetRemoveAllItems(ZMapWindowContainerFeatureSet c
 
 void zmapWindowContainerFeatureSetSortFeatures(ZMapWindowContainerFeatureSet container_set, 
 					       gint direction);
+                                     
+void zMapWindowContainerFeatureSetMarkUnsorted(ZMapWindowContainerFeatureSet container_set);
 
 /* Finished with this container */
 ZMapWindowContainerFeatureSet zMapWindowContainerFeatureSetDestroy(ZMapWindowContainerFeatureSet canvas_item);
diff --git a/src/zmapWindow/items/zmapWindowContainerUtils.c b/src/zmapWindow/items/zmapWindowContainerUtils.c
index e07672a84..929431157 100755
--- a/src/zmapWindow/items/zmapWindowContainerUtils.c
+++ b/src/zmapWindow/items/zmapWindowContainerUtils.c
@@ -29,7 +29,7 @@
  * HISTORY:
  * Last edited: Oct 16 14:41 2009 (edgrif)
  * Created: Tue Apr 28 16:10:46 2009 (rds)
- * CVS info:   $Id: zmapWindowContainerUtils.c,v 1.7 2009-10-16 13:41:38 edgrif Exp $
+ * CVS info:   $Id: zmapWindowContainerUtils.c,v 1.8 2010-01-19 12:36:53 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -872,3 +872,13 @@ static void set_column_lists_cb(ZMapWindowContainerGroup container, FooCanvasPoi
 }
 
 
+// debugging for WindowItem.c here due to private headers
+char *group_foo_info(ZMapWindowContainerGroup container)
+{
+      static char buf[512];         // quick bo9dge function not thread safe
+      FooCanvasItem *foo = &container->__parent__.item;
+      
+      sprintf(buf,"type %d, box (%s) %f %f %f %f",container->feature_any->struct_type,
+            (FOO_CANVAS_ITEM_GET_CLASS (foo)->bounds) ? "Y" : "N",foo->x1,foo->y1,foo->x2,foo->y2);
+      return(buf);
+}
diff --git a/src/zmapWindow/zmapWindowItem.c b/src/zmapWindow/zmapWindowItem.c
index 5f79b9efd..4ee2796b9 100755
--- a/src/zmapWindow/zmapWindowItem.c
+++ b/src/zmapWindow/zmapWindowItem.c
@@ -28,7 +28,7 @@
  * HISTORY:
  * Last edited: Jan 13 13:49 2010 (edgrif)
  * Created: Thu Sep  8 10:37:24 2005 (edgrif)
- * CVS info:   $Id: zmapWindowItem.c,v 1.121 2010-01-14 09:05:10 edgrif Exp $
+ * CVS info:   $Id: zmapWindowItem.c,v 1.122 2010-01-19 12:36:54 mh17 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -1439,9 +1439,10 @@ gboolean zmapWindowWorld2SeqCoords(ZMapWindow window,
       FooCanvasGroup *block_container ;
       ZMapFeatureBlock block ;
       
+zMapLogWarning("got foo item at %f %f %f %f",wx1,wy1,wx2,wy2);
       /* Getting the block struct as well is a bit belt and braces...we could return it but
        * its redundant info. really. */
-      if ((block_container = zmapWindowContainerUtilsItemGetParentLevel(item, ZMAPCONTAINER_LEVEL_BLOCK))
+      if ((block_container = FOO_CANVAS_GROUP(zmapWindowContainerUtilsItemGetParentLevel(item, ZMAPCONTAINER_LEVEL_BLOCK)))
 	  && (block = zmapWindowItemGetFeatureBlock(block_container)))
 	{
 	  double offset ;
@@ -1449,6 +1450,7 @@ gboolean zmapWindowWorld2SeqCoords(ZMapWindow window,
 	  offset = (double)(block->block_to_sequence.q1 - 1) ; /* - 1 for 1 based coord system. */
 
 	  my_foo_canvas_world_bounds_to_item(FOO_CANVAS_ITEM(block_container), &wx1, &wy1, &wx2, &wy2) ;
+zMapLogWarning("%s","got block");
 
 	  if (block_grp_out)
 	    *block_grp_out = block_container ;
@@ -1471,6 +1473,7 @@ gboolean zmapWindowWorld2SeqCoords(ZMapWindow window,
       workaround_struct.wx2 = wx2;
       workaround_struct.wy1 = wy1;
       workaround_struct.wy2 = wy2;
+zMapLogWarning("Workaround %f %f %f %f",wx1,wy1,wx2,wy2);
 
       /* For some reason foo_canvas_get_item_at() fails to find items
        * a lot of the time even when it shouldn't and so we need a solution. */
@@ -1499,7 +1502,7 @@ gboolean zmapWindowWorld2SeqCoords(ZMapWindow window,
        * item's (block container background) original size. */
       workaround_struct.window = window;
 
-      zmapWindowContainerUtilsExecute(window->feature_root_group, ZMAPCONTAINER_LEVEL_BLOCK, 
+      zmapWindowContainerUtilsExecute(window->feature_root_group, ZMAPCONTAINER_LEVEL_BLOCK,
 				      fill_workaround_struct,     &workaround_struct);
 
       if((result = workaround_struct.result))
@@ -1992,6 +1995,10 @@ static void fill_workaround_struct(ZMapWindowContainerGroup container,
 				   gpointer               user_data)
 {
   get_item_at_workaround workaround = (get_item_at_workaround)user_data;
+extern char *group_foo_info(ZMapWindowContainerGroup container);
+
+if(!container) return;
+//zMapLogWarning("level %d container: %s",level,group_foo_info(container));
 
   switch(level)
     {
@@ -2041,12 +2048,14 @@ static void fill_workaround_struct(ZMapWindowContainerGroup container,
 		workaround->result = TRUE;
 	      }
 	    else
-	      zMapLogWarning("fill_workaround_struct: Area block (%f, %f), (%f, %f) "
+	      {
+                 zMapLogWarning("fill_workaround_struct: Area block (%f, %f), (%f, %f) "
 			     "workaround (%f, %f), (%f, %f) Roy needs to look at this.",
 			     area_block.x1, area_block.y1,
 			     area_block.x2, area_block.y2,
 			     workaround->wx1, workaround->wy1,
 			     workaround->wx2, workaround->wy2);
+            }
 	  }
 	
       }
-- 
GitLab