From 722bc213ab1c89f7678153304e625badb3403e4d Mon Sep 17 00:00:00 2001
From: edgrif <edgrif>
Date: Fri, 2 Nov 2007 09:36:13 +0000
Subject: [PATCH] add 'r' keyboard shortbut for reverse complement.

---
 src/include/ZMap/zmapWindow.h | 30 ++++++++++++++++++++++-----
 src/zmapView/zmapView.c       | 20 ++++++++++++++++--
 src/zmapWindow/zmapWindow.c   | 39 +++++++++++++++++++++++++----------
 3 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/src/include/ZMap/zmapWindow.h b/src/include/ZMap/zmapWindow.h
index 4cae372ec..46b269fde 100755
--- a/src/include/ZMap/zmapWindow.h
+++ b/src/include/ZMap/zmapWindow.h
@@ -26,9 +26,9 @@
  *              window displaying genome data.
  *              
  * HISTORY:
- * Last edited: Oct 15 15:31 2007 (rds)
+ * Last edited: Nov  2 08:31 2007 (edgrif)
  * Created: Thu Jul 24 15:21:56 2003 (edgrif)
- * CVS info:   $Id: zmapWindow.h,v 1.91 2007-10-15 14:32:18 rds Exp $
+ * CVS info:   $Id: zmapWindow.h,v 1.92 2007-11-02 09:36:13 edgrif Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_WINDOW_H
@@ -132,12 +132,20 @@ typedef struct
 
 
 
-/* Data returned by the "command" callback, note all command structs must start with the
- * CommandAny fields. */
+/* 
+ * THIS IS GOING BACK TO HOW I ORIGINALLY ENVISAGED THE CALLBACK SYSTEM WHICH WAS AS A COMMAND
+ * FIELD FOLLOWED BY DIFFERENT INFO. STRUCTS...I.E. LIKE THE SIGNAL INTERFACE OF GTK ETC...
+ * 
+ * Data returned by the "command" callback, note all command structs must start with the
+ * CommandAny fields.
+ * 
+ */
+
 typedef enum
   {
     ZMAPWINDOW_CMD_INVALID,
-    ZMAPWINDOW_CMD_SHOWALIGN
+    ZMAPWINDOW_CMD_SHOWALIGN,
+    ZMAPWINDOW_CMD_REVERSECOMPLEMENT
   } ZMapWindowCommandType ;
 
 
@@ -146,6 +154,7 @@ typedef struct
   ZMapWindowCommandType cmd ;
 } ZMapWindowCallbackCommandAnyStruct, *ZMapWindowCallbackCommandAny ;
 
+
 /* Call an alignment display program for the given alignment feature. */
 typedef struct
 {
@@ -154,6 +163,17 @@ typedef struct
 } ZMapWindowCallbackCommandAlignStruct, *ZMapWindowCallbackCommandAlign ;
 
 
+/* No extra data needed for rev. comp. */
+typedef struct
+{
+  ZMapWindowCommandType cmd ;
+} ZMapWindowCallbackCommandRevCompStruct, *ZMapWindowCallbackCommandRevComp ;
+
+
+
+
+
+
 
 /* Callback functions that can be registered with ZMapWindow, functions are registered all in one.
  * go via the ZMapWindowCallbacksStruct. */
diff --git a/src/zmapView/zmapView.c b/src/zmapView/zmapView.c
index 0a37661c3..98ac421ad 100755
--- a/src/zmapView/zmapView.c
+++ b/src/zmapView/zmapView.c
@@ -25,9 +25,9 @@
  * Description: 
  * Exported functions: See ZMap/zmapView.h
  * HISTORY:
- * Last edited: Oct  9 15:00 2007 (edgrif)
+ * Last edited: Nov  2 09:16 2007 (edgrif)
  * Created: Thu May 13 15:28:26 2004 (edgrif)
