-
Notifications
You must be signed in to change notification settings - Fork 0
/
edd_show_scan_details.m
289 lines (261 loc) · 10.5 KB
/
edd_show_scan_details.m
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
function edd_show_scan_details(varargin)
% show detail scan information.
%
% Usage: edd_show_scan_details(da[i])
%
% da[i]: i-th scan struct from readedd5_6bm
% default i=1
%
% 2018-06-05 : add error handling in case motor configuration changes
% 2018-02-07 : initial release
%
% Copyright 2018 Andrew Chuang
% $Revision: 1.1 $ $Date: 2018/06/05 $
heddshowscanMain = findall(0,'Tag','eddshowscanmain_Fig');
if isempty(heddshowscanMain)
switch nargin
case 1
da = varargin{1}(1);
otherwise
fprintf('Usage: edd_show_scan_details(data_struct)\n')
return;
end
initFigure(da);
else
switch nargin
case 1
da = varargin{1}(1);
otherwise
fprintf('Usage: edd_show_scan_details(data_struct)\n')
return;
end
% Error handling
if ~isfield(da.allmotors,'s1out'); da.allmotors.s1out = 0 ; end
if ~isfield(da.allmotors,'s1in'); da.allmotors.s1in = 0 ; end
if ~isfield(da.allmotors,'s1top'); da.allmotors.s1top = 0 ; end
if ~isfield(da.allmotors,'s1bot'); da.allmotors.s1bot = 0 ; end
if ~isfield(da.allmotors,'s2out'); da.allmotors.s2out = 0 ; end
if ~isfield(da.allmotors,'s2in'); da.allmotors.s2in = 0 ; end
if ~isfield(da.allmotors,'s2top'); da.allmotors.s2top = 0 ; end
if ~isfield(da.allmotors,'s2bot'); da.allmotors.s2bot = 0 ; end
if ~isfield(da.allmotors,'s4hout'); da.allmotors.s4hout = 0 ; end
if ~isfield(da.allmotors,'s4hin'); da.allmotors.s4hin = 0 ; end
if ~isfield(da.allmotors,'s4htop'); da.allmotors.s4htop = 0 ; end
if ~isfield(da.allmotors,'s4hbot'); da.allmotors.s4hbot = 0 ; end
figure(heddshowscanMain);
h = get_handle;
mtab = h.showscan_table;
% update number based on input
h.showscanmain_text_WB.String = sprintf('WB: %4d x %4d',...
round((da.allmotors.ush-da.allmotors.dsh)*1000),...
round((da.allmotors.usv-da.allmotors.dsv)*1000));
h.showscanmain_text_S1.String = sprintf('S1: %4d x %4d',...
round((da.allmotors.s1out-da.allmotors.s1in)*1000),...
round((da.allmotors.s1top-da.allmotors.s1bot)*1000));
h.showscanmain_text_S2.String = sprintf('S2: %4d x %4d',...
round((da.allmotors.s2out-da.allmotors.s2in)*1000),...
round((da.allmotors.s2top-da.allmotors.s2bot)*1000));
h.showscanmain_text_S4v.String = sprintf('S4v: %4d x %4d',...
round((da.allmotors.s4vout-da.allmotors.s4vin)*1000),...
round((da.allmotors.s4vtop-da.allmotors.s4vbot)*1000));
h.showscanmain_text_S4h.String = sprintf('S4h: %4d x %4d',...
round((da.allmotors.s4hout-da.allmotors.s4hin)*1000),...
round((da.allmotors.s4htop-da.allmotors.s4hbot)*1000));
h.showscanmain_text_vtth.String = sprintf('2%cv: %1.4f', 952,...
abs(da.allmotors.vtth));
h.showscanmain_text_htth.String = sprintf('2%ch: %1.4f', 952,...
abs(da.allmotors.htth));
set(mtab,'Data',num2cell(da.motorpos_all));
set(mtab,'ColumnName',da.motornames);
update_handle(h)
end
%================================================================
% --- initialize main figure layout
%================================================================
function initFigure(da)
% Error handling
if ~isfield(da.allmotors,'s1out'); da.allmotors.s1out = 0 ; end
if ~isfield(da.allmotors,'s1in'); da.allmotors.s1in = 0 ; end
if ~isfield(da.allmotors,'s1top'); da.allmotors.s1top = 0 ; end
if ~isfield(da.allmotors,'s1bot'); da.allmotors.s1bot = 0 ; end
if ~isfield(da.allmotors,'s2out'); da.allmotors.s2out = 0 ; end
if ~isfield(da.allmotors,'s2in'); da.allmotors.s2in = 0 ; end
if ~isfield(da.allmotors,'s2top'); da.allmotors.s2top = 0 ; end
if ~isfield(da.allmotors,'s2bot'); da.allmotors.s2bot = 0 ; end
if ~isfield(da.allmotors,'s4hout'); da.allmotors.s4hout = 0 ; end
if ~isfield(da.allmotors,'s4hin'); da.allmotors.s4hin = 0 ; end
if ~isfield(da.allmotors,'s4htop'); da.allmotors.s4htop = 0 ; end
if ~isfield(da.allmotors,'s4hbot'); da.allmotors.s4hbot = 0 ; end
% --------------------------------
% --- main figure handle
% --------------------------------
pos = get(0,'PointerLocation');
figureSize = [555 205];
figurePos = [pos(1) pos(2)-180 figureSize];
tablesize = 125;
row1 = tablesize+12;
row2 = tablesize+39;
heddshowscanmain = figure(...
'BackingStore','on',...
'Units','pixels',...
'DockControls','off',...
'Resize','off',...
'PaperOrient','portrait',...
'PaperPositionMode','auto',...
'IntegerHandle','off',...
'NumberTitle','off',...
'MenuBar','none',...
'Toolbar','none',...
'Name','Detail Motor Positions',...
'Position',figurePos,...
'HandleVisibility','callback',...
'Tag','eddshowscanmain_Fig',...
'CloseRequestFcn',@eddshowscanmain_CloseRequestFcn,...
'UserData',[]);
hAxes = axes(...
'Parent',heddshowscanmain,...
'Units','pixels',...
'Position',[0 0 figureSize],...
'Xlim',[0 figureSize(1)],...
'Ylim',[0 figureSize(2)],...
'Tag','eddshowscanmain_Axes');
hPatchMain = patch(...
'Parent',hAxes,...
'XData',[0 figureSize(1) figureSize(1) 0],...
'YData',[0 0 figureSize(2) figureSize(2)],...
'FaceColor',[1 1 0.55],...
'EdgeColor',[1 1 0.55]);
% ----------------------------------------
% --- layout of control panel putshbuttons
% ----------------------------------------
text('Parent',hAxes,...
'Position',[10 row1+12],...
'String','(h x v) in \mum',...
'Fontsize',13,...
'Units','pixel',...
'HorizontalAlignment','left',...
'Color',[0.4 0.3 0]);
htext(1) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[10 row2-5 140 25],...
'backgroundcolor',[1 1 0.55],...
'fontsize',12,...
'String',sprintf('WB: %4d x %4d',...
round((da.allmotors.ush-da.allmotors.dsh)*1000),...
round((da.allmotors.usv-da.allmotors.dsv)*1000)),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_WB');
htext(2) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[155 row2-5 135 25],...
'backgroundcolor',[0.75 1 0.75],...
'fontsize',12,...
'String',sprintf('S1: %4d x %4d',...
round((da.allmotors.s1out-da.allmotors.s1in)*1000),...
round((da.allmotors.s1top-da.allmotors.s1bot)*1000)),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_S1');
htext(3) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[155 row1-5 135 25],...
'backgroundcolor',[1 1 0.55],...
'fontsize',12,...
'String',sprintf('S2: %4d x %4d',...
round((da.allmotors.s2out-da.allmotors.s2in)*1000),...
round((da.allmotors.s2top-da.allmotors.s2bot)*1000)),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_S2');
htext(4) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[295 row2-5 145 25],...
'backgroundcolor',[1 1 0.55],...
'fontsize',12,...
'String',sprintf('S4v: %4d x %4d',...
round((da.allmotors.s4vout-da.allmotors.s4vin)*1000),...
round((da.allmotors.s4vtop-da.allmotors.s4vbot)*1000)),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_S4v');
htext(5) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[295 row1-5 145 25],...
'backgroundcolor',[1 1 0.55],...
'fontsize',12,...
'String',sprintf('S4h: %4d x %4d',...
round((da.allmotors.s4hout-da.allmotors.s4hin)*1000),...
round((da.allmotors.s4htop-da.allmotors.s4hbot)*1000)),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_S4h');
htext(6) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[445 row2-5 105 25],...
'backgroundcolor',[1 0.75 0.55],...
'fontsize',12,...
'String',sprintf('2%cv: %1.4f',...
952,...
abs(da.allmotors.vtth)),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_vtth');
htext(7) = uicontrol('Style','text',...
'Parent',heddshowscanmain,...
'units','pixels',...
'Position',[445 row1-5 105 25],...
'backgroundcolor',[1 0.75 0.55],...
'fontsize',12,...
'String',sprintf('2%ch: %1.4f',...
952,...
da.allmotors.htth),...
'HorizontalAlignment','left',...
'Enable','on',...
'Tag','showscanmain_text_htth');
% construct table
data = num2cell(da.motorpos_all);
htablepar = uitable('Parent',heddshowscanmain,...
'Units','pixels',...
'Position',[10 10 figureSize(1)-20 tablesize],...
'ColumnName',da.motornames,...
'ColumnEditable',false(zeros(1,length(da.motornames))),...
'Data',data,...
'Fontsize',11,...
'CellSelectionCallback',@uitable_selection_Callback,...
'Tag','showscan_table');
allhandle = guihandles(heddshowscanmain);
update_handle(allhandle)
%==========================================================================
% --- Callbacks for
%==========================================================================
%%%% call back to report selection
function uitable_selection_Callback(~,eventdata,~)
% h = get_handle;
eventdata.Indices
% h.opt.table_selection = eventdata.Indices;
% update_handle(h);
%==========================================================================
% --- close request function of eddshowscanmain fig
%==========================================================================
function eddshowscanmain_CloseRequestFcn(hObject,eventdata)
delete(findall(0,'Tag','eddshowscanmain_Fig'))
delete(findall(0,'-regexp','Tag','eddgetpar*'))
%==========================================================================
% --- Load all handle object function
%==========================================================================
function h = get_handle
hmain = findall(0,'Tag','eddshowscanmain_Fig');
h = getappdata(hmain,'allhandle');
%==========================================================================
% --- Save all handle object function
%==========================================================================
function update_handle(handle_to_save)
hmain = findall(0,'Tag','eddshowscanmain_Fig');
setappdata(hmain,'allhandle',handle_to_save);