-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshiftPlotCB.m
More file actions
93 lines (89 loc) · 2.85 KB
/
Copy pathshiftPlotCB.m
File metadata and controls
93 lines (89 loc) · 2.85 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
action = get(gcbo,'Tag')
hfig = get(gcbo,'Parent');
iA = get(findobj('Tag','Plot List'),'Value');
ShiftInfo = get(hfig,'UserData');
getOS;
switch action
case 'Time Shift'
ShiftInfo.di = str2num(get(gcbo,'String'));
ShiftInfo.subMean = 1;
shiftRePlot;
ShiftInfo.subMean = 0;
case 'Replot'
% use with zoom to focus time axis
I = fix(get(ShiftInfo.hax,'Xlim'))
i1 = ShiftInfo.i1; i2 = ShiftInfo.i2;
ShiftInfo.i1 = I(1);
ShiftInfo.i2 = I(2);
ShiftInfo.subMean = 1;
shiftRePlot;
ShiftInfo.subMean = 0;
set(findobj('Tag','Zoom On'),'Value',0)
set(findobj('Tag','Zoom Out'),'Value',0)
case '-'
increment = get(gcbo,'UserData')
ShiftInfo.di = ShiftInfo.di-increment
set(findobj('Tag','Time Shift','Parent',hfig),...
'String',num2str(ShiftInfo.di));
ShiftInfo.subMean = 1;
shiftRePlot;
ShiftInfo.subMean = 0;
case '+'
increment = get(gcbo,'UserData')
ShiftInfo.di = ShiftInfo.di+increment
set(findobj('Tag','Time Shift','Parent',hfig),...
'String',num2str(ShiftInfo.di));
ShiftInfo.subMean = 1;
shiftRePlot;
ShiftInfo.subMean = 0;
case 'Zoom On'
if get(gcbo,'Value')
zoom on
else
zoom off
end
case 'Zoom Out'
zoom off
set(findobj('Tag','Zoom On','Parent',hfig),'Value',0);
I = fix(get(ShiftInfo.hax,'Xlim'))
i1 = I(1);
i2 = I(2);
nPts2 = fix((i2-i1+1)/2);
i1 = max(1,ShiftInfo.i1-nPts2);
i2 = min(ShiftInfo.i2+nPts2,length(ShiftInfo.d));
ShiftInfo.i1 = i1;
ShiftInfo.i2 = i2;
shiftRePlot;
case 'Plot All'
options = struct('chPlot',[1,6],'plotAll',1,'skip',10,...
'di',0);
delete(hfig);
LDF = ShiftInfo.LoadedDataFiles;
shiftPlotStart(TSdata{iA},LDF,options)
ShiftInfo = get(gcf,'UserData');
case 'Switch'
k = 3 - ShiftInfo.ShiftFile;
shiftFileString = ['Shift : ' ShiftInfo.Names{k}]
ShiftInfo.ShiftFile = k;
clr = [0 0 1; 1 0 0];
set(findobj('Tag','Shift File Name','Parent',hfig),...
'String',shiftFileString,'ForeGroundColor',clr(k,:));
start = ShiftInfo.LoadedDataFiles{k}.start;
di = ShiftInfo.di;
dt = ShiftInfo.dt;
startString=datestr(datenum(start)+dt*(di*(-1)^k)/(24*3600));
set(findobj('Tag','Corrected Start Time','Parent',hfig),...
'string',startString,'Foregroundcolor',clr(k,:));
case 'Save'
k = ShiftInfo.ShiftFile;
start = get(findobj('Tag','Corrected Start Time','Parent',hfig),...
'String');
temp = [ShiftInfo.Names{k} ' : ' start];
[fileName,pathName] = uiputfile(['.' filesep '*'],...
'Save corrected start time to file');
fid = fopen([pathName fileName],'a');
fseek(fid,0,1);
fprintf(fid,'%s\n%',temp);
fclose(fid)
end
set(hfig,'UserData',ShiftInfo);