From a2e4d9abf3a425d7d469c9cac6d760f8b91322be Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Thu, 17 Jan 2008 14:15:28 +0000
Subject: [PATCH] et cursor to normal before zoom and pan callback   in case
 where user is in QC callback (pointer crosshair), action on zoom or pan
 callback   desactive QC mode but set pointer to crosshair at exit. Change
 some comment and smart ident

M    tsgqc_GUI.m
---
 tsgqc_GUI.m | 135 +++++++++-------------------------------------------
 1 file changed, 23 insertions(+), 112 deletions(-)

diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m
index 465f99a..d897b02 100644
--- a/tsgqc_GUI.m
+++ b/tsgqc_GUI.m
@@ -588,6 +588,10 @@ end
   %----------------------------------------------------------------------
   function Zoom_OnMenuCallback(hObject, eventdata)
     
+    % cursor back to normal
+    % ---------------------
+    set(hMainFig,'Pointer','arrow');
+    
     % returns a zoom mode object for the figure hMainFig handle
     % --------------------------------------------------------
     hZoom = zoom(hMainFig);
@@ -606,6 +610,7 @@ end
     % -----------------------------------------
     set(hQCToggletool,  'state', 'off' );
     set(hPanToggletool, 'state', 'off' );
+    
   end
 
   %----------------------------------------------------------------------
@@ -628,6 +633,10 @@ end
   %----------------------------------------------------------------------
   function Pan_OnMenuCallback(hObject, eventdata)
     
+    % cursor back to normal
+    % ---------------------
+    set(hMainFig,'Pointer','arrow');
+    
     % Returns a pan mode object for the figure handle
     % -----------------------------------------------
     hPan = pan(hMainFig);
@@ -664,6 +673,7 @@ end
     % cursor back to normal
     % ---------------------
     set(hMainFig,'Pointer','arrow');
+    
   end
 
   %----------------------------------------------------------------------
@@ -740,118 +750,10 @@ end
       % enable ButtonMotion on main fig after select QC area
       % ----------------------------------------------------
       set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
-
     end
+    
   end
 
