1 | %'read_set_object': read the data on the 'set_object' interface
|
---|
2 | %--------------------------------------------------------
|
---|
3 | % data=read_set_object(handles)
|
---|
4 | %--------------------------------------------------------
|
---|
5 | %OUTPUT
|
---|
6 | %data: structure of data read on the set_object interface
|
---|
7 | % .Style : style of projection object
|
---|
8 | % .Coord(nbpos,3): set of coordinates defining the object position;
|
---|
9 | % .ProjMode=type of projection ;
|
---|
10 | % .Phi=angle of projection;
|
---|
11 | % .DX,.DY,.DZ=increments;
|
---|
12 | % .YMax,YMin: min and max Y
|
---|
13 | %INPUT:
|
---|
14 | % handles: structure describing the tags of the edit boxes and menus
|
---|
15 | function data=read_set_object(handles)
|
---|
16 | %menus
|
---|
17 | if isfield(handles,'ObjectStyle')%case of the set_object interface
|
---|
18 | menu=get(handles.ObjectStyle,'String');
|
---|
19 | value=get(handles.ObjectStyle,'Value');
|
---|
20 | data.Style=menu{value};
|
---|
21 | menu=get(handles.ProjMode,'String');
|
---|
22 | value=get(handles.ProjMode,'Value');
|
---|
23 | data.ProjMode=menu{value};
|
---|
24 | data.CoordUnit=get(handles.CoordUnit,'String');
|
---|
25 | testcalib=0;
|
---|
26 | else %default
|
---|
27 | data.Style='points';
|
---|
28 | testcalib=1;
|
---|
29 | end
|
---|
30 |
|
---|
31 | %Euler angles and projection ranges
|
---|
32 | if ~testcalib
|
---|
33 | if isequal(get(handles.Phi,'Visible'),'on')
|
---|
34 | data.Angle(1)=str2double(get(handles.Phi,'String'));
|
---|
35 | end
|
---|
36 | if isequal(get(handles.Theta,'Visible'),'on')
|
---|
37 | data.Angle(2)=str2double(get(handles.Theta,'String'));
|
---|
38 | end
|
---|
39 | if isequal(get(handles.Psi,'Visible'),'on')
|
---|
40 | data.Angle(3)=str2double(get(handles.Psi,'String'));
|
---|
41 | end
|
---|
42 | if isequal(get(handles.DX,'Visible'),'on')
|
---|
43 | data.DX=str2num(get(handles.DX,'String'));
|
---|
44 | end
|
---|
45 | if isequal(get(handles.DY,'Visible'),'on')
|
---|
46 | data.DY=str2num(get(handles.DY,'String'));
|
---|
47 | end
|
---|
48 | if isequal(get(handles.DZ,'Visible'),'on')
|
---|
49 | data.DZ=str2num(get(handles.DZ,'String'));
|
---|
50 | end
|
---|
51 | dimrange=[1 1];%default
|
---|
52 | if isequal(get(handles.ZMin,'Visible'),'on')
|
---|
53 | ZMin=str2num(get(handles.ZMin,'String'));
|
---|
54 | if ~isempty(ZMin)
|
---|
55 | data.RangeZ(1)=ZMin;
|
---|
56 | dimrange=[2 3];
|
---|
57 | end
|
---|
58 | end
|
---|
59 | if isequal(get(handles.ZMax,'Visible'),'on')
|
---|
60 | ZMax=str2double(get(handles.ZMax,'String'));
|
---|
61 | if isnan(ZMax)
|
---|
62 | if dimrange(1)>1
|
---|
63 | data.RangeZ(1)=ZMax;
|
---|
64 | end
|
---|
65 | else
|
---|
66 | data.RangeZ(2)=ZMax;
|
---|
67 | dimrange=[dimrange(1) 3];
|
---|
68 | end
|
---|
69 | end
|
---|
70 | if isequal(get(handles.YMin,'Visible'),'on')
|
---|
71 | YMin=str2double(get(handles.YMin,'String'));
|
---|
72 | if ~isnan(YMin)
|
---|
73 | data.RangeY(2)=YMin;
|
---|
74 | dimrange=[2 max(dimrange(2),2)];
|
---|
75 | end
|
---|
76 | end
|
---|
77 | if isequal(get(handles.YMax,'Visible'),'on')
|
---|
78 | YMax=str2double(get(handles.YMax,'String'));
|
---|
79 | if ~isnan(YMax)
|
---|
80 | data.RangeY(1)=YMax;
|
---|
81 | dimrange=[dimrange(1) max(dimrange(2),2)];
|
---|
82 | end
|
---|
83 | end
|
---|
84 | if isequal(get(handles.XMin,'Visible'),'on')
|
---|
85 | XMin=str2double(get(handles.XMin,'String'));
|
---|
86 | if ~isnan(XMin)
|
---|
87 | data.RangeX(2)=XMin;
|
---|
88 | end
|
---|
89 | end
|
---|
90 | if isequal(get(handles.XMax,'Visible'),'on')
|
---|
91 | XMax=str2double(get(handles.XMax,'String'));
|
---|
92 | if ~isnan(XMax)
|
---|
93 | data.RangeX(1)=XMax;
|
---|
94 | end
|
---|
95 | end
|
---|
96 | end
|
---|
97 |
|
---|
98 |
|
---|
99 | %positions x,y,z
|
---|
100 | Xcolumn=get(handles.XObject,'String');
|
---|
101 | Ycolumn=get(handles.YObject,'String');
|
---|
102 | if ischar(Xcolumn)
|
---|
103 | sizchar=size(Xcolumn);
|
---|
104 | for icol=1:sizchar(1)
|
---|
105 | Xcolumn_cell{icol}=Xcolumn(icol,:);
|
---|
106 | end
|
---|
107 | Xcolumn=Xcolumn_cell;
|
---|
108 | end
|
---|
109 | if ischar(Ycolumn)
|
---|
110 | sizchar=size(Ycolumn);
|
---|
111 | for icol=1:sizchar(1)
|
---|
112 | Ycolumn_cell{icol}=Ycolumn(icol,:);
|
---|
113 | end
|
---|
114 | Ycolumn=Ycolumn_cell;
|
---|
115 | end
|
---|
116 | Zcolumn={};%default
|
---|
117 | if isequal(get(handles.ZObject,'Visible'),'on')
|
---|
118 | data.NbDim=3; %test 3D object
|
---|
119 | Zcolumn=get(handles.ZObject,'String');
|
---|
120 | if ischar(Zcolumn)
|
---|
121 | Zcolumn={Zcolumn};
|
---|
122 | end
|
---|
123 | end
|
---|
124 | nb_points=min(length(Xcolumn),length(Ycolumn));%number of point positions needed to define the object position
|
---|
125 | if isequal (data.Style,'line');
|
---|
126 | nb_defining_points=2;
|
---|
127 | elseif isequal(data.Style,'plane')|isequal(data.Style,'rectangle')|isequal(data.Style,'ellipse')
|
---|
128 | nb_defining_points=1;
|
---|
129 | else
|
---|
130 | nb_defining_points=nb_points;
|
---|
131 | end
|
---|
132 | data_XObject=[];
|
---|
133 | data_YObject=[];
|
---|
134 | data_ZObject=[];
|
---|
135 | for i=1:nb_points
|
---|
136 | Xnumber=str2num(Xcolumn{i});
|
---|
137 | Ynumber=str2num(Ycolumn{i});
|
---|
138 | if isempty(Xnumber)|isempty(Ynumber)
|
---|
139 | break
|
---|
140 | else
|
---|
141 | data_XObject=[data_XObject; Xnumber(1)];
|
---|
142 | data_YObject=[data_YObject; Ynumber(1)];
|
---|
143 | end
|
---|
144 | if length(Zcolumn)<i | isempty(str2num(Zcolumn{i}))
|
---|
145 | data_ZObject=[data_ZObject; 0];
|
---|
146 | else
|
---|
147 | data_ZObject=[data_ZObject; str2num(Zcolumn{i})];
|
---|
148 | end
|
---|
149 | end
|
---|
150 | if nb_defining_points > nb_points
|
---|
151 | for i=nb_points+1:nb_defining_points
|
---|
152 | data_XObject=[0;data_XObject];
|
---|
153 | data_YObject=[0;data_YObject];
|
---|
154 | data_ZObject=[0;data_ZObject];
|
---|
155 | end
|
---|
156 | end
|
---|
157 | if isempty(data_XObject)
|
---|
158 | data_XObject=0;
|
---|
159 | end
|
---|
160 | if isempty(data_YObject)
|
---|
161 | data_YObject=0;
|
---|
162 | end
|
---|
163 | if isempty(data_ZObject)
|
---|
164 | data_ZObject=0;
|
---|
165 | end
|
---|
166 | data.Coord=[data_XObject data_YObject data_ZObject];
|
---|
167 |
|
---|
168 | set(handles.XObject,'String',mat2cell(data_XObject,length(data_XObject)))%correct the interface display
|
---|
169 | set(handles.YObject,'String',mat2cell(data_YObject,length(data_XObject)))
|
---|
170 | set(handles.ZObject,'String',mat2cell(data_ZObject,length(data_XObject)))
|
---|
171 |
|
---|
172 |
|
---|