- * CVS info:   $Id: zmapView.c,v 1.124 2007-10-12 10:39:13 edgrif Exp $
+ * CVS info:   $Id: zmapView.c,v 1.125 2007-11-02 09:36:13 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -2358,6 +2358,22 @@ static void commandCB(ZMapWindow window, void *caller_data, void *window_data)
 	      view->spawned_processes = g_list_append(view->spawned_processes, GINT_TO_POINTER(blixem_pid)) ;
 	  }
 
+	break ;
+      }
+    case ZMAPWINDOW_CMD_REVERSECOMPLEMENT:
+      {
+	gboolean status ;
+	ZMapView view = view_window->parent_view ;
+
+	/* NOTE, there is no need to signal the layer above that things are changing,
+	 * the layer above does the complement and handles all that. */
+	if (!(status = zMapViewReverseComplement(view)))
+	  {
+	    zMapLogCritical("%s", "View Reverse Complement failed.") ;
+
+	    zMapWarning("%s", "View Reverse Complement failed.") ;
+	  }
+
 	break ;
       }
     default:
diff --git a/src/zmapWindow/zmapWindow.c b/src/zmapWindow/zmapWindow.c
index d44c9dbdc..0f2c68647 100755
--- a/src/zmapWindow/zmapWindow.c
+++ b/src/zmapWindow/zmapWindow.c
@@ -19,16 +19,16 @@
  * This file is part of the ZMap genome database package
  * and was written by
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk and
- *      Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
+ *      Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk
  *
  * Description: Provides interface functions for controlling a data
  *              display window.
  *              
  * Exported functions: See ZMap/zmapWindow.h
  * HISTORY:
- * Last edited: Oct 31 10:13 2007 (edgrif)
+ * Last edited: Nov  2 09:16 2007 (edgrif)
  * Created: Thu Jul 24 14:36:27 2003 (edgrif)
- * CVS info:   $Id: zmapWindow.c,v 1.208 2007-11-01 14:59:05 edgrif Exp $
+ * CVS info:   $Id: zmapWindow.c,v 1.209 2007-11-02 09:36:13 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -195,7 +195,7 @@ static void popUpMenu(GdkEventKey *key_event, ZMapWindow window, FooCanvasItem *
 
 static void printStats(FooCanvasGroup *container_parent, FooCanvasPoints *points, 
                        ZMapContainerLevelType level, gpointer user_data) ;
-
+static void revCompRequest(ZMapWindow window) ;
 
 
 
@@ -3227,13 +3227,6 @@ static gboolean keyboardEvent(ZMapWindow window, GdkEventKey *key_event)
       put dna on ....;
 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
 
-#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
-      /* There is an issue with this...it needs to happen at the view level really so that all
-       * windows for a view get redrawn so we need to signal back to view for this one. */
-    case GDK_r:
-      reversecomp ;
-#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
-
     case GDK_h:
       {
 	/* Flip flop highlighting.... */
@@ -3397,6 +3390,13 @@ static gboolean keyboardEvent(ZMapWindow window, GdkEventKey *key_event)
 	break ;
       }
 
+    case GDK_r:
+      {
+	revCompRequest(window) ;
+
+	break ;
+      }
+
     case GDK_u:
     case GDK_U:
       {
@@ -4319,3 +4319,20 @@ static void printStats(FooCanvasGroup *container_parent, FooCanvasPoints *points
   return ;
 }
 
+
+
+/* Called when user presses a short cut key, problematic because actually its the layer
+ * above that needs to do the reverse complement. */
+static void revCompRequest(ZMapWindow window)
+{
+  ZMapWindowCallbackCommandRevCompStruct rev_comp ;
+  ZMapWindowCallbacks window_cbs_G = zmapWindowGetCBs() ;
+
+  rev_comp.cmd = ZMAPWINDOW_CMD_REVERSECOMPLEMENT ;
+
+  (*(window_cbs_G->command))(window, window->app_data, &rev_comp) ;
+
+  return ;
+}
+
+
-- 
GitLab