From 255b124700e1f50c9675c042dee145a7191d37e8 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Tue, 15 Jan 2008 11:45:32 +0000
Subject: [PATCH] =?UTF-8?q?Bascule=20le=20zoom=20et=20pan=20en=20toggletoo?=
 =?UTF-8?q?l,=20le=20code=20est=20clarifi=C3=A9=20mais=20il=20faudra=20v?=
 =?UTF-8?q?=C3=A9rifier=20(et=20valider)=20le=20comportement,=20notamment?=
 =?UTF-8?q?=20lorsque=20l'outil=20est=20d=C3=A9sactive=20V=C3=A9rifier=20?=
 =?UTF-8?q?=C3=A9galement=20que=20toute=20les=20fonctionnalit=C3=A9s=20de?=
 =?UTF-8?q?=20QC=5FSelectCallback=20appel=C3=A9=20par=20QC=5FOnMenuCallbac?=
 =?UTF-8?q?k=20sont=20pr=C3=A9sentes=20=3F=20voir=20QCMenuCallback=5Fold?=
 =?UTF-8?q?=20laiss=C3=A9=20en=20commentaire=20et=20a=20supprimer=20apr?=
 =?UTF-8?q?=C3=A8s=20validation.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

J'ai rajouté 2 fonctions de tracés : plot_WS et plot_EXT qui pourront etre appelées depuis plot_SalTsgSample
---
 tsgqc_GUI.m | 158 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 92 insertions(+), 66 deletions(-)

diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m
index 72445f8..33bdf49 100644
--- a/tsgqc_GUI.m
+++ b/tsgqc_GUI.m
@@ -124,7 +124,7 @@ hSavePushtool  =   uipushtool(...   % Open Save toolbar button
   'Tag','PUSHTOOL_SAVE',...
   'Enable', 'off',...
   'ClickedCallback', @SaveMenuCallback);
