Changeset 155


Ignore:
Timestamp:
Dec 19, 2010, 10:08:38 PM (14 years ago)
Author:
sommeria
Message:

many bug repairs and corrections for mouse action

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r153 r155  
    9999%                                                                ObjectData
    100100%                                                                    |
    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                                        |
    103103%                                                                    |
    104104%                                                                AxeData
     
    116116% name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
    117117% 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
    119119     
    120120% Properties attached to plotting figures (standard Matlab properties):
     
    130130%    'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
    131131%     AxeData:=get(gca,'UserData');
    132 %     AxeData.Drawing  = create: create a new edit
    133 %                       = deform: modify an existing edit by moving its defining create
     132%     AxeData.Drawing  = create: create a new object
     133%                       = deform: modify an existing object by moving its defining create
    134134%                      = off: no current drawing action
    135 %                     = translate: translate an existing edit
    136 %                    = 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
    139139%            .CurrentLine: currently drawn menuline (A REVOIR)
    140 %            .CurrentObject: handle of the currently drawn edit
     140%            .CurrentObject: handle of the currently drawn edit_object
    141141%            .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 vector
    145 %            .C:
    146 %            .F:
    147 %            .FF:
    148 %            .A
    149142
    150143% Properties attached to projection objects (create, menuline, menuplane...):
    151 %    'Tag'='proj_edit': for all projection objects
    152 %    ObjectData.Style=...: style of projection edit:
     144%    'Tag'='proj_object': for all projection objects
     145%    ObjectData.Style=...: style of projection object:
    153146%              .ProjMode
    154 %              .Coord: defines the position of the edit
     147%              .Coord: defines the position of the object
    155148%              .XMin,YMin....
    156149%              .XMax,YMax....
    157150%              .DX,DY,DZ
    158151%              .Phi, .Theta, .Psi : Euler angles
    159 %              .X,.Y,.U,.V.... : field data projected on the edit
     152%              .X,.Y,.U,.V.... : field data projected on the object
    160153%              .IndexObj: index in the list of UvData.Object
    161154           %during plotting
     
    378371        set(handles.MenuTools,'Enable','on')
    379372        set(handles.OBJECT_txt,'Visible','on')
    380         set(handles.edit,'Visible','on')
     373        set(handles.edit_object,'Visible','on')
    381374        set(handles.list_object_1,'Visible','on')
    382375        set(handles.frame_object,'Visible','on')
     
    604597        set(handles.MenuTools,'Enable','on')
    605598        set(handles.OBJECT_txt,'Visible','on')
    606         set(handles.edit,'Visible','on')
     599        set(handles.edit_object,'Visible','on')
    607600        set(handles.list_object_1,'Visible','on')
    608601        set(handles.frame_object,'Visible','on')
     
    13311324        set(handles.pycm,'String','var')
    13321325    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
    13371332    end
    13381333end
     
    27032698for imap=1:numel(IndexObj)
    27042699    iobj=IndexObj(imap);   
    2705     [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj},iobj);% project field on the object
     2700    [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
    27062701    if ~isempty(errormsg)
    27072702        return
     
    27592754            [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap});
    27602755            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)
    27622757                ObjectData.Mesh=UvData.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
    27632758            end
     
    28672862    [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
    28682863    num_i2=str2double(str2);
    2869     if isempty(num_i2)
     2864    if isnan(num_i2)
    28702865        num_i2=num_i1;
    28712866    end
    28722867    num_j1=str2double(str_a);
    2873     if isempty(num_j1)
     2868    if isnan(num_j1)
    28742869        num_j1=1;
    28752870    end
    28762871    num_j2=str2double(str_b);
    2877     if isempty(num_j2)
     2872    if isnan(num_j2)
    28782873        num_j2=num_j1;
    28792874    end
     
    30042999% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
    30053000filename=read_file_boxes(handles);
    3006 AxeData=get(gca,'UserData');
    30073001[erread,message]=fileattrib(filename);
    30083002if ~isempty(message) && ~isequal(message.UserWrite,1)
     
    30263020end
    30273021%write fix flags in the netcdf file
     3022UvData=get(handles.uvmat,'UserData');
    30283023hhh=which('netcdf.open');% look for built-in matlab netcdf library
    30293024if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
     
    30383033    end
    30393034    netcdf.endDef(nc)
    3040     netcdf.putVar(nc,varid,AxeData.FF);
     3035    netcdf.putVar(nc,varid,UvData.axes3.FF);
    30413036    netcdf.close(nc) 
    30423037else %old netcdf library
     
    30443039end
    30453040
     3041%-------------------------------------------------------------------
     3042%----Correct the netcdf file, using toolbox (old versions of Matlab).
     3043%-------------------------------------------------------------------
    30463044function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
    30473045nc=netcdf(filename,'write'); %open netcdf file
     
    37263724    set(handles.edit_vect,'Value',0)
    37273725    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])
    37303728%     set(handles.cal,'Value',0)
    37313729%     set(handles.cal,'BackgroundColor',[0 1 0])
     
    37533751    PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    37543752    [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 axes
     3753                                                      % associate the set_object interface handle to the plotting axes
    37563754    if isfield(UvData,'SetObjectOrigin')                                               
    37573755    pos_uvmat=get(huvmat,'Position');
     
    37703768function edit_vect_Callback(hObject, eventdata, handles)
    37713769%-------------------------------------------------------
    3772 
    3773 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     3770%
     3771% UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    37743772if isequal(get(handles.edit_vect,'Value'),1)
    37753773    test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
     
    37803778    set(handles.record,'Visible','on')
    37813779    set(handles.edit_vect,'BackgroundColor',[1 1 0])
    3782     set(handles.edit,'Value',0)
     3780    set(handles.edit_object,'Value',0)
    37833781    set(handles.zoom,'Value',0)
    37843782    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
    37853783%     set(handles.create,'Value',0)
    37863784%     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])
    37883786    set(gcf,'Pointer','arrow')
    3789     UvData.MouseAction='edit_vect';
     3787%     UvData.MouseAction='edit_vect';
    37903788else
    37913789    set(handles.record,'Visible','off')
    37923790    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';
     3792end
     3793% set(handles.uvmat,'UserData',UvData)
    37963794
    37973795%----------------------------------------------
     
    43784376
    43794377%-------------------------------------------------------------------
    4380 % --- Executes on selection change in edit.
    4381 function edit_Callback(hObject, eventdata, handles)
     4378% --- Executes on selection change in edit_object.
     4379function edit_object_Callback(hObject, eventdata, handles)
    43824380%-------------------------------------------------------------------
    43834381UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    4384 test=get(handles.edit,'Value');
     4382test=get(handles.edit_object,'Value');
    43854383if test
    4386     UvData.MouseAction='edit_object';
    4387     set(handles.edit,'BackgroundColor',[1,1,0]) 
     4384    set(handles.edit_object,'BackgroundColor',[1,1,0]) 
    43884385    %suppress the other options
    43894386    set(handles.zoom,'Value',0)
    43904387    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)
    43944388else
    43954389    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])   
    43974391end
    43984392set(handles.uvmat,'UserData',UvData);
     
    44464440ObjectData=UvData.Object{IndexObj};
    44474441ObjectData.Name=ObjectName;
    4448 if isequal(get(handles.edit,'Value'),1)
     4442if isequal(get(handles.edit_object,'Value'),1)
    44494443    ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
    44504444end
    4451 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    44524445ZBounds=0; % default
    44534446    if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
     
    44594452    delete(hset_object)% delete existing version of set_object
    44604453end
    4461 hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
    4462 %set(hset_object,'name',ObjectName)
     4454hset_object=set_object(ObjectData,[],ZBounds);% call the set_object interface,
    44634455
    44644456% %project the current field on the object and plot it
    4465 ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
     4457ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    44664458if 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;
     4461else
     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;
     4470end
     4471if ~isempty(ProjData)
     4472plot_field(ProjData,PlotHandles.axes3,PlotHandles);
    44734473end
    44744474set(handles.uvmat,'UserData',UvData)
     
    44924492set(hother,'Color','b');
    44934493set(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');
     4494if 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');
    44994499            if isequal(linetype,'line')
    4500                 set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
     4500                set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color
    45014501            elseif isequal(linetype,'rectangle')
    4502                 set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
     4502                set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color
    45034503            elseif isequal(linetype,'patch')
    4504                 set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
     4504                set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color
    45054505            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)
    45084508                uistack(SubObjectData.SubObject,'top')
    45094509                for iobj=1:length(SubObjectData.SubObject)
     
    45204520                end
    45214521            end
    4522             if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
     4522            if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
    45234523                set(SubObjectData.DeformPoint,'Color','m')
    45244524            end
    45254525        end
    4526     end
     4526%     end
    45274527end
    45284528pause(0.1)
     
    46584658% ------------------------------------------------------------------
    46594659function MenuCalib_Callback(hObject, eventdata, handles)
     4660%geometry_calib; %display the GUI as a  waiting display
    46604661
    46614662UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     
    46644665set(handles.zoom,'Value',0)
    46654666set(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')
    46704671set(handles.list_object_1,'Value',1)     
    46714672% initiate display of GUI geometry_calib
     
    46784679pos(2)=pos(2)-0.02;
    46794680[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 
     4681set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
    46834682if isfield(UvData,'CalOrigin')
     4683    pos_uvmat=get(handles.uvmat,'Position');
    46844684    pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
    46854685    pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
    46864686    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)
     4688end
     4689geometry_calib(FileName,pos_cal);% call the geometry_calib interface   
     4690set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
     4691set(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);
    46914695
    46924696
    46934697% ------------------------------------------------------------------
    46944698function 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 yellow
    4700 % 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_slice
    4705 %         list_index{ilist,1}=num2str(ilist);
    4706 %     end   
    4707 %     set(handles.masklevel,'String',list_index)
    4708 %     val=str2num(get(handles.z_index,'String'));
    4709 %     if val<=nb_slice
    4710 %         set(handles.masklevel,'Value',val)
    4711 %     end
    4712 % else
    4713 %     set(handles.masklevel,'String',{'1'})
    4714 %     set(handles.masklevel,'Value',1)
    4715 % end
    4716 % if ishandle(handles.UVMAT_title)
    4717 %     delete(handles.UVMAT_title)
    4718 % end
    47194699UvData=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_object
    4732 % data.TITLE='MASK';
    4733 % if isfield(UvData,'CoordType')
    4734 %     data.CoordType=UvData.CoordType;
    4735 % end
    4736 % 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 image
    4739 %     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 % end
    4745 % data.Coord=[0 0 0]; %default
    4746 % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
    4747 % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
    4748 % 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 % end
    47544700ListObj=UvData.Object;
    47554701select=zeros(1,numel(ListObj));
     
    47664712    set(handles.list_object_1,'Max',2);%allow multiple selection
    47674713    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;
    48194730                    end
    48204731                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
    48214764            end
    48224765        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)
     4799end
     4800
     4801%set(handles.uvmat,'UserData',UvData);
    48644802
    48654803% ------------------------------------------------------------------
     
    48714809set(handles.edit_vect,'Value',0)
    48724810edit_vect_Callback(hObject, eventdata, handles)
    4873 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     4811set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
    48744812set(handles.list_object_1,'Value',1)     
    48754813
     
    48864824function MenuSeries_Callback(hObject, eventdata, handles)
    48874825%-------------------------------------------------------------------
    4888 
     4826series; %first display of the GUI to fill waiting time
    48894827[param.FileName]=read_file_boxes(handles);
    48904828if isequal(get(handles.SubField,'Value'),1)
     
    49754913% ------------------------------------------------------------------
    49764914function MenuEditObject_Callback(hObject, eventdata, handles)
    4977 set(handles.edit,'Value',1)
     4915set(handles.edit_object,'Value',1)
    49784916edit_Callback(hObject, eventdata, handles)
    49794917
     
    49924930function MenuEditVectors_Callback(hObject, eventdata, handles)
    49934931%------------------------------------------------------------------------
     4932% set(handles.MenuEditVectors,'checked','on')
    49944933set(handles.edit_vect,'Visible','on')
    49954934set(handles.edit_vect,'Value',1)
     
    50925031    delete(hset_object)% delete existing version of set_object
    50935032end
    5094 UvData=get(handles.uvmat,'UserData');
    5095 [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
     5033% UvData=get(handles.uvmat,'UserData');
     5034set_object(data);% call the set_object interface
    50965035% %position the set_object GUI with respect to uvmat
    50975036% pos_uvmat=get(handles.uvmat,'Position');
     
    51015040%     set(hset_object,'Position',pos_set_object)
    51025041% 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)
     5042set(handles.edit_object,'Value',0); %suppress the object edit mode
     5043set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
     5044set(handles.MenuObject,'checked','on')
     5045%UvData.MouseAction='create_object';
     5046% set(handles.uvmat,'UserData',UvData)
    51075047set(handles.delete_object,'Visible','on')
    51085048set(handles.uvmat_title,'Visible','on')
     
    51185058end
    51195059UvData=get(handles.uvmat,'UserData');
    5120 set(handles.edit,'Value',0); %suppress the object edit mode
    5121 set(handles.edit,'BackgroundColor',[0.7,0.7,0.7]) 
     5060set(handles.edit_object,'Value',0); %suppress the object edit mode
     5061set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    51225062data.enable_plot=1;
    51235063transform_list=get(handles.transform_fct,'String');
     
    51565096end
    51575097PlotHandles=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 interface
    5159 
    5160 UvData.MouseAction='create_object';
     5098set_object(data,PlotHandles);% call the set_object interface
     5099set(handles.MenuObject,'checked','on')
     5100%UvData.MouseAction='create_object';
    51615101set(handles.uvmat,'UserData',UvData)
    51625102set(handles.zoom,'Value',0)
     
    51715111set(handles.zoom,'Value',0)
    51725112zoom_Callback(handles.uvmat, [], handles)
     5113set(handles.MenuRuler,'checked','on')
    51735114UvData=get(handles.uvmat,'UserData');
    51745115UvData.MouseAction='ruler';
Note: See TracChangeset for help on using the changeset viewer.