-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowmotorposition.m
117 lines (108 loc) · 4.23 KB
/
showmotorposition.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
function showmotorposition
% SHOWMOTORPOSITION Called by specr to show the current motor positions
hFigSpecr = findall(0,'Tag','specr_Fig');
settings = getappdata(hFigSpecr,'settings');
% --- open GUI to display the selected scans
h = findall(0,'Tag','figSpecrShowMotorPos');
if ~isempty(h)
figure(h);
hTable = findall(h,'tag','figspecrshowmotorpos_table');
else
p0 = get(hFigSpecr,'position'); % main figure position
p1(3) = 500; % p1 is the setting figure position
p1(4) = 400;
p1(1) = p0(1)+p0(3)/2-p1(3)/2-20;
p1(2) = p0(2)+p0(4)/2-p1(4)/2-30;
h = figure(...
'Units','pixels',...
'MenuBar','none',...
'Units','pixels',...
'Name','Spec Reader - Current Motor Position',...
'NumberTitle','off',...
'IntegerHandle','off',...
'Position',p1,...
'ResizeFcn',@resizefcn,...
'HandleVisibility','callback',...
'Tag','figSpecrShowMotorPos',...
'WindowStyle','normal',...
'UserData',[]);
tableSize = [10 60 p1(3)-20 p1(4)-70];
hTable = uitable(...
'Parent',h,...
'Units','pixels',...
'Tag','figspecrshowmotorpos_table',...
'Position',tableSize);
hPushbuttonOutput = uicontrol(...
'Parent',h,...
'Style','pushbutton',...
'String','Save to Workspace',...
'tag','figspecrshowmotorpos_pushbuttonOutput',...
'Position',[p1(3)-310 20 120 25],...
'callback',@pushbuttonOutputCallbackFcn);
hPushbuttonRefresh = uicontrol(...
'Parent',h,...
'Style','pushbutton',...
'String','Refresh',...
'tag','figspecrshowmotorpos_pushbuttonRefresh',...
'Position',[p1(3)-180 20 50 25],...
'callback','showmotorposition;');
hPushbuttonClose = uicontrol(...
'Parent',h,...
'Style','pushbutton',...
'String','Close',...
'tag','figspecrshowmotorpos_pushbuttonClose',...
'Position',[p1(3)-90 20 50 25],...
'Callback','delete(gcf);');
end
file = settings.file;
scan = settings.scan;
if isempty(file) | isempty(scan) | ~isfield(scan,'selection') | isempty(scan.selection{1})
return;
end
% --- display motor positions in table
%colName = cell(1,length(scan.selectionIndex)+1);
colFormat = cell(1,length(scan.selectionIndex)+1);
colEditable = false(1,length(scan.selectionIndex)+1);
tableData = cell(length(scan.motorName),length(scan.selectionIndex)+1);
colName{1} = 'name/scan#';
colFormat{1} = 'char';
tableData(:,1) = scan.motorName';
for iCol = 1:length(scan.selectionIndex)
colName{iCol+1} = num2str(scan.selectionIndex(iCol));
colFormat{iCol+1} = 'numeric';
tableData(:,iCol+1) = num2cell(scan.selection{iCol}.motorPos');
end
set(hTable,...
'columnName',colName,...
'columnFormat',colFormat,...
'columnEditable',colEditable,...
'RearrangeableColumn','on',...
'Data',tableData,...
'Userdata',scan.selectionIndex);
%================================================================
% --- toolbar mousetracking callback function
%================================================================
function pushbuttonOutputCallbackFcn(hObject,eventdata)
hTable = findall(gcbf,'Tag','figspecrshowmotorpos_table');
tableData = get(hTable,'Data');
if isempty(tableData)
return;
end
motorPosOutput.scan = get(hTable,'userdata');
motorPosOutput.name = tableData(:,1);
motorPosOutput.pos = cell2mat(tableData(:,2:end));
assignin('base','specrMotor',motorPosOutput);
%=================================================================
% --- figure resizefcn function
%=================================================================
function resizefcn(hObject,eventdata)
h = gcbo;
p1 = get(h,'Position');
panelSize = [10 60 p1(3)-20 p1(4)-70];
try
set(findobj(h,'tag','figspecrshowmotorpos_table'),'position',panelSize);
set(findobj(h,'tag','figspecrshowmotorpos_pushbuttonOutput'),'position',[p1(3)-310 20 120 25]);
set(findobj(h,'tag','figspecrshowmotorpos_pushbuttonRefresh'),'position',[p1(3)-180 20 80 25]);
set(findobj(h,'tag','figspecrshowmotorpos_pushbuttonClose'),'position',[p1(3)-90 20 80 25]);
catch
end