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