-hZoomPushtool  =   uipushtool(...   % Open Zoom toolbar button
+hZoomToggletool  =   uitoggletool(...   % Open Zoom toolbar button
   'Parent',hToolbar,...
   'Separator', 'on', ...
   'TooltipString','Zoom',...
@@ -133,8 +133,9 @@ hZoomPushtool  =   uipushtool(...   % Open Zoom toolbar button
   'HandleVisibility','callback', ...
   'Tag','PUSHTOOL_ZOOM',...
   'Enable', 'off',...
-  'ClickedCallback', @ZoomMenuCallback);
-hPanPushtool  =   uipushtool(...   % Open Pan toolbar button
+  'OffCallback', @Zoom_OffMenuCallback,...
+  'ONCallback',  @Zoom_OnMenuCallback);
+hPanToggletool  =   uitoggletool(...   % Open Pan toolbar button
   'Parent',hToolbar,...
   'TooltipString','Pan',...
   'CData',iconRead(fullfile(matlabroot, ...
@@ -142,7 +143,9 @@ hPanPushtool  =   uipushtool(...   % Open Pan toolbar button
   'HandleVisibility','callback', ...
   'Tag','PUSHTOOL_PAN',...
   'Enable', 'off',...
-  'ClickedCallback', @PanMenuCallback);
+  'OffCallback', @Pan_OffMenuCallback,...
+  'ONCallback',  @Pan_OnMenuCallback);
+  %'ClickedCallback', @PanMenuCallback);
 hQCToggletool  =   uitoggletool(...   % Open QC toolbar button
   'Parent',hToolbar,...
   'TooltipString','Validation codes',...
@@ -438,8 +441,8 @@ hQcCmenuBad       = uimenu(...
   'Callback', @Qc);
 
 
-% Initialisation
-% --------------
+% Initialize tsg structure
+% ------------------------
 tsg_initialisation(hMainFig, hQcCmenu)
 
 % -------------------------
@@ -498,8 +501,8 @@ tsg_initialisation(hMainFig, hQcCmenu)
         % ---------------------------------
         set( hOpenMenu, 'UserData', 'on' );
         
-        % enable menu pushtool
-        % --------------------
+        % enable toolbar menu pushtool
+        % ----------------------------
         hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_');
         set(hdl_pushtool, 'Enable', 'on');
 
@@ -544,7 +547,8 @@ tsg_initialisation(hMainFig, hQcCmenu)
     % Maybe use a new pushbutton to draw or delete the bucket
     % -------------------------------------------------------
     if error2 ~= -1
-      plot_SalTsgSample( hMainFig, hPlotAxes );
+      plot_WS( hMainFig, hPlotAxes );
+      plot_EXT( hMainFig, hPlotAxes );
     end
     
     % Pointer reset to arrow
@@ -553,58 +557,87 @@ tsg_initialisation(hMainFig, hQcCmenu)
 
   end
 
+ %----------------------------------------------------------------------
+  % Callback function run when the zoom toggle toolbar is released
   %----------------------------------------------------------------------
-  %----------------------------------------------------------------------
-  function ZoomMenuCallback(hObject, eventdata)
-    % Callback function run when the Open menu item is selected
+  function Zoom_OffMenuCallback(hObject, eventdata)
+    
+    % returns the plot to its initial zoom setting
+    % --------------------------------------------
+    zoom out;
+    
+    % turns interactive zooming off
+    % -----------------------------
+    zoom off;
+    
+  end
 
-    % Returns a zoom mode object for the figure handle
+  %----------------------------------------------------------------------
+  % Callback function run when the zoom toggle toolbar is released
+  %----------------------------------------------------------------------
+  function Zoom_OnMenuCallback(hObject, eventdata)
+    
+    % returns a zoom mode object for the figure hMainFig handle
+    % --------------------------------------------------------
     hZoom = zoom(hMainFig);
-    % Specifies whether this mode is currently enabled on the figure
-    zoomOnOff = get(hZoom, 'Enable' );
-    switch zoomOnOff
-      case 'on'
-        zoom off
-        zoomAdaptiveDateTicks('off');
-      case 'off'
-        pan off
-
-        % Desactivate the QC toggle button
-        % --------------------------------
-        set(hQCPushtool, 'state', 'off' );
-
-        zoom on
-        zoomAdaptiveDateTicks('on');
-    end
-    %  zoomColor = get(hZoomPushtool,'CData');
-    % set(hZoomplusPushtool,'CData', zoomColor);
+    
+    % turns on interactive zooming (same effect than zoom on) but prevent
+    % side effect on another figure
+    % -------------------------------------------------------------------
+    set(hZoom,'enable', 'on');
+   
+    % Turns on the automatic adaptation of date ticks
+    % -----------------------------------------------
+    zoomAdaptiveDateTicks('on');
+ 
+    % Desactivate the QC and pan toggle buttons
+    % -----------------------------------------
+    set(hQCToggletool,  'state', 'off' );
+    set(hPanToggletool, 'state', 'off' );
   end
 
   %----------------------------------------------------------------------
+  % Callback function run when the pan toggle toolbar is released
   %----------------------------------------------------------------------
-  function PanMenuCallback(hObject, eventdata)
-    % Callback function run when the Open menu item is selected
+  function Pan_OffMenuCallback(hObject, eventdata)
+    
+    % turns interactive pan off
+    % -------------------------
+    pan off;
+    
+    % reset to original figure
+    % ------------------------
+    zoom out;
+    
+  end
 
+  %----------------------------------------------------------------------
+  % Callback function run when the pan toggle toolbar is selected
+  %----------------------------------------------------------------------
+  function Pan_OnMenuCallback(hObject, eventdata)
+    
     % Returns a pan mode object for the figure handle
+    % -----------------------------------------------
     hPan = pan(hMainFig);
-    % Specifies whether this mode is currently enabled on the figure
-    panOnOff = get(hPan, 'Enable' );
-    switch panOnOff
-      case 'on'
-        pan off
-        panAdaptiveDateTicks('off');
-      case 'off'
-        zoom off
-        % Desactivate the QC toggle button
-        % --------------------------------
-        set(hQCPushtool, 'state', 'off' );
-        pan on
-        panAdaptiveDateTicks('on');
-
-    end
+    
+    % turns on interactive pan (same effect than pan on) but prevent
+    % side effect on another figure
+    % -------------------------------------------------------------------
+    set(hPan,'enable', 'on');
+    
+    % Turns on the automatic adaptation of date ticks
+    % -----------------------------------------------
+    panAdaptiveDateTicks('on');
+    
+    % Desactivate the QC and pan toggle button
+    % ----------------------------------------
+    set(hQCToggletool,   'state', 'off' );
+    set(hZoomToggletool, 'state', 'off' );
+    
   end
 
   %----------------------------------------------------------------------
+  % Callback function run when the QC toggle tool is released
   %----------------------------------------------------------------------
   function QC_OffMenuCallback(gcbo, eventdata)
     
@@ -622,6 +655,7 @@ tsg_initialisation(hMainFig, hQcCmenu)
   end
 
   %----------------------------------------------------------------------
+  % Callback function run when the QC toggle tool is pressed
   %----------------------------------------------------------------------
   function QC_OnMenuCallback(gcbo, eventdata)
     
@@ -637,25 +671,18 @@ tsg_initialisation(hMainFig, hQcCmenu)
     % Activate clic mouse menu on first axes (salinity)
     % -------------------------------------------------
     set(hPlotAxes(1),'ButtonDownFcn', @QC_SelectCallback);
-
-    % Try to make visible the context menu a the top of
-    % the figure. DOESN'T WORK
-    %oldUnits = get(hMainFig,'units' );
-    %set(hMainFig,'units', 'pixels');
-    %figPos = get(hMainFig,'Position');
-    %set(hQcCmenu, 'Visible', 'on', 'Position', [figPos(1) figPos(4)]);
-    %set(hMainFig,'units', oldUnits);
     
-    % change cursor to crosshai aspect
-    % --------------------------------
+    % change cursor to crosshair aspect
+    % ---------------------------------
     set( hMainFig, 'Pointer', 'crosshair');
     
     % -------------------------------------------------------------
-    % nested function on mouse clic
+    % nested function on mouse clic when QC toggle tool is selected
     % -------------------------------------------------------------
     function QC_SelectCallback(gcbo, eventdata)
 
       % disable ButtonMotion on main fig during select
+      % prevent drawing to map
       % ----------------------------------------------
       set( hMainFig, 'WindowButtonMotionFcn', []);
       
@@ -698,8 +725,8 @@ tsg_initialisation(hMainFig, hQcCmenu)
       % ----------------------
       setappdata( hMainFig, 'tsg_data', tsg);
       
-      % disable ButtonMotion on main fig during select
-      % ----------------------------------------------
+      % enable ButtonMotion on main fig after select QC area
+      % ----------------------------------------------------
       set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
 
     end
@@ -841,13 +868,11 @@ tsg_initialisation(hMainFig, hQcCmenu)
       end
 
       setappdata( hMainFig, 'tsg_data', tsg );
-      
-      % uiwait in the QCMenuCallback function
-      % -------------------------------------
-      %uiresume
   end
 
   %---------------------------------------------------------------------
+  % Callback function run when mouse pointer is moving on temperature plot
+  % draw corresponding measurement position on map
   %---------------------------------------------------------------------
   function MouseMotion(hObject, eventdata)
 
@@ -933,6 +958,7 @@ tsg_initialisation(hMainFig, hQcCmenu)
   end
 
   %---------------------------------------------------------------------
+  % Callback function run when the bootle push tool is pressed
   %---------------------------------------------------------------------
   function BottleMenuCallback(hObject, eventdata)
     % Callback function run when the Bottle tool bar item is selected
@@ -1004,7 +1030,7 @@ tsg_initialisation(hMainFig, hQcCmenu)
     hLine1 = get( hPlotAxes(1), 'UserData');
     hLine2 = get( hPlotAxes(2), 'UserData');
     
-    % Delete climatology linesthe on axes
+    % Delete climatology lines on axes
     % -----------------------------------
     try
       delete(hLine1.stdClimMinus);
-- 
GitLab