Commit 172e16b4d5272a13dad460e92b930475646568d2

Authored by Jean-Luc Shaw
1 parent cc52c00a
Exists in master

Added support for undo function. Still a little graphically uncomfortable to use.

GUI_drifter_cleanup.m
... ... @@ -208,13 +208,6 @@ if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgr
208 208 end
209 209  
210 210  
211   -% --- Executes on button press in but_undo.
212   -function but_undo_Callback(hObject, eventdata, handles)
213   -% hObject handle to but_undo (see GCBO)
214   -% eventdata reserved - to be defined in a future version of MATLAB
215   -% handles structure with handles and user data (see GUIDATA)
216   -
217   -
218 211 % --- Executes during object creation, after setting all properties.
219 212 function menu_bathy_files_CreateFcn(hObject, eventdata, handles)
220 213 % hObject handle to menu_bathy_files (see GCBO)
... ...
lib/but_bathy_filter_Callback.m
... ... @@ -4,6 +4,8 @@ global S
4 4  
5 5 if isfield(S,'z')
6 6 zmin = str2num(handles.edit_zmin.String) ;
  7 + numel(S.z)
  8 + numel(S.lon)
7 9 I = find(S.z < zmin) ;
8 10 S.lon(I) = [] ;
9 11 S.lat(I) = [] ;
... ...
lib/but_undo_Callback.m 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +function but_undo_Callback(hObject, eventdata, handles)
  2 +
  3 +global S bathy cnt
  4 +
  5 +% read the logfile
  6 +fseek(handles.logfid,0,-1) ; % Rewind!
  7 +log = textscan(handles.logfid,'%s%d%d%f%d','headerlines',1,'delimiter',',') ;
  8 +
  9 +if numel(log{1}) < 2
  10 + msgbox('Log file one operation long. Reload file from menu.') ;
  11 +else
  12 + % is the bathymetry loaded
  13 + cp_bath = isfield(S,'z') ;
  14 + % reload the raw file
  15 + liste = get(handles.menu_files,'String') ;
  16 + I = get(handles.menu_files,'Value') ;
  17 + file = liste{I} ;
  18 + load(['data/gps/raw/' file]) ;
  19 +
  20 + S = struct('lon',data.lon,'lat',data.lat,'dnum',data.timeM) ;
  21 + cnt = 0 ; % reset output punch counter
  22 +
  23 + % compute bathymetry if this was done before
  24 + if cp_bath; S.z = bathy(S.lon,S.lat) ; end ;
  25 +
  26 + % Open a new logfile
  27 + if isfield(handles,'logfid') ; fclose(handles.logfid) ; end % out with the old
  28 + logfid = fopen(['log/' file(1:end-4) '.log'],'w+') ;
  29 + fprintf(logfid,'%s\n','Operation, I0, If, Parameter, New track size') ;
  30 + handles.logfid = logfid ; % in with the new
  31 +
  32 + % Update handles structure
  33 + guidata(hObject, handles);
  34 +
  35 +
  36 + % loop over operations and remake the vectors
  37 + for ii = 1:numel(log{1})-1
  38 + switch log{1}{ii}
  39 + case 'delete'
  40 + I0 = log{2}(ii); If = log{3}(ii);
  41 + handles.edit_I0.String = num2str(I0) ;
  42 + handles.edit_If.String = num2str(If) ;
  43 + guidata(hObject, handles);
  44 + but_delete_Callback(hObject, eventdata, handles) ;
  45 + case 'interpolate'
  46 + I0 = log{2}(ii); If = log{3}(ii); par = log{4}(ii);
  47 + handles.edit_I0.String = num2str(I0) ;
  48 + handles.edit_If.String = num2str(If) ;
  49 + handles.edit_interpolate_step.String = num2str(par) ;
  50 + guidata(hObject, handles);
  51 + but_interpolate_Callback(hObject, eventdata, handles) ;
  52 + case 'bathy_filter'
  53 + I0 = log{2}(ii); If = log{3}(ii); par = log{4}(ii);
  54 + handles.edit_I0.String = num2str(I0) ;
  55 + handles.edit_If.String = num2str(If) ;
  56 + handles.edit_zmin.String = num2str(par) ;
  57 + guidata(hObject, handles);
  58 + but_bathy_filter_Callback(hObject, eventdata, handles) ;
  59 + case 'output'
  60 + I0 = log{2}(ii); If = log{3}(ii);
  61 + handles.edit_I0.String = num2str(I0) ;
  62 + handles.edit_If.String = num2str(If) ;
  63 + guidata(hObject, handles);
  64 + but_punch_out_Callback(hObject, eventdata, handles) ;
  65 +
  66 + end
  67 + end
  68 +
  69 + % update plots
  70 + guidata(hObject, handles);
  71 + update_plots(hObject, eventdata, handles) ;
  72 +end
  73 +
  74 +end
0 75 \ No newline at end of file
... ...
lib/menu_files_Callback.m
... ... @@ -20,8 +20,8 @@ axes(handles.ax_track) ;
20 20 plot(S.lon,S.lat,'b',S.lon,S.lat,'ko')
21 21  
22 22 % Open a new logfile
23   -if isfield(handles,'logfid') ; delete(handles.logfid) ; end % out with the old
24   -logfid = fopen(['log/' file(1:end-4) '.log'],'w') ;
  23 +if isfield(handles,'logfid') ; fclose(handles.logfid) ; end % out with the old
  24 +logfid = fopen(['log/' file(1:end-4) '.log'],'w+') ;
25 25 fprintf(logfid,'%s\n','Operation, I0, If, Parameter, New track size') ;
26 26 handles.logfid = logfid ; % in with the new
27 27  
... ...
lib/update_plots.m
... ... @@ -7,6 +7,7 @@ If = str2num(handles.edit_If.String);
7 7  
8 8 % update track plot
9 9 axes(handles.ax_track) ;
  10 +cla;
10 11 plot(S.lon(I0:If),S.lat(I0:If),'b',S.lon(I0:If),S.lat(I0:If),'ko')
11 12  
12 13 %% update aux plot
... ...