Changeset 155
- Timestamp:
- Dec 19, 2010, 10:08:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r153 r155 99 99 % ObjectData 100 100 % | 101 % plot_field.m: plot the projected fields and store them as user|102 % data of the plotting axes|101 % plot_field.m: plot the projected fields and store them as | 102 % UvData.axes3 | 103 103 % | 104 104 % AxeData … … 116 116 % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. 117 117 % Else only its name AName is recorded in Field{i}, and its field is then calculated 118 %by the fuction calc_scal after the coordinate transform or after projection on an edit 118 %by the fuction calc_scal after the coordinate transform or after projection on an edit_object 119 119 120 120 % Properties attached to plotting figures (standard Matlab properties): … … 130 130 % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. 131 131 % AxeData:=get(gca,'UserData'); 132 % AxeData.Drawing = create: create a new edit133 % = deform: modify an existing edit by moving its defining create132 % AxeData.Drawing = create: create a new object 133 % = deform: modify an existing object by moving its defining create 134 134 % = off: no current drawing action 135 % = translate: translate an existing edit136 % = zoom: isolate a subregion for zoom in=1 if an edit is being currently drawn, 0 else (set to 0 by releasing mouse button)137 % .hset_edit=handle of the set_edit interface (if a projection edit is edited);138 % .CurrentOrigin: Origin of a curently drawn edit 135 % = translate: translate an existing object 136 % = calibration: move a calibration point 137 % = zoom: isolate a subregion for zoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) 138 % .CurrentOrigin: Origin of a curently drawn edit_object 139 139 % .CurrentLine: currently drawn menuline (A REVOIR) 140 % .CurrentObject: handle of the currently drawn edit 140 % .CurrentObject: handle of the currently drawn edit_object 141 141 % .CurrentRectZoom: current rectangle used for zoom 142 % .zoomon : zoom state (a revoir)143 % .X, .Y, .Z: array of coordinates defining the position of the vector: ASSOCIER AU PLAN (OBJET) PLUTOT QU'A L'AXE ?144 % .U, .V, .W: array of components of the vector145 % .C:146 % .F:147 % .FF:148 % .A149 142 150 143 % Properties attached to projection objects (create, menuline, menuplane...): 151 % 'Tag'='proj_ edit': for all projection objects152 % ObjectData.Style=...: style of projection edit:144 % 'Tag'='proj_object': for all projection objects 145 % ObjectData.Style=...: style of projection object: 153 146 % .ProjMode 154 % .Coord: defines the position of the edit147 % .Coord: defines the position of the object 155 148 % .XMin,YMin.... 156 149 % .XMax,YMax.... 157 150 % .DX,DY,DZ 158 151 % .Phi, .Theta, .Psi : Euler angles 159 % .X,.Y,.U,.V.... : field data projected on the edit152 % .X,.Y,.U,.V.... : field data projected on the object 160 153 % .IndexObj: index in the list of UvData.Object 161 154 %during plotting … … 378 371 set(handles.MenuTools,'Enable','on') 379 372 set(handles.OBJECT_txt,'Visible','on') 380 set(handles.edit ,'Visible','on')373 set(handles.edit_object,'Visible','on') 381 374 set(handles.list_object_1,'Visible','on') 382 375 set(handles.frame_object,'Visible','on') … … 604 597 set(handles.MenuTools,'Enable','on') 605 598 set(handles.OBJECT_txt,'Visible','on') 606 set(handles.edit ,'Visible','on')599 set(handles.edit_object,'Visible','on') 607 600 set(handles.list_object_1,'Visible','on') 608 601 set(handles.frame_object,'Visible','on') … … 1331 1324 set(handles.pycm,'String','var') 1332 1325 else 1333 pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); 1334 pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); 1335 set(handles.pxcm,'String',num2str(pixcmx)) 1336 set(handles.pycm,'String',num2str(pixcmy)) 1326 if isfield(GeometryCalib,'fx_fy') 1327 pixcmx=GeometryCalib.fx_fy(1); 1328 pixcmy=GeometryCalib.fx_fy(2); 1329 set(handles.pxcm,'String',num2str(pixcmx)) 1330 set(handles.pycm,'String',num2str(pixcmy)) 1331 end 1337 1332 end 1338 1333 end … … 2703 2698 for imap=1:numel(IndexObj) 2704 2699 iobj=IndexObj(imap); 2705 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj} ,iobj);% project field on the object2700 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object 2706 2701 if ~isempty(errormsg) 2707 2702 return … … 2759 2754 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap}); 2760 2755 write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters 2761 if isfield(UvData,'Mesh')& ~isempty(UvData.Mesh)2756 if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 2762 2757 ObjectData.Mesh=UvData.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) 2763 2758 end … … 2867 2862 [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); 2868 2863 num_i2=str2double(str2); 2869 if is empty(num_i2)2864 if isnan(num_i2) 2870 2865 num_i2=num_i1; 2871 2866 end 2872 2867 num_j1=str2double(str_a); 2873 if is empty(num_j1)2868 if isnan(num_j1) 2874 2869 num_j1=1; 2875 2870 end 2876 2871 num_j2=str2double(str_b); 2877 if is empty(num_j2)2872 if isnan(num_j2) 2878 2873 num_j2=num_j1; 2879 2874 end … … 3004 2999 % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); 3005 3000 filename=read_file_boxes(handles); 3006 AxeData=get(gca,'UserData');3007 3001 [erread,message]=fileattrib(filename); 3008 3002 if ~isempty(message) && ~isequal(message.UserWrite,1) … … 3026 3020 end 3027 3021 %write fix flags in the netcdf file 3022 UvData=get(handles.uvmat,'UserData'); 3028 3023 hhh=which('netcdf.open');% look for built-in matlab netcdf library 3029 3024 if ~isequal(hhh,'')% case of new builtin Matlab netcdf library … … 3038 3033 end 3039 3034 netcdf.endDef(nc) 3040 netcdf.putVar(nc,varid, AxeData.FF);3035 netcdf.putVar(nc,varid,UvData.axes3.FF); 3041 3036 netcdf.close(nc) 3042 3037 else %old netcdf library … … 3044 3039 end 3045 3040 3041 %------------------------------------------------------------------- 3042 %----Correct the netcdf file, using toolbox (old versions of Matlab). 3043 %------------------------------------------------------------------- 3046 3044 function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) 3047 3045 nc=netcdf(filename,'write'); %open netcdf file … … 3726 3724 set(handles.edit_vect,'Value',0) 3727 3725 edit_vect_Callback(hObject, eventdata, handles) 3728 set(handles.edit ,'Value',0)3729 set(handles.edit ,'BackgroundColor',[0.7 0.7 0.7])3726 set(handles.edit_object,'Value',0) 3727 set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) 3730 3728 % set(handles.cal,'Value',0) 3731 3729 % set(handles.cal,'BackgroundColor',[0 1 0]) … … 3753 3751 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 3754 3752 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, 3755 % associate the set_ edit interface handle to the plotting axes3753 % associate the set_object interface handle to the plotting axes 3756 3754 if isfield(UvData,'SetObjectOrigin') 3757 3755 pos_uvmat=get(huvmat,'Position'); … … 3770 3768 function edit_vect_Callback(hObject, eventdata, handles) 3771 3769 %------------------------------------------------------- 3772 3773 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface3770 % 3771 % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 3774 3772 if isequal(get(handles.edit_vect,'Value'),1) 3775 3773 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); … … 3780 3778 set(handles.record,'Visible','on') 3781 3779 set(handles.edit_vect,'BackgroundColor',[1 1 0]) 3782 set(handles.edit ,'Value',0)3780 set(handles.edit_object,'Value',0) 3783 3781 set(handles.zoom,'Value',0) 3784 3782 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7]) 3785 3783 % set(handles.create,'Value',0) 3786 3784 % set(handles.create,'BackgroundColor',[0 1 0]) 3787 set(handles.edit ,'BackgroundColor',[0.7 0.7 0.7])3785 set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) 3788 3786 set(gcf,'Pointer','arrow') 3789 UvData.MouseAction='edit_vect';3787 % UvData.MouseAction='edit_vect'; 3790 3788 else 3791 3789 set(handles.record,'Visible','off') 3792 3790 set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) 3793 UvData.MouseAction='none';3794 end 3795 set(handles.uvmat,'UserData',UvData)3791 % UvData.MouseAction='none'; 3792 end 3793 % set(handles.uvmat,'UserData',UvData) 3796 3794 3797 3795 %---------------------------------------------- … … 4378 4376 4379 4377 %------------------------------------------------------------------- 4380 % --- Executes on selection change in edit .4381 function edit_ Callback(hObject, eventdata, handles)4378 % --- Executes on selection change in edit_object. 4379 function edit_object_Callback(hObject, eventdata, handles) 4382 4380 %------------------------------------------------------------------- 4383 4381 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4384 test=get(handles.edit ,'Value');4382 test=get(handles.edit_object,'Value'); 4385 4383 if test 4386 UvData.MouseAction='edit_object'; 4387 set(handles.edit,'BackgroundColor',[1,1,0]) 4384 set(handles.edit_object,'BackgroundColor',[1,1,0]) 4388 4385 %suppress the other options 4389 4386 set(handles.zoom,'Value',0) 4390 4387 zoom_Callback(hObject, eventdata, handles) 4391 set(handles.edit_vect,'Value',0)4392 edit_vect_Callback(hObject, eventdata, handles)4393 %list_object_Callback(hObject, eventdata, handles)4394 4388 else 4395 4389 UvData.MouseAction='none'; 4396 set(handles.edit ,'BackgroundColor',[0.7,0.7,0.7])4390 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4397 4391 end 4398 4392 set(handles.uvmat,'UserData',UvData); … … 4446 4440 ObjectData=UvData.Object{IndexObj}; 4447 4441 ObjectData.Name=ObjectName; 4448 if isequal(get(handles.edit ,'Value'),1)4442 if isequal(get(handles.edit_object,'Value'),1) 4449 4443 ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode 4450 4444 end 4451 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters4452 4445 ZBounds=0; % default 4453 4446 if isfield(UvData,'ZMin') && isfield(UvData,'ZMax') … … 4459 4452 delete(hset_object)% delete existing version of set_object 4460 4453 end 4461 hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface, 4462 %set(hset_object,'name',ObjectName) 4454 hset_object=set_object(ObjectData,[],ZBounds);% call the set_object interface, 4463 4455 4464 4456 % %project the current field on the object and plot it 4465 ProjData= proj_field(UvData.Field,ObjectData ,IndexObj);%project the current interface field on ObjectData4457 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 4466 4458 if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes) 4467 plot_field(ProjData,handles.axes3,PlotHandles); 4468 UvData.Object{IndexObj}.plotaxes=handles.axes3; 4469 else 4470 hviewfield=view_field(ProjData); 4471 hhviewfield=guidata(hviewfield); 4472 UvData.Object{IndexObj}.plotaxes=hhviewfield.axes3; 4459 PlotHandles=handles; 4460 % UvData.Object{IndexObj}.plotaxes=handles.axes3; 4461 else 4462 hview_field=findobj(allchild(0),'tag','view_field'); 4463 if isempty(hview_field) 4464 hview_field=view_field; 4465 end 4466 PlotHandles=guidata(hview_field); 4467 % hview_field=view_field(ProjData); 4468 % hhviewfield=guidata(hviewfield); 4469 % UvData.Object{IndexObj}.plotaxes=hhviewfield.axes3; 4470 end 4471 if ~isempty(ProjData) 4472 plot_field(ProjData,PlotHandles.axes3,PlotHandles); 4473 4473 end 4474 4474 set(handles.uvmat,'UserData',UvData) … … 4492 4492 set(hother,'Color','b'); 4493 4493 set(hother,'Selected','off') 4494 if isfield(ObjectData,' HandlesDisplay')4495 for iview=1:length(ObjectData.HandlesDisplay)4496 if ishandle(ObjectData. HandlesDisplay(iview))4497 uistack(ObjectData. HandlesDisplay(iview),'top')4498 linetype=get(ObjectData. HandlesDisplay(iview),'Type');4494 if isfield(ObjectData,'DisplayHandle_uvmat') 4495 % for iview=1:length(ObjectData.HandlesDisplay) 4496 if ishandle(ObjectData.DisplayHandle_uvmat) 4497 uistack(ObjectData.DisplayHandle_uvmat,'top') 4498 linetype=get(ObjectData.DisplayHandle_uvmat,'Type'); 4499 4499 if isequal(linetype,'line') 4500 set(ObjectData. HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color4500 set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color 4501 4501 elseif isequal(linetype,'rectangle') 4502 set(ObjectData. HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color4502 set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color 4503 4503 elseif isequal(linetype,'patch') 4504 set(ObjectData. HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color4504 set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color 4505 4505 end 4506 SubObjectData=get(ObjectData. HandlesDisplay(iview),'UserData');4507 if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)4506 SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData'); 4507 if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) 4508 4508 uistack(SubObjectData.SubObject,'top') 4509 4509 for iobj=1:length(SubObjectData.SubObject) … … 4520 4520 end 4521 4521 end 4522 if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)4522 if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) 4523 4523 set(SubObjectData.DeformPoint,'Color','m') 4524 4524 end 4525 4525 end 4526 end4526 % end 4527 4527 end 4528 4528 pause(0.1) … … 4658 4658 % ------------------------------------------------------------------ 4659 4659 function MenuCalib_Callback(hObject, eventdata, handles) 4660 %geometry_calib; %display the GUI as a waiting display 4660 4661 4661 4662 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface … … 4664 4665 set(handles.zoom,'Value',0) 4665 4666 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7]) 4666 set(handles.MenuMask,'enable','off')4667 set(handles.MenuGrid,'enable','off')4668 set(handles.MenuObject,'enable','off')4669 set(handles.MenuEdit,'enable','off')4667 % set(handles.MenuMask,'enable','off') 4668 % set(handles.MenuGrid,'enable','off') 4669 % set(handles.MenuObject,'enable','off') 4670 % set(handles.MenuEdit,'enable','off') 4670 4671 set(handles.list_object_1,'Value',1) 4671 4672 % initiate display of GUI geometry_calib … … 4678 4679 pos(2)=pos(2)-0.02; 4679 4680 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles); 4680 [UvData.hset_object,UvData.sethandles]=geometry_calib(FileName,pos);% call the geometry_calib interface 4681 pos_uvmat=get(handles.uvmat,'Position'); 4682 4681 set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib 4683 4682 if isfield(UvData,'CalOrigin') 4683 pos_uvmat=get(handles.uvmat,'Position'); 4684 4684 pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3); 4685 4685 pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4); 4686 4686 pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4); 4687 set(UvData.hset_object,'Position',pos_cal) 4688 end 4689 UvData.MouseAction='calib'; 4690 set(handles.uvmat,'UserData',UvData); 4687 %set(UvData.hset_object,'Position',pos_cal) 4688 end 4689 geometry_calib(FileName,pos_cal);% call the geometry_calib interface 4690 set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib 4691 set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action 4692 4693 %UvData.MouseAction='calib'; 4694 % set(handles.uvmat,'UserData',UvData); 4691 4695 4692 4696 4693 4697 % ------------------------------------------------------------------ 4694 4698 function MenuMask_Callback(hObject, eventdata, handles) 4695 % set(handles.TOOLS_txt,'Visible','on')4696 % set(handles.frame_tools,'Visible','on')4697 % % set(handles.create,'Visible','on')4698 % % set(handles.create,'Value',1)4699 % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow4700 % set(handles.save_mask,'Visible','on')4701 % set(handles.masklevel,'Visible','on')4702 % if isequal(get(handles.z_index,'Visible'),'on')4703 % nb_slice=str2num(get(handles.nb_slice,'String'));4704 % for ilist=1:nb_slice4705 % list_index{ilist,1}=num2str(ilist);4706 % end4707 % set(handles.masklevel,'String',list_index)4708 % val=str2num(get(handles.z_index,'String'));4709 % if val<=nb_slice4710 % set(handles.masklevel,'Value',val)4711 % end4712 % else4713 % set(handles.masklevel,'String',{'1'})4714 % set(handles.masklevel,'Value',1)4715 % end4716 % if ishandle(handles.UVMAT_title)4717 % delete(handles.UVMAT_title)4718 % end4719 4699 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4720 % set(handles.zoom,'Value',0)4721 % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])4722 % set(handles.edit_vect,'Value',0)4723 % edit_vect_Callback(hObject, eventdata, handles)4724 % set(handles.edit,'Value',0)4725 % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])4726 % set(handles.edit_vect,'Value',0)4727 % edit_vect_Callback(hObject, eventdata, handles)4728 % set(handles.cal,'Value',0)4729 % set(handles.cal,'BackgroundColor',[0 1 0])4730 4731 %initiate the GUI set_object4732 % data.TITLE='MASK';4733 % if isfield(UvData,'CoordType')4734 % data.CoordType=UvData.CoordType;4735 % end4736 % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)4737 % data.YMax=UvData.Mesh;4738 % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image4739 % np=size(UvData.Field.A);4740 % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);4741 % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);4742 % data.YMax=max(meshx,meshy);4743 % data.DX=max(meshx,meshy);4744 % end4745 % data.Coord=[0 0 0]; %default4746 % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters4747 % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface4748 % pos_uvmat=get(handles.uvmat,'Position');4749 % if isfield(UvData,'SetObjectOrigin')4750 % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);4751 % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);4752 % set(hset_object,'Position',pos_set_object)4753 % end4754 4700 ListObj=UvData.Object; 4755 4701 select=zeros(1,numel(ListObj)); … … 4766 4712 set(handles.list_object_1,'Max',2);%allow multiple selection 4767 4713 set(handles.list_object_1,'Value',val); 4768 % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']); 4769 % if ~isempty(answer) 4770 flag=1; 4771 npx=size(UvData.Field.A,2); 4772 npy=size(UvData.Field.A,1); 4773 xi=0.5:npx-0.5; 4774 yi=0.5:npy-0.5; 4775 [Xi,Yi]=meshgrid(xi,yi); 4776 if isfield(UvData,'Object') 4777 for iobj=1:length(UvData.Object) 4778 ObjectData=UvData.Object{iobj}; 4779 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); 4780 flagobj=1; 4781 testphys=0; %coordinates in pixels by default 4782 if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') 4783 if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib') 4784 Calib=UvData.XmlData.GeometryCalib; 4785 testphys=1; 4786 end 4787 end 4788 if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') 4789 if isequal(ObjectData.Style,'polygon') 4790 X=ObjectData.Coord(:,1); 4791 Y=ObjectData.Coord(:,2); 4792 if testphys 4793 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 4794 end 4795 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside 4796 elseif isequal(ObjectData.Style,'ellipse') 4797 if testphys 4798 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4799 end 4800 RangeX=max(ObjectData.RangeX); 4801 RangeY=max(ObjectData.RangeY); 4802 X2Max=RangeX*RangeX; 4803 Y2Max=RangeY*RangeY; 4804 distX=(Xi-ObjectData.Coord(1,1)); 4805 distY=(Yi-ObjectData.Coord(1,2)); 4806 flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; 4807 elseif isequal(ObjectData.Style,'rectangle') 4808 if testphys 4809 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4810 end 4811 distX=abs(Xi-ObjectData.Coord(1,1)); 4812 distY=abs(Yi-ObjectData.Coord(1,2)); 4813 flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); 4814 end 4815 if isequal(ObjectData.ProjMode,'mask_outside') 4816 flagobj=~flagobj; 4817 end 4818 flag=flag & flagobj; 4714 flag=1; 4715 npx=size(UvData.Field.A,2); 4716 npy=size(UvData.Field.A,1); 4717 xi=0.5:npx-0.5; 4718 yi=0.5:npy-0.5; 4719 [Xi,Yi]=meshgrid(xi,yi); 4720 if isfield(UvData,'Object') 4721 for iobj=1:length(UvData.Object) 4722 ObjectData=UvData.Object{iobj}; 4723 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); 4724 flagobj=1; 4725 testphys=0; %coordinates in pixels by default 4726 if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') 4727 if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib') 4728 Calib=UvData.XmlData.GeometryCalib; 4729 testphys=1; 4819 4730 end 4820 4731 end 4732 if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') 4733 if isequal(ObjectData.Style,'polygon') 4734 X=ObjectData.Coord(:,1); 4735 Y=ObjectData.Coord(:,2); 4736 if testphys 4737 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 4738 end 4739 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside 4740 elseif isequal(ObjectData.Style,'ellipse') 4741 if testphys 4742 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4743 end 4744 RangeX=max(ObjectData.RangeX); 4745 RangeY=max(ObjectData.RangeY); 4746 X2Max=RangeX*RangeX; 4747 Y2Max=RangeY*RangeY; 4748 distX=(Xi-ObjectData.Coord(1,1)); 4749 distY=(Yi-ObjectData.Coord(1,2)); 4750 flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; 4751 elseif isequal(ObjectData.Style,'rectangle') 4752 if testphys 4753 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys 4754 end 4755 distX=abs(Xi-ObjectData.Coord(1,1)); 4756 distY=abs(Yi-ObjectData.Coord(1,2)); 4757 flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); 4758 end 4759 if isequal(ObjectData.ProjMode,'mask_outside') 4760 flagobj=~flagobj; 4761 end 4762 flag=flag & flagobj; 4763 end 4821 4764 end 4822 4765 end 4823 % flag=~flag; 4824 %mask name 4825 RootPath=get(handles.RootPath,'String'); 4826 RootFile=get(handles.RootFile,'String'); 4827 if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\')) 4828 RootFile(1)=[]; 4829 end 4830 filebase=fullfile(RootPath,RootFile); 4831 list=get(handles.masklevel,'String'); 4832 masknumber=num2str(length(list)); 4833 maskindex=get(handles.masklevel,'Value'); 4834 mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); 4835 imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) 4836 imflag=flipdim(imflag,1); 4837 % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 4838 % 20<imflag<200) 4839 4840 %display the mask 4841 %update_mask(handles,num_i1,num_j1) 4842 figure; 4843 vec=linspace(0,1,256);%define a linear greyscale colormap 4844 map=[vec' vec' vec']; 4845 colormap(map) 4846 image(imflag); 4847 answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); 4848 if ~strcmp(answer,'Cancel') 4849 mask_dir=fileparts(answer); 4850 if ~exist(mask_dir,'dir') 4851 msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist']) 4852 return 4853 end 4854 imwrite(imflag,answer,'BitDepth',8); 4855 end 4856 set(handles.list_object_1,'Value',1) 4857 set(handles.list_object_1,'Max',1) 4858 % end 4859 end 4860 4861 4862 % UvData.MouseAction='create_object'; 4863 set(handles.uvmat,'UserData',UvData); 4766 end 4767 % flag=~flag; 4768 %mask name 4769 RootPath=get(handles.RootPath,'String'); 4770 RootFile=get(handles.RootFile,'String'); 4771 if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\')) 4772 RootFile(1)=[]; 4773 end 4774 filebase=fullfile(RootPath,RootFile); 4775 list=get(handles.masklevel,'String'); 4776 masknumber=num2str(length(list)); 4777 maskindex=get(handles.masklevel,'Value'); 4778 mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); 4779 imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) 4780 imflag=flipdim(imflag,1); 4781 4782 %display the mask 4783 figure; 4784 vec=linspace(0,1,256);%define a linear greyscale colormap 4785 map=[vec' vec' vec']; 4786 colormap(map) 4787 image(imflag); 4788 answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); 4789 if ~strcmp(answer,'Cancel') 4790 mask_dir=fileparts(answer); 4791 if ~exist(mask_dir,'dir') 4792 msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist']) 4793 return 4794 end 4795 imwrite(imflag,answer,'BitDepth',8); 4796 end 4797 set(handles.list_object_1,'Value',1) 4798 set(handles.list_object_1,'Max',1) 4799 end 4800 4801 %set(handles.uvmat,'UserData',UvData); 4864 4802 4865 4803 % ------------------------------------------------------------------ … … 4871 4809 set(handles.edit_vect,'Value',0) 4872 4810 edit_vect_Callback(hObject, eventdata, handles) 4873 set(handles.edit ,'BackgroundColor',[0.7 0.7 0.7])4811 set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) 4874 4812 set(handles.list_object_1,'Value',1) 4875 4813 … … 4886 4824 function MenuSeries_Callback(hObject, eventdata, handles) 4887 4825 %------------------------------------------------------------------- 4888 4826 series; %first display of the GUI to fill waiting time 4889 4827 [param.FileName]=read_file_boxes(handles); 4890 4828 if isequal(get(handles.SubField,'Value'),1) … … 4975 4913 % ------------------------------------------------------------------ 4976 4914 function MenuEditObject_Callback(hObject, eventdata, handles) 4977 set(handles.edit ,'Value',1)4915 set(handles.edit_object,'Value',1) 4978 4916 edit_Callback(hObject, eventdata, handles) 4979 4917 … … 4992 4930 function MenuEditVectors_Callback(hObject, eventdata, handles) 4993 4931 %------------------------------------------------------------------------ 4932 % set(handles.MenuEditVectors,'checked','on') 4994 4933 set(handles.edit_vect,'Visible','on') 4995 4934 set(handles.edit_vect,'Value',1) … … 5092 5031 delete(hset_object)% delete existing version of set_object 5093 5032 end 5094 UvData=get(handles.uvmat,'UserData');5095 [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface5033 % UvData=get(handles.uvmat,'UserData'); 5034 set_object(data);% call the set_object interface 5096 5035 % %position the set_object GUI with respect to uvmat 5097 5036 % pos_uvmat=get(handles.uvmat,'Position'); … … 5101 5040 % set(hset_object,'Position',pos_set_object) 5102 5041 % end 5103 set(handles.edit,'Value',0); %suppress the object edit mode 5104 set(handles.edit,'BackgroundColor',[0.7,0.7,0.7]) 5105 UvData.MouseAction='create_object'; 5106 set(handles.uvmat,'UserData',UvData) 5042 set(handles.edit_object,'Value',0); %suppress the object edit mode 5043 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 5044 set(handles.MenuObject,'checked','on') 5045 %UvData.MouseAction='create_object'; 5046 % set(handles.uvmat,'UserData',UvData) 5107 5047 set(handles.delete_object,'Visible','on') 5108 5048 set(handles.uvmat_title,'Visible','on') … … 5118 5058 end 5119 5059 UvData=get(handles.uvmat,'UserData'); 5120 set(handles.edit ,'Value',0); %suppress the object edit mode5121 set(handles.edit ,'BackgroundColor',[0.7,0.7,0.7])5060 set(handles.edit_object,'Value',0); %suppress the object edit mode 5061 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 5122 5062 data.enable_plot=1; 5123 5063 transform_list=get(handles.transform_fct,'String'); … … 5156 5096 end 5157 5097 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 5158 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface5159 5160 UvData.MouseAction='create_object';5098 set_object(data,PlotHandles);% call the set_object interface 5099 set(handles.MenuObject,'checked','on') 5100 %UvData.MouseAction='create_object'; 5161 5101 set(handles.uvmat,'UserData',UvData) 5162 5102 set(handles.zoom,'Value',0) … … 5171 5111 set(handles.zoom,'Value',0) 5172 5112 zoom_Callback(handles.uvmat, [], handles) 5113 set(handles.MenuRuler,'checked','on') 5173 5114 UvData=get(handles.uvmat,'UserData'); 5174 5115 UvData.MouseAction='ruler';
Note: See TracChangeset
for help on using the changeset viewer.