[8] | 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.MenuCoord,'String');
|
---|
| 25 | value=get(handles.MenuCoord,'Value');
|
---|
| 26 | data.CoordType=menu{value};
|
---|
| 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=str2num(get(handles.ZMax,'String'));
|
---|
| 63 | if isempty(ZMax)
|
---|
| 64 | if dimrange(1)>1
|
---|
| 65 | % set(handles.ZMax,'String',get(handles.ZMin,'String'))
|
---|
| 66 | data.RangeZ(1)=ZMax;
|
---|
| 67 | end
|
---|
| 68 | else
|
---|
[77] | 69 | data.RangeZ(2)=ZMax;
|
---|
[8] | 70 | dimrange=[dimrange(1) 3];
|
---|
| 71 | end
|
---|
| 72 | end
|
---|
| 73 | if isequal(get(handles.YMin,'Visible'),'on')
|
---|
| 74 | YMin=str2num(get(handles.YMin,'String'));
|
---|
| 75 | if isempty(YMin)
|
---|
| 76 | % if dimrange(2)>2
|
---|
| 77 | % % set(handles.YMin,'String','0')
|
---|
| 78 | % data.RangeY(2)=0;
|
---|
| 79 | % end
|
---|
| 80 | else
|
---|
| 81 | data.RangeY(2)=YMin;
|
---|
| 82 | dimrange=[2 max(dimrange(2),2)];
|
---|
| 83 | end
|
---|
| 84 | end
|
---|
| 85 | if isequal(get(handles.YMax,'Visible'),'on')
|
---|
| 86 | % data.YMax=str2num(get(handles.YMax,'String'));
|
---|
| 87 | YMax=str2num(get(handles.YMax,'String'));
|
---|
| 88 | if isempty(YMax)
|
---|
| 89 | % if dimrange(1)>1
|
---|
| 90 | % % set(handles.YMax,'String',get(handles.YMin,'String'))
|
---|
| 91 | % if ~isempty(YMin)
|
---|
| 92 | % data.RangeY(1)=YMin;
|
---|
| 93 | % end
|
---|
| 94 | % elseif dimrange(2)>2
|
---|
| 95 | % % set(handles.YMax,'String',get(handles.ZMin,'String'))
|
---|
| 96 | % data.RangeY(2)=ZMin;
|
---|
| 97 | % end
|
---|
| 98 | else
|
---|
| 99 | data.RangeY(1)=YMax;
|
---|
| 100 | dimrange=[dimrange(1) max(dimrange(2),2)];
|
---|
| 101 | end
|
---|
| 102 | end
|
---|
| 103 | if isequal(get(handles.XMin,'Visible'),'on')
|
---|
| 104 | XMin=str2num(get(handles.XMin,'String'));
|
---|
| 105 | if isempty(XMin)
|
---|
| 106 | % if ~isempty(YMin)
|
---|
| 107 | % if dimrange(2)>1
|
---|
| 108 | % % set(handles.XMin,'String',get(handles.YMin,'String'))
|
---|
| 109 | % data.RangeX(2)=YMin;
|
---|
| 110 | % XMin=YMin;
|
---|
| 111 | % end
|
---|
| 112 | % end
|
---|
| 113 | else
|
---|
| 114 | data.RangeX(2)=XMin;
|
---|
| 115 | %dimrange=[2 max(dimrange(2),1)];
|
---|
| 116 | end
|
---|
| 117 | end
|
---|
| 118 | if isequal(get(handles.XMax,'Visible'),'on')
|
---|
| 119 | XMax=str2num(get(handles.XMax,'String'));
|
---|
| 120 | if isempty(XMax)
|
---|
| 121 | % if dimrange(1)>1
|
---|
| 122 | % % set(handles.XMax,'String',get(handles.XMin,'String'))
|
---|
| 123 | % if ~isempty(XMin)
|
---|
| 124 | % data.RangeX(2)=XMin;
|
---|
| 125 | % end
|
---|
| 126 | % elseif dimrange(2)>1
|
---|
| 127 | % % set(handles.XMax,'String',get(handles.YMax,'String'))
|
---|
| 128 | % data.RangeX(1)=YMax;
|
---|
| 129 | % end
|
---|
| 130 | else
|
---|
| 131 | data.RangeX(1)=XMax;
|
---|
| 132 | end
|
---|
| 133 | end
|
---|
| 134 | end
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | %positions x,y,z
|
---|
| 138 | Xcolumn=get(handles.XObject,'String');
|
---|
| 139 | Ycolumn=get(handles.YObject,'String');
|
---|
| 140 | if ischar(Xcolumn)
|
---|
| 141 | sizchar=size(Xcolumn);
|
---|
| 142 | for icol=1:sizchar(1)
|
---|
| 143 | Xcolumn_cell{icol}=Xcolumn(icol,:);
|
---|
| 144 | end
|
---|
| 145 | Xcolumn=Xcolumn_cell;
|
---|
| 146 | end
|
---|
| 147 | if ischar(Ycolumn)
|
---|
| 148 | sizchar=size(Ycolumn);
|
---|
| 149 | for icol=1:sizchar(1)
|
---|
| 150 | Ycolumn_cell{icol}=Ycolumn(icol,:);
|
---|
| 151 | end
|
---|
| 152 | Ycolumn=Ycolumn_cell;
|
---|
| 153 | end
|
---|
| 154 | Zcolumn={};%default
|
---|
| 155 | if isequal(get(handles.ZObject,'Visible'),'on')
|
---|
| 156 | data.NbDim=3; %test 3D object
|
---|
| 157 | Zcolumn=get(handles.ZObject,'String');
|
---|
| 158 | if ischar(Zcolumn)
|
---|
| 159 | Zcolumn={Zcolumn};
|
---|
| 160 | end
|
---|
| 161 | end
|
---|
| 162 | nb_points=min(length(Xcolumn),length(Ycolumn));%number of point positions needed to define the object position
|
---|
| 163 | if isequal (data.Style,'line');
|
---|
| 164 | nb_defining_points=2;
|
---|
| 165 | elseif isequal(data.Style,'plane')|isequal(data.Style,'rectangle')|isequal(data.Style,'ellipse')
|
---|
| 166 | nb_defining_points=1;
|
---|
| 167 | else
|
---|
| 168 | nb_defining_points=nb_points;
|
---|
| 169 | end
|
---|
| 170 | data_XObject=[];
|
---|
| 171 | data_YObject=[];
|
---|
| 172 | data_ZObject=[];
|
---|
| 173 | for i=1:nb_points
|
---|
| 174 | Xnumber=str2num(Xcolumn{i});
|
---|
| 175 | Ynumber=str2num(Ycolumn{i});
|
---|
| 176 | if isempty(Xnumber)|isempty(Ynumber)
|
---|
| 177 | break
|
---|
| 178 | else
|
---|
| 179 | data_XObject=[data_XObject; Xnumber(1)];
|
---|
| 180 | data_YObject=[data_YObject; Ynumber(1)];
|
---|
| 181 | end
|
---|
| 182 | if length(Zcolumn)<i | isempty(str2num(Zcolumn{i}))
|
---|
| 183 | data_ZObject=[data_ZObject; 0];
|
---|
| 184 | else
|
---|
| 185 | data_ZObject=[data_ZObject; str2num(Zcolumn{i})];
|
---|
| 186 | end
|
---|
| 187 | end
|
---|
| 188 | if nb_defining_points > nb_points
|
---|
| 189 | for i=nb_points+1:nb_defining_points
|
---|
| 190 | data_XObject=[0;data_XObject];
|
---|
| 191 | data_YObject=[0;data_YObject];
|
---|
| 192 | data_ZObject=[0;data_ZObject];
|
---|
| 193 | end
|
---|
| 194 | end
|
---|
| 195 | if isempty(data_XObject)
|
---|
| 196 | data_XObject=0;
|
---|
| 197 | end
|
---|
| 198 | if isempty(data_YObject)
|
---|
| 199 | data_YObject=0;
|
---|
| 200 | end
|
---|
| 201 | if isempty(data_ZObject)
|
---|
| 202 | data_ZObject=0;
|
---|
| 203 | end
|
---|
| 204 | data.Coord=[data_XObject data_YObject data_ZObject];
|
---|
| 205 |
|
---|
| 206 | set(handles.XObject,'String',mat2cell(data_XObject,length(data_XObject)))%correct the interface display
|
---|
| 207 | set(handles.YObject,'String',mat2cell(data_YObject,length(data_XObject)))
|
---|
| 208 | set(handles.ZObject,'String',mat2cell(data_ZObject,length(data_XObject)))
|
---|
| 209 |
|
---|
| 210 |
|
---|