-% %----------------------------------------------------------------------
-%   function QCMenuCallback_old(gcbo, eventdata,handles)
-%     % Callback function run when the QC pushbutton is selected
-% 
-%     % Desactivate the Zoom and Pan functions.
-%     % ---------------------------------------
-%     zoom off; pan off
-%     panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off');
-% 
-%     % Toggle the tag of the Qc pushbutton to 'on' or 'off'
-%     % ----------------------------------------------------
-%     switch get(hQCToggletool, 'UserData');
-%       case 'off'
-%         set(hQCToggletool, 'UserData', 'on' );
-%         set(hPlotAxes(1),'UIContextMenu', hQcCmenu);
-%         set( hMainFig, 'Pointer', 'crosshair');
-%       case 'on'
-%         set(hQCToggletool, 'UserData', 'off' );
-%         set(hPlotAxes(1),'UIContextMenu', []);
-%         set(hMainFig,'Pointer','arrow');
-%     end
-% 
-%     qualityCode = -1;
-%     ind = [];
-%     while strcmp( get(hQCToggletool, 'UserData'),'on')
-% 
-%       k = waitforbuttonpress;
-% 
-%       % If the QC pushbutton is pressed we quit the callback
-%       % ----------------------------------------------------
-%       if strcmp( get(hQCToggletool, 'UserData'),'off')
-% 
-%         % Desactivate the context menu use to choose the Quality Codes
-%         % ------------------------------------------------------------
-%         set(hQcCmenu, 'Visible', 'off');
-%         break
-%       end
-% 
-%       % Test if the right mouse button is clicked
-%       % -----------------------------------------
-%       if strcmp(get(hMainFig, 'SelectionType'), 'alt') && ~isempty(ind)
-%         % Wait for a QC Context Menu choice : The user choose the
-%         % quality code
-%         % -------------------------------------------------------
-%         uiwait
-%         qualityCode = 1;
-% 
-%       else
-% 
-%         % Mouse motion callback desactivated when a selection is made.
-%         % Otherwise there is a conflict with the map if it is activated
-%         % -------------------------------------------------------------
-%         set( hMainFig, 'UserData', 'ButtonMotionOff');
-% 
-%         % Selection of the data within the figure
-%         % ---------------------------------------
-%         point1 = get(gca,'CurrentPoint');    % button down detected
-%         finalRect = rbbox;                   % return figure units
-%         point2 = get(gca,'CurrentPoint');    % button up detected
-% 
-%         point1 = point1(1,1:2);              % extract x and y
-%         point2 = point2(1,1:2);
-% 
-%         p1 = min(point1,point2);
-%         p2 = max(point1,point2);             % calculate locations
-% 
-%         % Retrieve named application data
-%         % -------------------------------
-%         tsg = getappdata( hMainFig, 'tsg_data');
-% 
-%         ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ...
-%           tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2));
-% 
-%         % As soon as a modification took place the data should be saved
-%         % -------------------------------------------------------------
-%         set( hSaveMenu, 'UserData', 'on' );
-% 
-%         % Selection made : Mouse motion callback re-activated
-%         % --------------------------------------------------
-%         set( hMainFig, 'UserData', 'ButtonMotionOn');
-% 
-%       end
-% 
-%       % Plot the data with the color of the chosen quality Code.
-%       % Is it the right place for this source code ????
-%       % --------------------------------------------------------
-%       if qualityCode ~= -1
-% 
-%         % Retrieve named application data - Code could have been changed
-%         % --------------------------------------------------------------
-%         tsg = getappdata( hMainFig, 'tsg_data');
-% 
-%         tsg.SSPS_QC(ind) = tsg.qc.Code.ACTIVE;
-% 
-%         % Save the modifications
-%         % ----------------------
-%         setappdata( hMainFig, 'tsg_data', tsg);
-% 
-%         axes(hPlotAxes(1));
-%         hold on
-%         color = ['.' tsg.qc.Color.ACTIVE];
-%         plot(tsg.DAYD(ind), tsg.SSPS(ind), color );
-%         hold off
-% 
-%       end
-%     end
-%   end
-
   %----------------------------------------------------------------------
   % Callback function run when the QC context menu is selected
   %---------------------------------------------------------------------
@@ -872,6 +774,7 @@ end
       tsg.qc.active.Color = color;
 
       setappdata( hMainFig, 'tsg_data', tsg );
+      
   end
 
   %---------------------------------------------------------------------
@@ -949,6 +852,7 @@ end
     % Make the earth map invisible
     % ----------------------------
     set(hMapPanel, 'Visible', 'off' );   
+    
   end
 
   %---------------------------------------------------------------------
@@ -965,6 +869,7 @@ end
     % Make the earth map visible
     % --------------------------
     set(hMapPanel, 'Visible', 'on' );
+    
   end
 
   %---------------------------------------------------------------------
@@ -1049,8 +954,12 @@ end
       delete(hLine2.stdClimMinus);
       delete(hLine2.stdClimPlus);
       delete(hLine2.meanClim);
+      
+    % if handle is missing, prevent warning message on console
+    % --------------------------------------------------------
     catch
     end
+    
   end
 
   %------------------------------------------------------------------------
@@ -1175,6 +1084,7 @@ end
     % call header form function
     % -------------------------
     headerForm(hMainFig);
+    
   end
 
   % -------------------------------------------------------------------
@@ -1239,9 +1149,9 @@ end
       hdl_pushtool = findobj('Tag', 'QC');
       set(hdl_pushtool, 'Enable', 'on');
     end
+    
   end
 
-
   % -----------------------------------------------------------------
   % Callback function run when the Quit menu item is selected
   % -----------------------------------------------------------------
@@ -1297,5 +1207,6 @@ end
     
   end
 
-
-end  % end of tsgqc_GUI
+% end of tsgqc_GUI
+% ----------------
+end  
-- 
GitLab