Changeset 379 for trunk/src/set_object.m
- Timestamp:
- Jan 27, 2012, 1:59:18 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/set_object.m
r342 r379 12 12 % .ProjMode 13 13 % .CoordType: 'phys' or 'px' 14 % . DX,.DY,.DZ : mesh along each dirction14 % .num_DX,.num_DY,.num_DZ : mesh along each dirction 15 15 % .RangeX, RangeY 16 16 % .Coord(j,i), i=1, 2, 3, components x, y, z of j=1...n position(s) characterizing the object components … … 36 36 function varargout = set_object(varargin) 37 37 38 % Last Modified by GUIDE v2.5 2 4-Nov-2008 14:29:0638 % Last Modified by GUIDE v2.5 26-Jan-2012 22:00:47 39 39 40 40 % Begin initialization code - DO NOT PLOT … … 65 65 % if=0; no associated object (used for series), the button 'PLOT' is then unvisible 66 66 %'data': read from an existing object selected in the interface 67 % . TITLE: class of object ('POINTS','LINE',....)68 % . DX,DY,DZ; meshes for regular grids67 % .Name : class of object ('POINTS','LINE',....) 68 % .num_DX,num_DY,num_DZ; meshes for regular grids 69 69 % .Coord: object position coordinates 70 70 % .ParentButton: handle of the uicontrol object calling the interface … … 92 92 enable_plot=data.enable_plot;%test to desable button PLOT (display mode) 93 93 end 94 if isfield(data,'Name') 95 set(handles.TITLE,'String',data.Name) 96 end 97 if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case 98 set(handles.ZObject,'Visible','off') 94 if isfield(data,'Coord') &&size(data.Coord,2)==3 95 set(handles.z_slider,'Visible','on') 96 else 99 97 set(handles.z_slider,'Visible','off') 100 else 101 set(handles.ZObject,'Visible','on') 102 set(handles.z_slider,'Visible','on') 103 if isfield(data,'Coord') && size(data.Coord,2)==3 104 set(handles.ZObject,'String',num2str(data.Coord(1,3),4)) 105 end 106 end 107 if isfield(data,'StyleMenu') 108 set(handles.ObjectStyle,'String',data.StyleMenu); 109 end 110 if isfield(data,'Style') 111 menu=get(handles.ObjectStyle,'String'); 112 for iline=1:length(menu) 113 if isequal(menu{iline},data.Style) 114 set(handles.ObjectStyle,'Value',iline) 115 break 116 end 117 end 118 end 119 ObjectStyle_Callback(hObject, eventdata, handles) 120 if isfield(data,'ProjMenu') 121 set(handles.ProjMode,'String',data.ProjMenu);%overset the standard menu 122 end 123 if isfield(data,'ProjMode') 124 menu=get(handles.ProjMode,'String'); 125 for iline=1:length(menu) 126 if isequal(menu{iline},data.ProjMode) 127 set(handles.ProjMode,'Value',iline) 128 break 129 end 130 end 131 end 132 ProjMode_Callback(hObject, eventdata, handles) 133 if isfield(data,'Coord') 134 if ischar(data.Coord) 135 data.Coord=str2num(data.Coord); 136 elseif iscell(data.Coord) 137 CoordCell=data.Coord; 138 data.Coord=zeros(numel(CoordCell),3); 139 data.Coord(:,3)=zeros(numel(CoordCell),1); % z component set to 0 by default 140 for iline=1:numel(CoordCell) 141 line_vec=str2num(CoordCell{iline}); 142 if numel(line_vec)==2 143 data.Coord(iline,1:2)=str2num(CoordCell{iline}); 144 else 145 data.Coord(iline,:)=str2num(CoordCell{iline}); 146 end 147 end 148 end 149 if size(data.Coord,2)>=2 150 sizcoord=size(data.Coord); 151 for i=1:sizcoord(1) 152 XObject{i}=num2str(data.Coord(i,1),4); 153 YObject{i}=num2str(data.Coord(i,2),4); 154 end 155 set(handles.XObject,'String',XObject) 156 set(handles.YObject,'String',YObject) 157 if sizcoord(2)>3 158 for i=1:sizcoord(1) 159 ZObject{i}=num2str(data.Coord(i,3),4); 160 end 161 set(handles.ZObject,'String',ZObject) 162 end 163 end 164 end 165 if isfield(data,'DX') 166 if ~ischar(handles.DX) 167 data.DX=num2str(data.DX,3); 168 end 169 set(handles.DX,'String',data.DX) 170 end 171 if isfield(data,'DY') 172 if ~ischar(handles.DY) 173 data.DY=num2str(data.DY,3); 174 end 175 set(handles.DY,'String',data.DX) 176 end 98 end 99 errormsg=fill_GUI(data,handles); 100 % if isfield(data,'StyleMenu') 101 % set(handles.Type,'String',data.StyleMenu); 102 % end 103 % if isfield(data,'Type') 104 % menu=get(handles.Type,'String'); 105 % for iline=1:length(menu) 106 % if isequal(menu{iline},data.Style) 107 % set(handles.Type,'Value',iline) 108 % break 109 % end 110 % end 111 % end 112 Type_Callback(hObject, eventdata, handles) 113 % if isfield(data,'ProjMenu') 114 % set(handles.ProjMode,'String',data.ProjMenu);%overset the standard menu 115 % end 116 % if isfield(data,'ProjMode') 117 % menu=get(handles.ProjMode,'String'); 118 % for iline=1:length(menu) 119 % if isequal(menu{iline},data.ProjMode) 120 % set(handles.ProjMode,'Value',iline) 121 % break 122 % end 123 % end 124 % end 125 % ProjMode_Callback(hObject, eventdata, handles) 126 % if isfield(data,'Coord') 127 % if ischar(data.Coord) 128 % data.Coord=str2num(data.Coord); 129 % elseif iscell(data.Coord) 130 % CoordCell=data.Coord; 131 % data.Coord=zeros(numel(CoordCell),3); 132 % data.Coord(:,3)=zeros(numel(CoordCell),1); % z component set to 0 by default 133 % for iline=1:numel(CoordCell) 134 % line_vec=str2num(CoordCell{iline}); 135 % if numel(line_vec)==2 136 % data.Coord(iline,1:2)=str2num(CoordCell{iline}); 137 % else 138 % data.Coord(iline,:)=str2num(CoordCell{iline}); 139 % end 140 % end 141 % end 142 % if size(data.Coord,2)>=2 143 % sizcoord=size(data.Coord); 144 % for i=1:sizcoord(1) 145 % XObject{i}=num2str(data.Coord(i,1),4); 146 % YObject{i}=num2str(data.Coord(i,2),4); 147 % end 148 % % set(handles.XObject,'String',XObject) 149 % % set(handles.YObject,'String',YObject) 150 % if sizcoord(2)>3 151 % for i=1:sizcoord(1) 152 % ZObject{i}=num2str(data.Coord(i,3),4); 153 % end 154 % set(handles.ZObject,'String',ZObject) 155 % end 156 % end 157 % end 158 % if isfield(data,'DX') 159 % if ~ischar(handles.num_DX) 160 % data.DX=num2str(data.DX,3); 161 % end 162 % set(handles.num_DX,'String',data.DX) 163 % end 164 % if isfield(data,'DY') 165 % if ~ischar(handles.num_DY) 166 % data.DY=num2str(data.DY,3); 167 % end 168 % set(handles.num_DY,'String',data.DX) 169 % end 177 170 if isfield(data,'RangeZ') && length(ZBounds) >= 2 178 set(handles. ZMax,'String',num2str(max(data.RangeZ),3))171 set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3)) 179 172 DZ=max(data.RangeZ);%slider step 180 173 if ~isnan(ZBounds(1)) && ZBounds(2)~=ZBounds(1) … … 192 185 data.RangeX=str2num(data.RangeX); 193 186 end 194 set(handles. XMax,'String',num2str(max(data.RangeX),3))195 set(handles. XMin,'String',num2str(min(data.RangeX),3))187 set(handles.num_RangeX_2,'String',num2str(max(data.RangeX),3)) 188 set(handles.num_RangeX_1,'String',num2str(min(data.RangeX),3)) 196 189 end 197 190 if isfield(data,'RangeY') … … 199 192 data.RangeY=str2num(data.RangeY); 200 193 end 201 set(handles. YMax,'String',num2str(max(data.RangeY),3))202 set(handles. YMin,'String',num2str(min(data.RangeY),3))194 set(handles.num_RangeY_2,'String',num2str(max(data.RangeY),3)) 195 set(handles.num_RangeY_1,'String',num2str(min(data.RangeY),3)) 203 196 end 204 197 if isfield(data,'RangeZ') … … 206 199 data.RangeZ=str2num(data.RangeZ); 207 200 end 208 set(handles. ZMax,'String',num2str(max(data.RangeZ),3))201 set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3)) 209 202 if numel(data.RangeZ)>=2 210 set(handles. ZMin,'String',num2str(min(data.RangeZ),3))203 set(handles.num_RangeZ_1,'String',num2str(min(data.RangeZ),3)) 211 204 end 212 205 end 213 206 if isfield(data,'Angle') && isequal(numel(data.Angle),3) 214 set(handles. Phi,'String',num2str(data.Angle(1)))215 set(handles. Theta,'String',num2str(data.Angle(2)))216 set(handles. Psi,'String',num2str(data.Angle(3)))217 end 218 if isfield(data,'DZ')219 if ~ischar(handles.DZ)220 data.DY=num2str(data.DZ,3);221 end222 set(handles.DZ,'String',data.DZ)223 end224 if isfield(data,'CoordUnit')225 set(handles.CoordUnit,'String',data.CoordUnit)226 end207 set(handles.num_Angle_1,'String',num2str(data.Angle(1))) 208 set(handles.num_Angle_2,'String',num2str(data.Angle(2))) 209 set(handles.num_Angle_3,'String',num2str(data.Angle(3))) 210 end 211 % if isfield(data,'DZ') 212 % if ~ischar(handles.num_DZ) 213 % data.DY=num2str(data.DZ,3); 214 % end 215 % set(handles.num_DZ,'String',data.DZ) 216 % end 217 % if isfield(data,'CoordUnit') 218 % set(handles.CoordUnit,'String',data.CoordUnit) 219 % end 227 220 end 228 221 if enable_plot … … 241 234 end 242 235 236 243 237 %------------------------------------------------------------------------ 244 238 % --- Outputs from this function are returned to the command line. … … 250 244 251 245 %------------------------------------------------------------------------ 252 % --- Executes on selection change in ObjectStyle. 253 function ObjectStyle_Callback(hObject, eventdata, handles) 254 %------------------------------------------------------------------------ 255 style_prev=get(handles.ObjectStyle,'UserData');%previous object style 256 str=get(handles.ObjectStyle,'String'); 257 val=get(handles.ObjectStyle,'Value'); 258 style=str{val}; 246 % --- Executes on selection change in Type. 247 function Type_Callback(hObject, eventdata, handles) 248 %------------------------------------------------------------------------ 249 %style_prev=get(handles.Type,'UserData');%previous object style 250 ListType=get(handles.Type,'String'); 251 Type=ListType{get(handles.Type,'Value')}; 259 252 % make correspondance between different object styles 260 Xcolumn=get(handles.XObject,'String'); 261 Ycolumn=get(handles.YObject,'String'); 262 if ischar(Xcolumn) 263 sizchar=size(Xcolumn); 264 for icol=1:sizchar(1) 265 Xcolumn_cell{icol}=Xcolumn(icol,:); 266 end 267 Xcolumn=Xcolumn_cell; 268 end 269 if ischar(Ycolumn) 270 sizchar=size(Ycolumn); 271 for icol=1:sizchar(1) 272 Ycolumn_cell{icol}=Ycolumn(icol,:); 273 end 274 Ycolumn=Ycolumn_cell; 275 end 276 Zcolumn={};%default 277 z_new={}; 278 if isequal(get(handles.ZObject,'Visible'),'on') 279 %data.NbDim=3; %test 3D object 280 Zcolumn=get(handles.ZObject,'String'); 281 if ischar(Zcolumn) 282 Zcolumn={Zcolumn}; 283 end 284 end 285 x_new{1}=Xcolumn{1}; 286 y_new{1}=Ycolumn{1}; 287 if ~isempty(Zcolumn) 288 z_new{1}=Zcolumn{1}; 289 end 290 if isequal(style,'line') 291 if strcmp(style_prev,'rectangle')||strcmp(style_prev,'ellipse') 292 XMax=get(handles.XMax,'String'); 293 YMax=get(handles.YMax,'String'); 294 x_new{2}=num2str(XMax,4); 295 y_new{2}=num2str(YMax,4); 296 set(handles.XObject,'String',x_new) 297 set(handles.YObject,'String',y_new) 298 set(handles.ZObject,'String',z_new) 299 end 300 elseif isequal(style,'polyline') 301 elseif strcmp(style,'rectangle')|| strcmp(style,'ellipse') 302 set(handles.XObject,'String',x_new) 303 set(handles.YObject,'String',y_new) 304 set(handles.ZObject,'String',z_new) 305 end 306 307 switch style 253 Coord=get(handles.Coord,'Data'); 254 % 255 % Xcolumn=get(handles.XObject,'String'); 256 % Ycolumn=get(handles.YObject,'String'); 257 % if ischar(Xcolumn) 258 % sizchar=size(Xcolumn); 259 % for icol=1:sizchar(1) 260 % Xcolumn_cell{icol}=Xcolumn(icol,:); 261 % end 262 % Xcolumn=Xcolumn_cell; 263 % end 264 % if ischar(Ycolumn) 265 % sizchar=size(Ycolumn); 266 % for icol=1:sizchar(1) 267 % Ycolumn_cell{icol}=Ycolumn(icol,:); 268 % end 269 % Ycolumn=Ycolumn_cell; 270 % end 271 % Zcolumn={};%default 272 % z_new={}; 273 % if isequal(get(handles.ZObject,'Visible'),'on') 274 % %data.NbDim=3; %test 3D object 275 % Zcolumn=get(handles.ZObject,'String'); 276 % if ischar(Zcolumn) 277 % Zcolumn={Zcolumn}; 278 % end 279 % end 280 % x_new{1}=Xcolumn{1}; 281 % y_new{1}=Ycolumn{1}; 282 % x_new{1}=Coord(1,1); 283 % y_new{1}=Coord(1,2); 284 % z_new{1}=Coord(1,3); 285 % if ~isempty(Zcolumn) 286 % z_new{1}=Zcolumn{1}; 287 % end 288 % if isequal(style,'line') 289 % if strcmp(style_prev,'rectangle')||strcmp(style_prev,'ellipse') 290 % num_RangeX_2=get(handles.num_RangeX_2,'String'); 291 % num_RangeY_2=get(handles.num_RangeY_2,'String'); 292 % x_new{2}=num2str(num_RangeX_2,4); 293 % y_new{2}=num2str(num_RangeY_2,4); 294 % set(handles.XObject,'String',x_new) 295 % set(handles.YObject,'String',y_new) 296 % set(handles.ZObject,'String',z_new) 297 % end 298 % elseif isequal(style,'polyline') 299 % elseif strcmp(style,'rectangle')|| strcmp(style,'ellipse') 300 % set(handles.XObject,'String',x_new) 301 % set(handles.YObject,'String',y_new) 302 % set(handles.ZObject,'String',z_new) 303 % end 304 305 %% set the number of lines in the Coord table depending on object type 306 switch Type 307 case{'line'} 308 if size(Coord,1)<2 309 if isequal(size(Coord,2),3) 310 Coord=[Coord; 0 0 0];%add a line for edition (3D case) 311 else 312 Coord=[Coord; 0 0]; %add a line for edition (2D case) 313 end 314 else 315 Coord=Coord(1:2,:); 316 end 317 case{'rectangle','ellipse','plane','volume'} 318 Coord=Coord(1,:); 319 end 320 set(handles.Coord,'Data',Coord) 321 322 %% set the projection menu and the corresponding options 323 switch Type 308 324 case {'points','line','polyline','plane'} 309 325 menu_proj={'projection';'interp';'filter';'none'}; … … 312 328 case 'volume' 313 329 menu_proj={'interp';'none'}; 330 otherwise 331 menu_proj={'projection';'interp';'filter';'none'};%default 314 332 end 315 333 proj_index=get(handles.ProjMode,'Value'); … … 319 337 set(handles.ProjMode,'String',menu_proj) 320 338 ProjMode_Callback(hObject, eventdata, handles) 339 321 340 %store the current option 322 str=get(handles.ObjectStyle,'String');323 val=get(handles.ObjectStyle,'Value');324 set(handles.ObjectStyle,'UserData',style)341 % str=get(handles.Type,'String'); 342 % val=get(handles.Type,'Value'); 343 % set(handles.Type,'UserData',style) 325 344 326 345 %------------------------------------------------------------------------ … … 341 360 value=get(handles.ProjMode,'Value'); 342 361 ProjMode=menu{value}; 343 menu=get(handles. ObjectStyle,'String');344 value=get(handles. ObjectStyle,'Value');362 menu=get(handles.Type,'String'); 363 value=get(handles.Type,'Value'); 345 364 ObjectStyle=menu{value}; 346 test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case 347 365 %%%%%%%%% TODO 366 test3D=0; %TODO: update test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case 367 %%%%%%%%% 348 368 %default setting 349 set(handles. Phi,'Visible','off')350 set(handles. Theta,'Visible','off')351 set(handles. Psi,'Visible','off')352 set(handles. XMin,'Visible','off')353 set(handles. XMax,'Visible','off')354 set(handles. YMin,'Visible','off')369 set(handles.num_Angle_1,'Visible','off') 370 set(handles.num_Angle_2,'Visible','off') 371 set(handles.num_Angle_3,'Visible','off') 372 set(handles.num_RangeX_1,'Visible','off') 373 set(handles.num_RangeX_2,'Visible','off') 374 set(handles.num_RangeY_1,'Visible','off') 355 375 if isequal(ProjMode,'interp') 356 set(handles. YMax,'Visible','off')357 else 358 set(handles. YMax,'Visible','on')376 set(handles.num_RangeY_2,'Visible','off') 377 else 378 set(handles.num_RangeY_2,'Visible','on') 359 379 end 360 380 if strcmp(ObjectStyle,'rectangle')||strcmp(ObjectStyle,'ellipse') 361 set(handles. XMax,'Visible','on')362 else 363 set(handles. XMax,'Visible','off')364 end 365 set(handles. ZMin,'Visible','off')366 set(handles. ZMax,'Visible','off')367 set(handles. DX,'Visible','off')368 set(handles. DY,'Visible','off')369 set(handles. DZ,'Visible','off')381 set(handles.num_RangeX_2,'Visible','on') 382 else 383 set(handles.num_RangeX_2,'Visible','off') 384 end 385 set(handles.num_RangeZ_1,'Visible','off') 386 set(handles.num_RangeZ_2,'Visible','off') 387 set(handles.num_DX,'Visible','off') 388 set(handles.num_DY,'Visible','off') 389 set(handles.num_DZ,'Visible','off') 370 390 371 391 switch ObjectStyle 372 392 case 'points' 373 set(handles. YMax,'TooltipString','YMax: range of averagingaround each point')374 set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points')375 set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points')376 set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points')393 set(handles.num_RangeY_2,'TooltipString','num_YMax: range of projection around each point') 394 % set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points') 395 % set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points') 396 % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points') 377 397 case {'line','polyline','polygon'} 378 set(handles. YMax,'TooltipString','YMax: range of averagingaround the line')379 set(handles.XObject,'TooltipString','XObject: set of xcoordinates defining the line')380 set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line')381 set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line')398 set(handles.num_RangeY_2,'TooltipString','num_YMax: range of projection around the line') 399 set(handles.Coord,'TooltipString','Coord: table of x,y, z coordinates defining the line') 400 % set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') 401 % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line') 382 402 if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') 383 set(handles. DX,'Visible','on')384 set(handles. DX,'TooltipString','DX: mesh for the interpolated field along the line')403 set(handles.num_DX,'Visible','on') 404 set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line') 385 405 end 386 406 case {'rectangle','ellipse'} 387 set(handles. XMax,'TooltipString',['XMax: half length of the ' ObjectStyle])388 set(handles. YMax,'TooltipString',['YMax: half width of the ' ObjectStyle])389 set(handles.XObject,'TooltipString',['XObject: x coordinate of the ' ObjectStyle ' centre'])390 set(handles.YObject,'TooltipString',['YObject: y coordinate of the ' ObjectStyle ' centre'])407 set(handles.num_RangeX_2,'TooltipString',['num_XMax: half length of the ' ObjectStyle]) 408 set(handles.num_RangeY_2,'TooltipString',['num_YMax: half width of the ' ObjectStyle]) 409 % set(handles.XObject,'TooltipString',['XObject: x coordinate of the ' Type ' centre']) 410 % set(handles.YObject,'TooltipString',['YObject: y coordinate of the ' Type ' centre']) 391 411 case {'plane'} 392 set(handles.Psi,'Visible','on') 393 set(handles.XMin,'Visible','on') 394 set(handles.XMax,'Visible','on') 395 set(handles.YMin,'Visible','on') 396 set(handles.YMax,'Visible','on') 412 set(handles.num_Angle_3,'Visible','on') 413 set(handles.num_RangeX_1,'Visible','on') 414 set(handles.num_RangeX_2,'Visible','on') 415 set(handles.num_RangeY_1,'Visible','on') 416 set(handles.num_RangeY_2,'Visible','on') 417 % set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' Type]) 418 % set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' Type]) 419 set(handles.num_RangeZ_2,'TooltipString','num_ZMax: range of projection normal to the plane') 420 if test3D 421 set(handles.num_Angle_2,'Visible','on') 422 set(handles.num_Angle_1,'Visible','on') 423 set(handles.num_RangeZ_2,'Visible','on') 424 end 425 if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') 426 set(handles.num_DX,'Visible','on') 427 set(handles.num_DY,'Visible','on') 428 else 429 set(handles.num_DX,'Visible','off') 430 set(handles.num_DY,'Visible','off') 431 end 432 if isequal(ProjMode,'interp') 433 set(handles.num_DZ,'Visible','on') 434 end 435 case {'volume'} 436 set(handles.num_RangeX_1,'Visible','on') 437 set(handles.num_RangeX_2,'Visible','on') 438 set(handles.num_RangeY_1,'Visible','on') 439 set(handles.num_RangeY_2,'Visible','on') 397 440 set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) 398 441 set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) 399 set(handles.ZMax,'TooltipString','ZMax: range of projection normal to the plane') 400 if test3D 401 set(handles.Theta,'Visible','on') 402 set(handles.Phi,'Visible','on') 403 set(handles.ZMax,'Visible','on') 404 end 442 set(handles.num_Angle_1,'Visible','on') 443 set(handles.num_Angle_2,'Visible','on') 444 set(handles.num_Angle_3,'Visible','on') 445 set(handles.num_RangeZ_1,'Visible','on') 446 set(handles.num_RangeZ_2,'Visible','on') 405 447 if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') 406 set(handles.DX,'Visible','on') 407 set(handles.DY,'Visible','on') 448 set(handles.num_DX,'Visible','on') 449 set(handles.num_DY,'Visible','on') 450 set(handles.num_DZ,'Visible','on') 408 451 else 409 set(handles.DX,'Visible','off') 410 set(handles.DY,'Visible','off') 411 end 412 if isequal(ProjMode,'interp') 413 set(handles.DZ,'Visible','on') 414 end 415 case {'volume'} 416 set(handles.XMin,'Visible','on') 417 set(handles.XMax,'Visible','on') 418 set(handles.YMin,'Visible','on') 419 set(handles.YMax,'Visible','on') 420 set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) 421 set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) 422 set(handles.Phi,'Visible','on') 423 set(handles.Theta,'Visible','on') 424 set(handles.Psi,'Visible','on') 425 set(handles.ZMin,'Visible','on') 426 set(handles.ZMax,'Visible','on') 427 if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') 428 set(handles.DX,'Visible','on') 429 set(handles.DY,'Visible','on') 430 set(handles.DZ,'Visible','on') 431 else 432 set(handles.DX,'Visible','off') 433 set(handles.DY,'Visible','off') 434 set(handles.DZ,'Visible','off') 435 end 436 end 437 %------------------------------------------------------------------------ 438 439 %------------------------------------------------------------------------ 440 function Phi_Callback(hObject, eventdata, handles) 452 set(handles.num_DX,'Visible','off') 453 set(handles.num_DY,'Visible','off') 454 set(handles.num_DZ,'Visible','off') 455 end 456 end 457 %------------------------------------------------------------------------ 458 459 %------------------------------------------------------------------------ 460 function num_Angle_1_Callback(hObject, eventdata, handles) 441 461 update_slider(hObject, eventdata,handles) 442 462 %------------------------------------------------------------------------ 443 463 %------------------------------------------------------------------------ 444 function Theta_Callback(hObject, eventdata, handles)464 function num_Angle_2_Callback(hObject, eventdata, handles) 445 465 update_slider(hObject, eventdata,handles) 446 466 %------------------------------------------------------------------------ 447 467 function update_slider(hObject, eventdata,handles) 448 468 %rotation angles 449 PlaneAngle(1)=str2num(get(handles. Phi,'String'));%first angle in degrees450 PlaneAngle(2)=str2num(get(handles. Theta,'String'));%second angle in degrees451 PlaneAngle(3)=str2num(get(handles. Psi,'String'));%second angle in degrees469 PlaneAngle(1)=str2num(get(handles.num_Angle_1,'String'));%first angle in degrees 470 PlaneAngle(2)=str2num(get(handles.num_Angle_2,'String'));%second angle in degrees 471 PlaneAngle(3)=str2num(get(handles.num_Angle_3,'String'));%second angle in degrees 452 472 om=norm(PlaneAngle);%norm of rotation angle in radians 453 473 OmAxis=PlaneAngle/om; %unit vector marking the rotation axis … … 468 488 end 469 489 %------------------------------------------------------------------------ 470 function DX_Callback(hObject, eventdata, handles) 471 %------------------------------------------------------------------------ 472 %------------------------------------------------------------------------ 473 function DY_Callback(hObject, eventdata, handles) 474 %------------------------------------------------------------------------ 475 %------------------------------------------------------------------------ 476 function DZ_Callback(hObject, eventdata, handles) 477 %------------------------------------------------------------------------ 478 479 %------------------------------------------------------------------------ 480 %----------------------------------------------------- 481 % --- Executes on button press in OPEN: DESACTIVATED use uvmat browser 482 function OPEN_Callback(hObject, eventdata, handles) 483 %get the object file 484 oldfile=' '; 485 huvmat=findobj('Tag','uvmat'); 486 hchild=get(huvmat,'Children'); 487 hrootpath=findobj(hchild,'Tag','RootPath'); 488 if ~isempty(hrootpath) 489 oldfile=get(hrootpath,'String'); 490 if iscell(oldfile) 491 oldfile=oldfile{1}; 492 end 493 end 494 [FileName, PathName, filterindex] = uigetfile( ... 495 {'*.xml;*.mat', ' (*.xml,*.mat)'; 496 '*.xml', '.xml files '; ... 497 '*.mat', '.mat matlab files '}, ... 498 'Pick a file',oldfile); 499 fileinput=[PathName FileName];%complete file name 500 testblank=findstr(fileinput,' ');%look for blanks 501 if ~isempty(testblank) 502 msgbox_uvmat('ERROR','forbidden input file name: contain blanks') 503 return 504 end 505 sizf=size(fileinput); 506 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end 507 508 %read the file 509 t=xmltree(fileinput); 510 s=convert(t); 511 if ~isfield(s,'Style') 512 s.Style='points'; 513 end 514 if ~isfield(s,'ProjMode') 515 s.ProjMode='none'; 516 end 517 teststyle=0; 518 519 switch s.Style 520 case {'points','line','polyline','plane'} 521 menu_proj={'projection';'interp';'filter';'none'}; 522 case {'polygon','rectangle','ellipse'} 523 menu_proj={'inside';'outside';'mask_inside';'mask_outside'}; 524 case 'volume' 525 menu_proj={'none'}; 526 end 527 set(handles.ObjectStyle,'String',menu_proj) 528 menu=get(handles.ObjectStyle,'String'); 529 for iline=1:length(menu) 530 if isequal(menu{iline},s.Style) 531 set(handles.ObjectStyle,'Value',iline) 532 teststyle=1; 533 break 534 end 535 end 536 testmode=0; 537 %menu=get(handles.ProjMode,'String'); 538 for iline=1:length(menu_proj) 539 if isequal(menu_proj{iline},s.ProjMode) 540 set(handles.ProjMode,'Value',iline) 541 testmode=1; 542 break 543 end 544 end 545 546 ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes 547 if isfield(s,'XMax') 548 set(handles.XMax,'String',s.XMax) 549 end 550 if isfield(s,'XMin') 551 set(handles.XMin,'String',s.XMin) 552 end 553 if isfield(s,'YMax') 554 set(handles.YMax,'String',s.YMax) 555 end 556 if isfield(s,'YMin') 557 set(handles.YMin,'String',s.YMin) 558 end 559 Range=0; 560 if isfield(s,'Range') 561 if ischar(s.Range) 562 Range=str2num(s.Range); 563 else 564 Range(1,:)=str2num(s.Range{1}); 565 Range(2,:)=str2num(s.Range{2}); 566 end 567 end 568 if size(Range,2)>=3 569 if size(Range,1)>=2 570 set(handles.ZMin,'String',num2str(Range(2,3),3)) 571 end 572 if size(Range,1)>=2 573 set(handles.ZMax,'String',num2str(Range(1,3),3)) 574 end 575 end 576 if size(Range,2)>=2 577 if size(Range,1)>=2 578 set(handles.YMin,'String',num2str(Range(2,2),3)) 579 end 580 if size(Range,1)>=2 581 set(handles.YMax,'String',num2str(Range(1,2),3)) 582 end 583 end 584 if size(Range,2)>=1 585 if size(Range,1)>=2 586 set(handles.XMin,'String',num2str(Range(2,1),3)) 587 end 588 if size(Range,1)>=2 589 set(handles.XMax,'String',num2str(Range(1,1),3)) 590 end 591 end 592 if isfield(s,'RangeX') & ischar(s.RangeX) 593 RangeX=str2num(s.RangeX); 594 set(handles.XMax,'String',num2str(max(RangeX),3)) 595 set(handles.XMin,'String',num2str(min(RangeX),3)) 596 end 597 598 if isfield(s,'RangeY') 599 if ischar(s.RangeY) 600 RangeY=str2num(s.RangeY); 601 set(handles.YMax,'String',num2str(max(RangeY),3)) 602 set(handles.YMin,'String',num2str(min(RangeY),3)) 603 end 604 end 605 if isfield(s,'RangeZ') 606 if ischar(s.RangeZ) 607 RangeZ=str2num(s.RangeZ); 608 set(handles.ZMax,'String',num2str(max(RangeZ),3)) 609 set(handles.ZMin,'String',num2str(min(RangeZ),3)) 610 end 611 end 612 if isfield(s,'Phi') 613 set(handles.Psi,'String',s.Phi)%old definition 614 end 615 if isfield(s,'Angle')&& isequal(numel(s.Angle),3) 616 set(handles.Phi,'String',s.Angle(1)) 617 set(handles.Theta,'String',s.Angle(2)) 618 set(handles.Psi,'String',s.Angle(3)) 619 end 620 % if isfield(s,'Psi') 621 % set(handles.Psi,'String',s.Psi) 622 % end 623 624 if isfield(s,'DX') 625 set(handles.DX,'String',s.DX) 626 end 627 if isfield(s,'DY') 628 set(handles.DY,'String',s.DY) 629 end 630 if ~isfield(s,'Coord') 631 XObject='0';%default 632 YObject='0'; 633 elseif ischar(s.Coord) 634 line=str2num(s.Coord); 635 XObject=num2str(line(1),4); 636 YObject=num2str(line(2),4); 637 else 638 for i=1:length(s.Coord) 639 line=str2num(s.Coord{i}); 640 XObject{i}=num2str(line(1),4); 641 YObject{i}=num2str(line(2),4); 642 end 643 end 644 set(handles.XObject,'String',XObject) 645 set(handles.YObject,'String',YObject) 646 647 %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening 490 function num_DX_Callback(hObject, eventdata, handles) 491 %------------------------------------------------------------------------ 492 %------------------------------------------------------------------------ 493 function num_DY_Callback(hObject, eventdata, handles) 494 %------------------------------------------------------------------------ 495 %------------------------------------------------------------------------ 496 function num_DZ_Callback(hObject, eventdata, handles) 497 %------------------------------------------------------------------------ 498 499 %------------------------------------------------------------------------ 648 500 %------------------------------------------------------------------------ 649 501 %---------------------------------------------------- … … 675 527 676 528 %% read the object on the GUI set_object 677 ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object 678 ObjectName=get(handles.TITLE,'String');%name of the current object defiend in set_object 529 %ObjectData=read_set_object(handles.set_object);%read the input parameters defining the object in the GUI set_object 530 ObjectData=read_GUI(handles.set_object);%read the input parameters defining the object in the GUI set_object 531 %ObjectData.Coord=cell2mat(ObjectData.Coord); 532 ObjectName=ObjectData.Name;%name of the current object defiend in set_object 679 533 if isempty(ObjectName) 680 534 if get(hhuvmat.edit_object,'Value')% edit mode 681 535 ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item 682 536 else %new object 683 StyleList=get(handles. ObjectStyle,'String');684 StyleVal=get(handles. ObjectStyle,'Value');537 StyleList=get(handles.Type,'String'); 538 StyleVal=get(handles.Type,'Value'); 685 539 ObjectName=StyleList{StyleVal}; 686 %ObjectName=[num2str(numel(ListObject)+1) '-' StyleList{StyleVal}];% take the object style as default name687 540 end 688 541 end … … 705 558 end 706 559 ObjectName=ObjectNameNew; 707 % ObjectName=[num2str(IndexObj(end)) '-' ObjectData.Style];%default name 708 set(handles.TITLE,'String',ObjectName)% display the default name in set_object 560 set(handles.Name,'String',ObjectName)% display the default name in set_object 709 561 IndexObj(2)=numel(ListObject)+1;% append an object to the list in uvmat 710 562 set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list … … 712 564 UvData.Object{IndexObj(2)}=[];%initiate a new object (empty yet) 713 565 end 714 % IndexObj_1=IndexObj(1);715 % % if isequal(get(hhuvmat.list_object_2,'Visible'),'on')716 % % IndexObj_2=get(hhuvmat.list_object_2,'Value');717 % % List2=get(hhuvmat.list_object_2,'String');718 % if numel(IndexObj)==2719 % IndexObj_2=IndexObj(2);720 % else721 % IndexObj_2=[];722 % end723 566 testnew=0; 724 725 567 if numel(IndexObj)==1 % if only one object is selected, the projection is in uvmat 726 PlotHandles=hhuvmat;568 % PlotHandles=hhuvmat; 727 569 plotaxes=hhuvmat.axes3;%handle of axes3 in view_field 728 570 else % if a second object is selected, the projection is in view_field, and this second object is selected … … 783 625 %------------------------------------------------------------------------ 784 626 %---------------------------------------------------- 785 function YMin_Callback(hObject, eventdata, handles)786 %------------------------------------------------------------------------ 787 788 function ZMin_Callback(hObject, eventdata, handles)789 %------------------------------------------------------------------------ 790 791 function ZMax_Callback(hObject, eventdata, handles)792 DZ=str2num(get(handles. ZMax,'String'));627 function num_RangeY_1_Callback(hObject, eventdata, handles) 628 %------------------------------------------------------------------------ 629 630 function num_RangeZ_1_Callback(hObject, eventdata, handles) 631 %------------------------------------------------------------------------ 632 633 function num_RangeZ_2_Callback(hObject, eventdata, handles) 634 DZ=str2num(get(handles.num_RangeZ_2,'String')); 793 635 ZMin=get(handles.z_slider,'Min'); 794 636 ZMax=get(handles.z_slider,'Max'); … … 799 641 end 800 642 %------------------------------------------------------------------------ 801 function YMax_Callback(hObject, eventdata, handles)802 %------------------------------------------------------------------------ 803 804 function XMin_Callback(hObject, eventdata, handles)805 %------------------------------------------------------------------------ 806 807 function XMax_Callback(hObject, eventdata, handles)643 function num_RangeY_2_Callback(hObject, eventdata, handles) 644 %------------------------------------------------------------------------ 645 646 function num_RangeX_1_Callback(hObject, eventdata, handles) 647 %------------------------------------------------------------------------ 648 649 function num_RangeX_2_Callback(hObject, eventdata, handles) 808 650 %------------------------------------------------------------------------ 809 651 %------------------------------------------------------------------------ 810 652 function SAVE_Callback(hObject, eventdata, handles) 811 653 % ------------------------------------------------------ 812 Object=read_set_object(handles); 654 %Object=read_set_object(handles); 655 Object=read_GUI(handles.set_object); 813 656 huvmat=findobj('Tag','uvmat'); 814 657 % UvData=get(huvmat,'UserData'); … … 828 671 title={'object name'}; 829 672 dir_save=uigetdir(RootPath); 830 ObjectName=get(handles. TITLE,'String');673 ObjectName=get(handles.Name,'String'); 831 674 if ~isempty(ObjectName)&&~strcmp(ObjectName,'') 832 675 def={fullfile(dir_save,[ObjectName '.xml'])}; … … 859 702 sin_om=0; 860 703 861 PlaneAngle(1)=str2double(get(handles. Phi,'String'));%first angle in degrees862 PlaneAngle(2)=str2double(get(handles. Theta,'String'));%second angle in degrees863 PlaneAngle(3)=str2double(get(handles. Psi,'String'));%second angle in degrees704 PlaneAngle(1)=str2double(get(handles.num_Angle_1,'String'));%first angle in degrees 705 PlaneAngle(2)=str2double(get(handles.num_Angle_2,'String'));%second angle in degrees 706 PlaneAngle(3)=str2double(get(handles.num_Angle_3,'String'));%second angle in degrees 864 707 PlaneAngle=(pi/180)*PlaneAngle; 865 708 om=norm(PlaneAngle);%norm of rotation angle in radians … … 878 721 879 722 %set new plane position and update graph 880 set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4))881 set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4))882 set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4))723 % set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4)) 724 % set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4)) 725 % set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4)) 883 726 PLOT_Callback(hObject, eventdata, handles) 884 727 … … 897 740 %------------------------------------------------------------------------ 898 741 899 742 function Name_Callback(hObject, eventdata, handles) 743 % hObject handle to Name (see GCBO) 744 % eventdata reserved - to be defined in a future version of MATLAB 745 % handles structure with handles and user data (see GUIDATA) 746 747 % Hints: get(hObject,'String') returns contents of Name as text 748 % str2double(get(hObject,'String')) returns contents of Name as a double 749 750 %------------------------------------------------------------------------ 751 % --- Executes when entered data in editable cell(s) in Coord. 752 function Coord_CellEditCallback(hObject, eventdata, handles) 753 %------------------------------------------------------------------------ 754 ListType=get(handles.Type,'String'); 755 Type=ListType{get(handles.Type,'Value')}; 756 switch Type 757 % add lines if multi line input needed 758 case{'points','polyline','polygon'} 759 Coord=get(handles.Coord,'Data'); 760 if isequal(size(Coord,2),3) 761 Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case) 762 else 763 Coord=[Coord;{[]} {[]}]; %add a line for edition (2D case) 764 end 765 set(handles.Coord,'Data',Coord) 766 end 767 768 769 770 function num_Angle_3_Callback(hObject, eventdata, handles) 771 % hObject handle to num_Angle_3 (see GCBO) 772 % eventdata reserved - to be defined in a future version of MATLAB 773 % handles structure with handles and user data (see GUIDATA) 774 775 % Hints: get(hObject,'String') returns contents of num_Angle_3 as text 776 % str2double(get(hObject,'String')) returns contents of num_Angle_3 as a double
Note: See TracChangeset
for help on using the changeset viewer.