Changeset 82 for trunk/src


Ignore:
Timestamp:
Apr 15, 2010, 5:12:42 AM (14 years ago)
Author:
sommeria
Message:

mouse_up: improve zoom : keep the selected point at the same place on the graph
plot_field: memorize the max coordiantes on the graph (AxeData?) for zoom out
set_object: input possibilities extende to restrict menu (for mask objects)
uvmat: improvement of mask creation
civ: select mask option for civ2 when select(ed for civ1

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r81 r82  
    295295   end
    296296end
    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);
    298298filebase=fullfile(RootPath,RootFile);
    299299% if isequal(nom_type,'*')% all fields in a single file ( movie files)
     
    355355set(handles.ImaDoc,'String',ext);
    356356if ~isempty(num_i1)
    357     ref_i=num_i1
    358     'TEStbrowse'
    359     num_i2
     357    ref_i=num_i1;
    360358    if ~isempty(num_i2)
    361359        ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file
     
    21092107end
    21102108if isfield(sparam,'CivBin')
    2111     CivBin=sparam.CivBin
     2109    CivBin=sparam.CivBin;
    21122110end
    21132111if isfield(sparam,'Civ1Bin')
     
    23562354                    par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    23572355                    if exist(par_civ1.maskname,'file')
    2358                         par_civ1.maskflag='y'; 
     2356                        par_civ1.maskflag='y';
    23592357                    else
    23602358                        par_civ1.maskname='noFile use default';
     
    26642662            save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
    26652663            %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];
    26672665        end
    26682666      % create the .bat file:
     
    39933991    set(handles.mask_fix2,'String',mask_displ)
    39943992end
     3993set(handles.mask_civ2,'Value',maskval)
    39953994
    39963995%------------------------------------------------------------------------
  • trunk/src/mouse_up.m

    r81 r82  
    213213        end
    214214end
    215 %zoom in if no new figure is created
     215%zoom in by a factor 2 if no new figure is created
    216216if zoomstate
     217    xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    217218     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
    218         %zoom(2)% zoom in by a factor of 2
    219         alpha=0.5; %zoom factor (zoom in by a factor 2)
    220219        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);
    223222        set(currentaxes,'XLim',xlim_new)
    224223        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);
    227226        set(currentaxes,'YLim',ylim_new)
    228227        if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
     
    234233            set(hparentrect,'Position',rect)
    235234        end
    236 
     235     %zoom out by a factor of 2 out when the right mouse button has been used
    237236     elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed
    238             %zoom(0.5)% zoom out by a factor of 2
    239237            alpha=2; %zoom factor (zoom out by a factor 2)
    240238            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;
    243243            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
    246260            set(currentaxes,'XLim',xlim_new)
    247261            set(currentaxes,'YLim',ylim_new)
    248262            %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)
    250264                AxeData.CurrentXLim=xlim;%
    251265            end
     
    338352        display(['UserData of ' objtype ':'])
    339353        evalin('base','CurData') %display CurData in the workspace
    340         commandwindow
     354        commandwindow %brings the Matlab command window to the front
    341355    end
    342356end
  • trunk/src/plot_field.m

    r80 r82  
    10341034    end
    10351035end
    1036 
     1036%store the coordinate extrema occupied by the field
     1037test_lim=0;
     1038if 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
     1048elseif 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;
     1054end
     1055AxeData.RangeX=Xlim;
     1056AxeData.RangeY=Ylim;
    10371057% 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
     1058if ~(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
    10651064        end
    10661065end
  • trunk/src/set_object.m

    r81 r82  
    7676% Choose default command line output for set_object
    7777handles.output = hObject;
    78 'TESTsetobj'
    79 data
    8078% Update handles structure
    8179guidata(hObject, handles);
     
    113111        end
    114112    end
     113    if isfield(data,'StyleMenu')
     114        set(handles.ObjectStyle,'String',data.StyleMenu);
     115    end
    115116    if isfield(data,'Style')
    116117        menu=get(handles.ObjectStyle,'String');
     
    123124    end
    124125    ObjectStyle_Callback(hObject, eventdata, handles)
     126    if isfield(data,'ProjMenu')
     127        set(handles.ProjMode,'String',data.ProjMenu);
     128    end
    125129    if isfield(data,'ProjMode')
    126130        menu=get(handles.ProjMode,'String');
     
    237241        set(handles.DZ,'String',data.DZ)
    238242    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')
    243247             set(handles.MenuCoord,'Value',2)
    244         end
     248%         end
    245249    end
    246250end
  • trunk/src/update_obj.m

    r71 r82  
    6262      end
    6363end
     64
    6465% 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
     66ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
     67if ~isempty(ProjData)   
     68    plotaxes=[];%default
    6969%         get(Object_set{IndexObj}.plotaxes)
    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
     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
    7676%         [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]);
    8382    end
    84 % end
     83end
    8584
    8685
     86
  • trunk/src/uvmat.m

    r81 r82  
    30853085
    30863086%read the rootfile input display
    3087 FileExt=get(handles.FileExt,'String');
     3087[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
    30883088[P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
    30893089NomTypeNew=NomType;%default
     
    31033103        elseif isequal(NomType,'_i1-i2')
    31043104            NomTypeNew='_i';
     3105            % TODO: look for other types
    31053106        end 
    31063107    end
     
    31923193RootPath_1=get(handles.RootPath_1,'String');
    31933194RootFile_1=get(handles.RootFile_1,'String');
    3194 if isempty(RootPath_1)|isequal(RootPath_1,'')
     3195if isempty(RootPath_1)||isequal(RootPath_1,'')
    31953196    set(handles.RootPath_1,'String','"')
    31963197end
    3197 if isempty(RootFile_1) | isequal(RootFile_1,'')
     3198if isempty(RootFile_1) || isequal(RootFile_1,'')
    31983199    set(handles.RootFile_1,'String','"')
    31993200end
    3200 if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
     3201if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
    32013202    RootFile_1(1)=[];
    32023203end
     
    32493250        filebase_1=fullfile(RootPath_1,RootFile_1);
    32503251        SubDir_1=get(handles.SubDir,'String');
    3251         if isempty(SubDir_1)|isequal(SubDir_1,'')
     3252        if isempty(SubDir_1)||isequal(SubDir_1,'')
    32523253            if isfield(UvData,'SubDir_1')
    32533254                SubDir_1=UvData.SubDir_1;%retrieve previous subdir
     
    32563257            end
    32573258        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')
    32593262            NomTypeNew=NomType_1;
    32603263        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);
    32623265             NomTypeNew='#_ab';
    32633266        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);
    32653268            if idetect==1
    32663269                NomTypeNew='_i1-i2_j';
     
    32693272            end
    32703273        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);
    32723275            NomTypeNew='_i1-i2';
    32733276        end           
     
    35873590function save_mask_Callback(hObject, eventdata, handles)
    35883591%-----------------------------------------------------------------------
    3589 huvmat=get(handles.save_mask,'parent');
    3590 UvData=get(huvmat,'UserData');
    3591 
    3592 hpatch=findobj(huvmat,'Type','patch');
     3592UvData=get(handles.uvmat,'UserData');
     3593
    35933594flag=1;
    35943595npx=size(UvData.Field.A,2);
     
    36163617                        [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
    36173618                    end
    3618                     flagobj=~inpolygon(Xi,Yi,X,Y);%=0 inside the polygon, 1 outside                 
     3619                    flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside                 
    36193620                elseif isequal(ObjectData.Style,'ellipse')
    36203621                    if testphys
     
    43114312hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
    43124313set(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);
    43194322% 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
    43464340hother=findobj('Tag','DeformPoint');
    43474341set(hother,'Color','b');
     
    43904384global CurData
    43914385CurData=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
     4386evalin('base','global CurData')%make CurData global in the workspace
     4387display(['current field :'])
    43974388evalin('base','CurData') %display CurData in the workspace
    4398 commandwindow;
     4389commandwindow; %brings the Matlab command window to the front
    43994390
    44004391%------------------------------------------------------
     
    45474538% ------------------------------------------------------------------
    45484539function 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
    45744564UvData=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)
    45834573% set(handles.cal,'Value',0)
    45844574% set(handles.cal,'BackgroundColor',[0 1 0])
    45854575
    45864576%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
     4599ListObj=UvData.Object;
     4600select=zeros(1,numel(ListObj));
     4601for iobj=1:numel(ListObj);
     4602    if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
     4603        select(iobj)=1;
     4604    end
     4605end
     4606val=find(select);
     4607if isempty(val)
     4608    msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
     4609    return
     4610else
     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
     4699end       
     4700     
     4701
     4702% UvData.MouseAction='create_object';
    46144703set(handles.uvmat,'UserData',UvData);
    46154704
     
    47794868create_object(data,handles)
    47804869
     4870%------------------------------------------------------------------------
     4871function MenuMaskObject_Callback(hObject, eventdata, handles)
     4872%------------------------------------------------------------------------
     4873data.Style='polygon';
     4874data.StyleMenu={'polygon'};
     4875data.ProjMode='mask_inside';%default
     4876data.ProjMenu={'mask_inside';'mask_outside'};
     4877create_object(data,handles)
     4878
    47814879% ------------------------------------------------------------------
    47824880function Menuplane_Callback(hObject, eventdata, handles)
     
    48524950set(handles.edit,'BackgroundColor',[0.7,0.7,0.7]) 
    48534951data.enable_plot=1;
    4854 if isfield(UvData,'CoordType')
    4855     data.CoordType=UvData.CoordType;
    4856 end
     4952transform_list=get(handles.transform_fct,'String');
     4953val=get(handles.transform_fct,'Value');
     4954data.CoordType=transform_list{val};
     4955% if isfield(UvData,'CoordType')
     4956%     data.CoordType=UvData.CoordType;
     4957% end
    48574958if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
    48584959    data.RangeX=UvData.Mesh;
     
    49345035
    49355036
    4936 
Note: See TracChangeset for help on using the changeset viewer.