forked from helgestein/htAx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbackButtonConst.m
68 lines (55 loc) · 1.91 KB
/
callbackButtonConst.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
function callbackButtonConst(obj, evt, constComp, ternHandles, ...
specHandles, ECHandles)
%CALLBACKBUTTONCONST plots the XRD and EC data according to the
%user-selected cut
figTern = ternHandles.fTernDiagram;
ternInfo = figTern.UserData;
ternInfo.constType = constComp;
ternInfo.polySelected = 0;
figTern.UserData = ternInfo;
hEditConst = ternHandles.editConst;
hEditWidth = ternHandles.editWidth;
valConst = hEditConst.UserData;
valWidth = hEditWidth.UserData;
if checkInputErrorComp(valConst, valWidth) == 1
resetConst(hEditConst, hEditWidth);
else
plotSpecData(ternHandles, specHandles, ECHandles);
plotECData(ternHandles, specHandles, ECHandles);
end
function isError = checkInputErrorComp(constPercent, width)
if isnan(constPercent)
errordlg('comp. not a number');
isError = 1;
elseif isnan(width)
errordlg('width not a number');
isError = 1;
elseif constPercent < 0
errordlg('invalid composition percent');
isError = 1;
elseif constPercent > 1
errordlg('invalid composition percent');
isError = 1;
elseif width < 0
errordlg('invalid width');
isError = 1;
elseif width > 1
errordlg('invalid width');
isError = 1;
elseif (constPercent + width) > 1
errordlg('invalid width-percent combination');
isError = 1;
elseif (constPercent - width) < 0
errordlg('invalid width-percent combination');
isError = 1;
else
isError = 0;
end
end
function [] = resetConst(editConstObj, editWidthObj)
editConstObj.UserData = 0;
editWidthObj.UserData = 0;
editConstObj.String = '0';
editWidthObj.String = '0';
end
end