Skip to content
Snippets Groups Projects
Commit 7bc3e36d authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

écriture d'un nouveau gestionnaire de tracé de repérage d'un événement particulier sur les 3 plots

Appui sur la touche SHIFT: le curseur se transforme en fullcrosshair
Relâchement de la touche SHIFT, le curseur reprend son aspect précédent suivant le contexte.

Appui sur la touche CTRL: tracé de barres verticales sur les 3 plots
Relâchement de la touche CTRL: effacement des barres verticales 

Notes: 
- cette fonctionnalité ne marche pas avec le zoom, la fonction zoom on remplace le gestionnaire d'interruption keyPressFcn par son propre gestionnaire
- cette fonctionnalité est désactivée lorsque le tracé de carte est actif, la carte, figure 2 devient le gcf par defaut des que l'on bouge la souris
parent 3ded335a
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,7 @@ hMainFig = figure(...
'WindowButtonMotionFcn', @MouseMotion, ...
'CloseRequestFcn', @QuitMenuCallback,...
'KeyPressFcn', @keyPressFcnCallback,...
'KeyReleaseFcn', @keyReleaseFcnCallback,...
'HandleVisibility', handleVisibility,...
'Visible','on',...
'Tag','TAG_TSG-QC_GUI',...
......@@ -144,7 +145,6 @@ tsg = getappdata( hMainFig, 'tsg_data');
hFileMenu = uimenu(...
'Parent', hMainFig,...
'HandleVisibility', handleVisibility,...
'userdata', 0, ... % pour test
'Label', 'File');
hOpenMenu = uimenu(...
'Parent', hFileMenu,...
......@@ -2303,25 +2303,6 @@ hrbInterpCancel = uicontrol( ...
% Dynamically display data in uicontrol
% -------------------------------------
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
%
% plot vertical lines when left control key pressed
% -------------------------------------------------
if get(hFileMenu,'userdata')
% get vertical lines handle and delete it
% ------------------------------------------
hdl_lines = findobj( 'Tag', 'VERTICAL_TAG_LINE' );
delete(hdl_lines);
% loop over 3 subplot and draw vertical line
% ------------------------------------------
for i=1:3
limy(i,:) = get(hPlotAxes(i), 'YLim');
end
for i=1:3
axes( hPlotAxes(i));
line([x x], limy(i,:), 'color', 'k', 'EraseMode', 'xor','tag','VERTICAL_TAG_LINE');
end
end
% display cursor in location in text uicontrol
% --------------------------------------------
......@@ -2412,6 +2393,10 @@ hrbInterpCancel = uicontrol( ...
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes)
% De-activate keyPressFcn callback on main fig
% --------------------------------------------
set(hMainFig, 'KeyPressFcn', []);
end
......@@ -2424,6 +2409,10 @@ hrbInterpCancel = uicontrol( ...
% Make the earth map invisible
% ----------------------------
set(hMapFig, 'Visible', 'off' );
% Re-activate keyPressFcn callback on main fig
% ---------------------------------------------
set(hMainFig, 'KeyPressFcn', @keyPressFcnCallback);
end
......@@ -3305,34 +3294,110 @@ hrbInterpCancel = uicontrol( ...
% -----------------------------------------------------------------------
function keyPressFcnCallback(hObject, evnt)
% check key pressed
% -----------------
if length(evnt.Modifier) == 1 && strcmp(evnt.Modifier{:},'shift')
if strcmp(get(hObject, 'pointer'), 'arrow')
% MATLAB generates repeated KeyPressFcn events, desactivate callback
% ------------------------------------------------------------------
set(hObject, 'KeyPressFcn', []);
% set cursor to fullcross or reset to normal arrow
% ------------------------------------------------
set(hObject, 'pointer', 'fullcrosshair');
% check if key is pressed
% -----------------------
if ~isempty(evnt.Key)
else
set(hObject, 'pointer', 'arrow');
end
end
% test key, shift or control
% --------------------------
switch evnt.Key
case 'shift'
% get current pointer shape
% -------------------------
pointerShape = get(hObject, 'pointer');
% save current cursor shape
% -------------------------
setappdata( hMainFig, 'tsg_pointer', pointerShape);
% set cursor to fullcross or reset to normal arrow
% ------------------------------------------------
set(hObject, 'pointer', 'fullcrosshair');
case 'control'
% Get current position of cusor and return its coordinates in
% axes
% -----------------------------------------------------------
a = get(hPlotAxes(1), 'CurrentPoint');
x = a(2,1);
% Test if cursor is inside data interval
% -------------------------------------
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
% loop over 3 subplot and draw vertical lines
% -------------------------------------------
for iplot = 1:3
axes( hPlotAxes(iplot));
limy = get(hPlotAxes(iplot), 'YLim');
line([x x], limy, 'color', 'k', 'EraseMode', 'xor',...
'tag', 'VERTICAL_TAG_LINE');
end
end
end % end of switch
if length(evnt.Modifier) == 1 && strcmp(evnt.Modifier{:},'control')
if get(hFileMenu,'userdata')
set(hFileMenu, 'userdata', 0);
% get vertical lines handle and delete it
% ------------------------------------------
hdl_lines = findobj( 'Tag', 'VERTICAL_TAG_LINE' );
delete(hdl_lines);
else
set(hFileMenu, 'userdata', 1);
end
end
end
%% KeyReleaseFcnCallback
% -----------------------------------------------------------------------
% Callback function run when key is release
% -----------------------------------------------------------------------
function keyReleaseFcnCallback(hObject, evnt)
% check if key is pressed
% -----------------------
if ~isempty(evnt.Key)
% test key, shift or control
% --------------------------
switch evnt.Key
case 'shift'
% get stored cursor shape
% -----------------------
pointerShape = getappdata( hMainFig, 'tsg_pointer');
% if pointer equal to fullcrosshair, oups, error, reset to arrow
% ---------------------------------------------------------------
if strcmp(pointerShape, 'fullcrosshair')
pointerShape = 'arrow';
set(hObject, 'pointer', pointerShape);
end
% set pointer
% -----------
set(hObject, 'pointer', pointerShape);
case 'control'
% find vertical lines and delete them
% -----------------------------------
hdl_lines = findobj( 'Tag', 'VERTICAL_TAG_LINE' );
delete(hdl_lines);
end % end of switch
end % end of if
% Re-activate callback
% --------------------
set(hObject, 'KeyPressFcn', @keyPressFcnCallback);
end
%% QuitMapCallback
% -----------------------------------------------------------------
% Callback function run when the Quit Map Figure item is selected
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment