1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| function BoutonCurseur_Callback(hObject, eventdata, handles)
% hObject handle to BoutonCurseur (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%affichage des courbes
handle_l1 = line([50000 50000],[-200 400],'LineWidth',3,'Color','g', 'ButtonDownFcn', @(obj, evt) click_on_line(obj));
setappdata(0,'handle_l1',handle_l1);
handle_l2 = line([450000 450000],[-200 400],'LineWidth',3,'Color','g','ButtonDownFcn', @(obj, evt) click_on_line(obj));
setappdata(0,'handle_l2',handle_l2);
function click_on_line(hObject)
% Change windows properties
set(ancestor(hObject, 'figure'), 'WindowButtonMotionFcn', @(obj, evt) move_line(obj), 'WindowButtonUpFcn', @(obj, evt) release_line(obj));
function release_line(hObject)
% Change windows properties
set(hObject, 'WindowButtonMotionFcn', [], 'WindowButtonUpFcn', []);
function move_line(hObject)
% Get mouse pointer position
position = get(ancestor(gca, 'axes'), 'CurrentPoint');
% Change line position
handle_l1 = getappdata(0,'handle_l1');
set(handle_l1, 'XData', [position(1), position(1)]); |
Partager