Changeset 82
- Timestamp:
- Apr 15, 2010, 5:12:42 AM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r81 r82 295 295 end 296 296 end 297 [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput) 297 [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); 298 298 filebase=fullfile(RootPath,RootFile); 299 299 % if isequal(nom_type,'*')% all fields in a single file ( movie files) … … 355 355 set(handles.ImaDoc,'String',ext); 356 356 if ~isempty(num_i1) 357 ref_i=num_i1 358 'TEStbrowse' 359 num_i2 357 ref_i=num_i1; 360 358 if ~isempty(num_i2) 361 359 ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file … … 2109 2107 end 2110 2108 if isfield(sparam,'CivBin') 2111 CivBin=sparam.CivBin 2109 CivBin=sparam.CivBin; 2112 2110 end 2113 2111 if isfield(sparam,'Civ1Bin') … … 2356 2354 par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 2357 2355 if exist(par_civ1.maskname,'file') 2358 par_civ1.maskflag='y'; 2356 par_civ1.maskflag='y'; 2359 2357 else 2360 2358 par_civ1.maskname='noFile use default'; … … 2664 2662 save(civAllxml,[filename_cmx([1:end-4]) '.xml']); 2665 2663 %cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); 2666 cmd=[cmd '\n' CivBin ' -f ' filename_cmx(1:end-4) '.xml ' civAllCmd] 2664 cmd=[cmd '\n' CivBin ' -f ' filename_cmx(1:end-4) '.xml ' civAllCmd]; 2667 2665 end 2668 2666 % create the .bat file: … … 3993 3991 set(handles.mask_fix2,'String',mask_displ) 3994 3992 end 3993 set(handles.mask_civ2,'Value',maskval) 3995 3994 3996 3995 %------------------------------------------------------------------------ -
trunk/src/mouse_up.m
r81 r82 213 213 end 214 214 end 215 %zoom in if no new figure is created215 %zoom in by a factor 2 if no new figure is created 216 216 if zoomstate 217 xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 217 218 if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed 218 %zoom(2)% zoom in by a factor of 2219 alpha=0.5; %zoom factor (zoom in by a factor 2)220 219 xlim=get(currentaxes,'XLim'); 221 xlim_new( 1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;222 xlim_new( 2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;220 xlim_new(2)=0.5*xy(1,1)+0.5*xlim(2); 221 xlim_new(1)=0.5*xy(1,1)+0.5*xlim(1); 223 222 set(currentaxes,'XLim',xlim_new) 224 223 ylim=get(currentaxes,'YLim'); 225 ylim_new( 1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;226 ylim_new( 2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;224 ylim_new(2)=0.5*xy(1,2)+0.5*ylim(2); 225 ylim_new(1)=0.5*xy(1,2)+0.5*ylim(1); 227 226 set(currentaxes,'YLim',ylim_new) 228 227 if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field … … 234 233 set(hparentrect,'Position',rect) 235 234 end 236 235 %zoom out by a factor of 2 out when the right mouse button has been used 237 236 elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed 238 %zoom(0.5)% zoom out by a factor of 2239 237 alpha=2; %zoom factor (zoom out by a factor 2) 240 238 xlim=get(currentaxes,'XLim'); 241 xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2; 242 xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2; 239 xlim_new(1)=2*xlim(1)-xy(1,1); 240 xlim_new(2)=2*xlim(2)-xy(1,1); 241 % xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2; 242 % xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2; 243 243 ylim=get(currentaxes,'YLim'); 244 ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2; 245 ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2; 244 ylim_new(1)=2*ylim(1)-xy(1,2); 245 ylim_new(2)=2*ylim(2)-xy(1,2); 246 % ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2; 247 % ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2; 248 if isfield(AxeData,'RangeX') && isfield(AxeData,'RangeY') 249 xlim_new(1)=max(AxeData.RangeX(1),xlim_new(1)); 250 xlim_new(2)=min(AxeData.RangeX(2),xlim_new(2)); 251 ylim_new(1)=max(AxeData.RangeY(1),ylim_new(1)); 252 ylim_new(2)=min(AxeData.RangeY(2),ylim_new(2)); 253 if isequal(xlim_new,AxeData.RangeX) && isequal(ylim_new,AxeData.RangeY) 254 set(hhuvmat.zoom,'Value',0) 255 set(hhuvmat.zoom,'BackgroundColor',[0.7 0.7 0.7]) 256 set(hhuvmat.FixedLimits,'Value',0) 257 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 258 end 259 end 246 260 set(currentaxes,'XLim',xlim_new) 247 261 set(currentaxes,'YLim',ylim_new) 248 262 %test whther zoom out is operating (to inactivate AxedAta 249 if ~isfield(AxeData,'CurrentXLim')| ~isequal(xlim,AxeData.CurrentXLim)263 if ~isfield(AxeData,'CurrentXLim')|| ~isequal(xlim,AxeData.CurrentXLim) 250 264 AxeData.CurrentXLim=xlim;% 251 265 end … … 338 352 display(['UserData of ' objtype ':']) 339 353 evalin('base','CurData') %display CurData in the workspace 340 commandwindow 354 commandwindow %brings the Matlab command window to the front 341 355 end 342 356 end -
trunk/src/plot_field.m
r80 r82 1034 1034 end 1035 1035 end 1036 1036 %store the coordinate extrema occupied by the field 1037 test_lim=0; 1038 if test_vec 1039 Xlim=[min(vec_X) max(vec_X)]; 1040 Ylim=[min(vec_Y) max(vec_Y)]; 1041 test_lim=1; 1042 if test_ima%both background image and vectors coexist, take the wider bound 1043 Xlim(1)=min(AX(1),Xlim(1)); 1044 Xlim(2)=max(AX(end),Xlim(2)); 1045 Ylim(1)=min(AY(end),Ylim(1)); 1046 Ylim(2)=max(AY(1),Ylim(2)); 1047 end 1048 elseif test_ima %only image plot 1049 Xlim(1)=min(AX(1),AX(end)); 1050 Xlim(2)=max(AX(1),AX(end)); 1051 Ylim(1)=min(AY(1),AY(end)); 1052 Ylim(2)=max(AY(1),AY(end)); 1053 test_lim=1; 1054 end 1055 AxeData.RangeX=Xlim; 1056 AxeData.RangeY=Ylim; 1037 1057 % adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1 1038 if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) 1039 %~(exist('KeepLim','var') && isequal(KeepLim,1)) %adjust the graph limits* 1040 test_lim=0; 1041 if test_vec 1042 Xlim=[min(vec_X) max(vec_X)]; 1043 Ylim=[min(vec_Y) max(vec_Y)]; 1044 test_lim=1; 1045 if test_ima%both background image and vectors coexist, take the wider bound 1046 Xlim(1)=min(AX(1),Xlim(1)); 1047 Xlim(2)=max(AX(end),Xlim(2)); 1048 Ylim(1)=min(AY(end),Ylim(1)); 1049 Ylim(2)=max(AY(1),Ylim(2)); 1050 end 1051 elseif test_ima %only image plot 1052 Xlim(1)=min(AX(1),AX(end)); 1053 Xlim(2)=max(AX(1),AX(end)); 1054 Ylim(1)=min(AY(1),AY(end)); 1055 Ylim(2)=max(AY(1),AY(end)); 1056 test_lim=1; 1057 end 1058 if test_lim 1059 if Xlim(2)>Xlim(1) 1060 set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates 1061 end 1062 if Ylim(2)>Ylim(1) 1063 set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate 1064 end 1058 if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) && test_lim 1059 if Xlim(2)>Xlim(1) 1060 set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates 1061 end 1062 if Ylim(2)>Ylim(1) 1063 set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate 1065 1064 end 1066 1065 end -
trunk/src/set_object.m
r81 r82 76 76 % Choose default command line output for set_object 77 77 handles.output = hObject; 78 'TESTsetobj'79 data80 78 % Update handles structure 81 79 guidata(hObject, handles); … … 113 111 end 114 112 end 113 if isfield(data,'StyleMenu') 114 set(handles.ObjectStyle,'String',data.StyleMenu); 115 end 115 116 if isfield(data,'Style') 116 117 menu=get(handles.ObjectStyle,'String'); … … 123 124 end 124 125 ObjectStyle_Callback(hObject, eventdata, handles) 126 if isfield(data,'ProjMenu') 127 set(handles.ProjMode,'String',data.ProjMenu); 128 end 125 129 if isfield(data,'ProjMode') 126 130 menu=get(handles.ProjMode,'String'); … … 237 241 set(handles.DZ,'String',data.DZ) 238 242 end 239 if isfield(data,'CoordType') 240 if isequal(data.CoordType,'phys')241 set(handles.MenuCoord,'Value',1)242 elseif isequal(data.CoordType,'px')243 if isfield(data,'CoordType')&& isequal(data.CoordType,'px') 244 % if isequal(data.CoordType,'phys') 245 % set(handles.MenuCoord,'Value',1) 246 % elseif isequal(data.CoordType,'px') 243 247 set(handles.MenuCoord,'Value',2) 244 end248 % end 245 249 end 246 250 end -
trunk/src/update_obj.m
r71 r82 62 62 end 63 63 end 64 64 65 % plot the field projected on the object 65 % if ~isempty(PlotHandles) %&& ~testmask 66 ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData 67 if ~isempty(ProjData) 68 plotaxes=[];%default 66 ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData 67 if ~isempty(ProjData) 68 plotaxes=[];%default 69 69 % get(Object_set{IndexObj}.plotaxes) 70 71 72 73 74 75 70 if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes') 71 plotaxes=Object_set{IndexObj}.plotaxes; 72 [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles); 73 else 74 [plotaxes]=view_field(ProjData); 75 end 76 76 % [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles); 77 Object_out.plotaxes=plotaxes; 78 plotfig=get(plotaxes,'parent'); 79 name_str=get(plotfig,'Name'); 80 if ~isequal(name_str,'uvmat') 81 set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]); 82 end 77 Object_out.plotaxes=plotaxes; 78 plotfig=get(plotaxes,'parent'); 79 name_str=get(plotfig,'Name'); 80 if ~isequal(name_str,'uvmat') 81 set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]); 83 82 end 84 %end83 end 85 84 86 85 86 -
trunk/src/uvmat.m
r81 r82 3085 3085 3086 3086 %read the rootfile input display 3087 FileExt=get(handles.FileExt,'String');3087 [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); 3088 3088 [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]); 3089 3089 NomTypeNew=NomType;%default … … 3103 3103 elseif isequal(NomType,'_i1-i2') 3104 3104 NomTypeNew='_i'; 3105 % TODO: look for other types 3105 3106 end 3106 3107 end … … 3192 3193 RootPath_1=get(handles.RootPath_1,'String'); 3193 3194 RootFile_1=get(handles.RootFile_1,'String'); 3194 if isempty(RootPath_1)| isequal(RootPath_1,'')3195 if isempty(RootPath_1)||isequal(RootPath_1,'') 3195 3196 set(handles.RootPath_1,'String','"') 3196 3197 end 3197 if isempty(RootFile_1) | isequal(RootFile_1,'')3198 if isempty(RootFile_1) || isequal(RootFile_1,'') 3198 3199 set(handles.RootFile_1,'String','"') 3199 3200 end 3200 if ~isempty(RootFile_1)& (isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))3201 if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\')) 3201 3202 RootFile_1(1)=[]; 3202 3203 end … … 3249 3250 filebase_1=fullfile(RootPath_1,RootFile_1); 3250 3251 SubDir_1=get(handles.SubDir,'String'); 3251 if isempty(SubDir_1)| isequal(SubDir_1,'')3252 if isempty(SubDir_1)||isequal(SubDir_1,'') 3252 3253 if isfield(UvData,'SubDir_1') 3253 3254 SubDir_1=UvData.SubDir_1;%retrieve previous subdir … … 3256 3257 end 3257 3258 end 3258 if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2') 3259 str1=get(handles.i1,'String'); 3260 str_a=get(handles.j1,'String'); 3261 if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2') 3259 3262 NomTypeNew=NomType_1; 3260 3263 elseif isequal(NomType_1,'#a') 3261 [filename, idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);3264 [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1); 3262 3265 NomTypeNew='#_ab'; 3263 3266 elseif isequal(NomType_1,'_i_j') 3264 [filename, idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);3267 [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1); 3265 3268 if idetect==1 3266 3269 NomTypeNew='_i1-i2_j'; … … 3269 3272 end 3270 3273 else %for instance avi files or any ima_num series 3271 [filename, idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);3274 [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1); 3272 3275 NomTypeNew='_i1-i2'; 3273 3276 end … … 3587 3590 function save_mask_Callback(hObject, eventdata, handles) 3588 3591 %----------------------------------------------------------------------- 3589 huvmat=get(handles.save_mask,'parent'); 3590 UvData=get(huvmat,'UserData'); 3591 3592 hpatch=findobj(huvmat,'Type','patch'); 3592 UvData=get(handles.uvmat,'UserData'); 3593 3593 3594 flag=1; 3594 3595 npx=size(UvData.Field.A,2); … … 3616 3617 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 3617 3618 end 3618 flagobj=~inpolygon(Xi,Yi,X ,Y);%=0 inside the polygon, 1 outside3619 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside 3619 3620 elseif isequal(ObjectData.Style,'ellipse') 3620 3621 if testphys … … 4311 4312 hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface, 4312 4313 set(hset_object,'name',ObjectName) 4313 % pos_uvmat=get(handles.uvmat,'Position'); 4314 % %position the set_object GUI with respect to uvmat 4315 % if isfield(UvData,'SetObjectOrigin') 4316 % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); 4317 % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 4318 % set(hset_object,'Position',pos_set_object) 4314 4315 % %project the current field on the object and plot it 4316 % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData 4317 % if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes) 4318 % plot_field(ProjData,handles.axes3,PlotHandles); 4319 % UvData.Object{IndexObj}.plotaxes=handles.axes3; 4320 % else 4321 % UvData.Object{IndexObj}.plotaxes=view_field(ProjData); 4319 4322 % end 4320 4321 %project the current field on the object and plot it 4322 ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData 4323 if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes) 4324 plot_field(ProjData,handles.axes3,PlotHandles); 4325 UvData.Object{IndexObj}.plotaxes=handles.axes3; 4326 else 4327 UvData.Object{IndexObj}.plotaxes=view_field(ProjData); 4328 end 4329 set(handles.uvmat,'UserData',UvData) 4330 hother=findobj('Tag','proj_object');%find all the proj objects 4331 for iobj=1:length(hother) 4332 if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch') 4333 set(hother(iobj),'EdgeColor','b') 4334 if isequal(get(hother(iobj),'FaceColor'),'m') 4335 set(hother(iobj),'FaceColor','b') 4336 end 4337 elseif isequal(get(hother(iobj),'Type'),'image') 4338 Acolor=get(hother(iobj),'CData'); 4339 Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 4340 set(hother(iobj),'CData',Acolor); 4341 else 4342 set(hother(iobj),'Color','b') 4343 end 4344 set(hother(iobj),'Selected','off') 4345 end 4323 % set(handles.uvmat,'UserData',UvData) 4324 % hother=findobj('Tag','proj_object');%find all the proj objects 4325 % for iobj=1:length(hother) 4326 % if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch') 4327 % set(hother(iobj),'EdgeColor','b') 4328 % if isequal(get(hother(iobj),'FaceColor'),'m') 4329 % set(hother(iobj),'FaceColor','b') 4330 % end 4331 % elseif isequal(get(hother(iobj),'Type'),'image') 4332 % Acolor=get(hother(iobj),'CData'); 4333 % Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 4334 % set(hother(iobj),'CData',Acolor); 4335 % else 4336 % set(hother(iobj),'Color','b') 4337 % end 4338 % set(hother(iobj),'Selected','off') 4339 % end 4346 4340 hother=findobj('Tag','DeformPoint'); 4347 4341 set(hother,'Color','b'); … … 4390 4384 global CurData 4391 4385 CurData=get(handles.uvmat,'UserData'); 4392 % if isfield(UvData,'ProjField') 4393 CurData=UvData; 4394 evalin('base','global CurData')%make CurData global in the workspace 4395 display(['current field :']) 4396 % end 4386 evalin('base','global CurData')%make CurData global in the workspace 4387 display(['current field :']) 4397 4388 evalin('base','CurData') %display CurData in the workspace 4398 commandwindow; 4389 commandwindow; %brings the Matlab command window to the front 4399 4390 4400 4391 %------------------------------------------------------ … … 4547 4538 % ------------------------------------------------------------------ 4548 4539 function MenuMask_Callback(hObject, eventdata, handles) 4549 set(handles.TOOLS_txt,'Visible','on') 4550 set(handles.frame_tools,'Visible','on') 4551 % set(handles.create,'Visible','on') 4552 % set(handles.create,'Value',1) 4553 % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow 4554 set(handles.save_mask,'Visible','on') 4555 set(handles.masklevel,'Visible','on') 4556 if isequal(get(handles.z_index,'Visible'),'on') 4557 nb_slice=str2num(get(handles.nb_slice,'String')); 4558 for ilist=1:nb_slice 4559 list_index{ilist,1}=num2str(ilist); 4560 end 4561 set(handles.masklevel,'String',list_index) 4562 val=str2num(get(handles.z_index,'String')); 4563 if val<=nb_slice 4564 set(handles.masklevel,'Value',val) 4565 end 4566 else 4567 set(handles.masklevel,'String',{'1'}) 4568 set(handles.masklevel,'Value',1) 4569 end 4570 if ishandle(handles.UVMAT_title) 4571 delete(handles.UVMAT_title) 4572 end 4573 % huvmat=get(handles.create,'parent'); 4540 % set(handles.TOOLS_txt,'Visible','on') 4541 % set(handles.frame_tools,'Visible','on') 4542 % % set(handles.create,'Visible','on') 4543 % % set(handles.create,'Value',1) 4544 % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow 4545 % set(handles.save_mask,'Visible','on') 4546 % set(handles.masklevel,'Visible','on') 4547 % if isequal(get(handles.z_index,'Visible'),'on') 4548 % nb_slice=str2num(get(handles.nb_slice,'String')); 4549 % for ilist=1:nb_slice 4550 % list_index{ilist,1}=num2str(ilist); 4551 % end 4552 % set(handles.masklevel,'String',list_index) 4553 % val=str2num(get(handles.z_index,'String')); 4554 % if val<=nb_slice 4555 % set(handles.masklevel,'Value',val) 4556 % end 4557 % else 4558 % set(handles.masklevel,'String',{'1'}) 4559 % set(handles.masklevel,'Value',1) 4560 % end 4561 % if ishandle(handles.UVMAT_title) 4562 % delete(handles.UVMAT_title) 4563 % end 4574 4564 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4575 set(handles.zoom,'Value',0)4576 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])4577 set(handles.edit_vect,'Value',0)4578 edit_vect_Callback(hObject, eventdata, handles)4579 set(handles.edit,'Value',0)4580 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])4581 set(handles.edit_vect,'Value',0)4582 edit_vect_Callback(hObject, eventdata, handles)4565 % set(handles.zoom,'Value',0) 4566 % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7]) 4567 % set(handles.edit_vect,'Value',0) 4568 % edit_vect_Callback(hObject, eventdata, handles) 4569 % set(handles.edit,'Value',0) 4570 % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7]) 4571 % set(handles.edit_vect,'Value',0) 4572 % edit_vect_Callback(hObject, eventdata, handles) 4583 4573 % set(handles.cal,'Value',0) 4584 4574 % set(handles.cal,'BackgroundColor',[0 1 0]) 4585 4575 4586 4576 %initiate the GUI set_object 4587 data.TITLE='MASK'; 4588 if isfield(UvData,'CoordType') 4589 data.CoordType=UvData.CoordType; 4590 end 4591 if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4592 data.YMax=UvData.Mesh; 4593 elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image 4594 np=size(UvData.Field.A); 4595 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1); 4596 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1); 4597 data.YMax=max(meshx,meshy); 4598 data.DX=max(meshx,meshy); 4599 end 4600 data.Coord=[0 0 0]; %default 4601 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters 4602 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface 4603 pos_uvmat=get(handles.huvmat,'Position'); 4604 if isfield(UvData,'SetObjectOrigin') 4605 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); 4606 pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 4607 set(hset_object,'Position',pos_set_object) 4608 end 4609 list_object=get(handles.list_object_1,'String'); 4610 if ~isempty(list_object) 4611 set(handles.list_object_1,'Value',length(list_object)) 4612 end 4613 UvData.MouseAction='create_object'; 4577 % data.TITLE='MASK'; 4578 % if isfield(UvData,'CoordType') 4579 % data.CoordType=UvData.CoordType; 4580 % end 4581 % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4582 % data.YMax=UvData.Mesh; 4583 % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image 4584 % np=size(UvData.Field.A); 4585 % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1); 4586 % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1); 4587 % data.YMax=max(meshx,meshy); 4588 % data.DX=max(meshx,meshy); 4589 % end 4590 % data.Coord=[0 0 0]; %default 4591 % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters 4592 % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface 4593 % pos_uvmat=get(handles.uvmat,'Position'); 4594 % if isfield(UvData,'SetObjectOrigin') 4595 % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); 4596 % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 4597 % set(hset_object,'Position',pos_set_object) 4598 % end 4599 ListObj=UvData.Object; 4600 select=zeros(1,numel(ListObj)); 4601 for iobj=1:numel(ListObj); 4602 if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') 4603 select(iobj)=1; 4604 end 4605 end 4606 val=find(select); 4607 if isempty(val) 4608 msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); 4609 return 4610 else 4611 set(handles.list_object_1,'Max',2);%allow multiple selection 4612 set(handles.list_object_1,'Value',val); 4613 % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']); 4614 % if ~isempty(answer) 4615 flag=1; 4616 npx=size(UvData.Field.A,2); 4617 npy=size(UvData.Field.A,1); 4618 xi=[0.5:npx-0.5]; 4619 yi=[0.5:npy-0.5]; 4620 [Xi,Yi]=meshgrid(xi,yi); 4621 if isfield(UvData,'Object') 4622 for iobj=1:length(UvData.Object) 4623 ObjectData=UvData.Object{iobj}; 4624 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); 4625 flagobj=1; 4626 testphys=0; %coordinates in pixels by default 4627 if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') 4628 if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib') 4629 Calib=UvData.XmlData.GeometryCalib; 4630 testphys=1; 4631 end 4632 end 4633 if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') 4634 if isequal(ObjectData.Style,'polygon') 4635 X=ObjectData.Coord(:,1); 4636 Y=ObjectData.Coord(:,2); 4637 if testphys 4638 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 4639 end 4640 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside 4641 elseif isequal(ObjectData.Style,'ellipse') 4642 if testphys 4643 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4644 end 4645 RangeX=max(ObjectData.RangeX); 4646 RangeY=max(ObjectData.RangeY); 4647 X2Max=RangeX*RangeX; 4648 Y2Max=RangeY*RangeY; 4649 distX=(Xi-ObjectData.Coord(1,1)); 4650 distY=(Yi-ObjectData.Coord(1,2)); 4651 flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; 4652 elseif isequal(ObjectData.Style,'rectangle') 4653 if testphys 4654 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4655 end 4656 distX=abs(Xi-ObjectData.Coord(1,1)); 4657 distY=abs(Yi-ObjectData.Coord(1,2)); 4658 flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); 4659 end 4660 if isequal(ObjectData.ProjMode,'mask_outside') 4661 flagobj=~flagobj; 4662 end 4663 flag=flag & flagobj; 4664 end 4665 end 4666 end 4667 end 4668 % flag=~flag; 4669 %mask name 4670 RootPath=get(handles.RootPath,'String'); 4671 RootFile=get(handles.RootFile,'String'); 4672 if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\')) 4673 RootFile(1)=[]; 4674 end 4675 filebase=fullfile(RootPath,RootFile); 4676 list=get(handles.masklevel,'String'); 4677 masknumber=num2str(length(list)); 4678 maskindex=get(handles.masklevel,'Value'); 4679 mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); 4680 imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) 4681 imflag=flipdim(imflag,1); 4682 % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 4683 % 20<imflag<200) 4684 4685 %display the mask 4686 %update_mask(handles,num_i1,num_j1) 4687 figure; 4688 vec=linspace(0,1,256);%define a linear greyscale colormap 4689 map=[vec' vec' vec']; 4690 colormap(map) 4691 image(imflag); 4692 answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name) 4693 if ~strcmp(answer,'Cancel') 4694 imwrite(imflag,answer,'BitDepth',8); 4695 end 4696 set(list_object_1,'Value',1) 4697 set(list_object_1,'Max',1) 4698 % end 4699 end 4700 4701 4702 % UvData.MouseAction='create_object'; 4614 4703 set(handles.uvmat,'UserData',UvData); 4615 4704 … … 4779 4868 create_object(data,handles) 4780 4869 4870 %------------------------------------------------------------------------ 4871 function MenuMaskObject_Callback(hObject, eventdata, handles) 4872 %------------------------------------------------------------------------ 4873 data.Style='polygon'; 4874 data.StyleMenu={'polygon'}; 4875 data.ProjMode='mask_inside';%default 4876 data.ProjMenu={'mask_inside';'mask_outside'}; 4877 create_object(data,handles) 4878 4781 4879 % ------------------------------------------------------------------ 4782 4880 function Menuplane_Callback(hObject, eventdata, handles) … … 4852 4950 set(handles.edit,'BackgroundColor',[0.7,0.7,0.7]) 4853 4951 data.enable_plot=1; 4854 if isfield(UvData,'CoordType') 4855 data.CoordType=UvData.CoordType; 4856 end 4952 transform_list=get(handles.transform_fct,'String'); 4953 val=get(handles.transform_fct,'Value'); 4954 data.CoordType=transform_list{val}; 4955 % if isfield(UvData,'CoordType') 4956 % data.CoordType=UvData.CoordType; 4957 % end 4857 4958 if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4858 4959 data.RangeX=UvData.Mesh; … … 4934 5035 4935 5036 4936
Note: See TracChangeset
for help on using the changeset viewer.