Changeset 252 for trunk/src/civ.m


Ignore:
Timestamp:
May 15, 2011, 11:17:08 PM (13 years ago)
Author:
sommeria
Message:

various bugs corrected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r251 r252  
    6262% Update handles structure
    6363guidata(hObject, handles);
    64 set(hObject,'WindowButtonUpFcn',{'mouse_up_GUI',handles}) %set mouse action (zoom on uicontrols)
     64set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display)
    6565%default initial parameters
    6666filebase=''; % root file name ('filebase'.civ)
    6767ext=[];
    6868set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'})
     69set(handles.subdomain_patch1,'String','1500')% default values
     70set(handles.subdomain_patch2,'String','1500')
     71delete(handles.grid_patch1)
     72delete(handles.get_gridpatch1)
     73delete(handles.grid_patch2)
     74delete(handles.get_gridpatch2)
     75
    6976%default input parameters:
    7077num_i1=1; % set of field i numbers
     
    447454%------------------------------------------------------------------------
    448455set(handles.compare,'Visible','on')
    449 %ext_ima=get(handles.ImaExt,'String');
    450456ext_ima='';%default
    451457nom_type_ima=[];%default
     
    472478    field_count=browse.num_i1;% get an image index type already determined by an input file
    473479end
     480set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS)
    474481
    475482%default first_i and j and increments
     
    11611168    mode='displacement';
    11621169else
    1163     mode_list=get(handles.mode,'String');
    1164     mode_value=get(handles.mode,'Value');
     1170    mode_list=get(handles.mode,'String')
     1171    mode_value=get(handles.mode,'Value')
    11651172    mode=mode_list{mode_value};
    11661173end
     
    21582165                Param.Civ2=par_civ2;
    21592166            end
     2167            if box_test(5)==1
     2168                fix2.WarnFlags=[];
     2169                if get(handles.vec_Fmin2_2,'Value')
     2170                    fix2.WarnFlags=[fix2.WarnFlags -2];
     2171                end
     2172                if get(handles.vec_F4,'Value')
     2173                    fix2.WarnFlags=[fix2.WarnFlags 4];
     2174                end
     2175                if get(handles.vec_F3_2,'Value')
     2176                    fix2.WarnFlags=[fix2.WarnFlags 3];
     2177                end
     2178                fix2.LowerBoundCorr=thresh_vec2C;
     2179                if get(handles.inf_sup2,'Value')
     2180                    fix2.UppperBoundVel=thresh_vel2;
     2181                else
     2182                    fix2.LowerBoundVel=thresh_vel2;
     2183                end   
     2184                if get(handles.get_mask_fix2,'Value')
     2185                    fix2.MaskName=maskname;
     2186                end     
     2187                Param.Fix2=fix2;
     2188            end
    21602189            [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j});
    21612190            if isempty(errormsg)
     
    25092538                [xx,msg1]=mkdir(subdir_civ1_new);
    25102539                            cd(currentdir);
    2511                 if ~strcmpl(msg1,'')
     2540                if ~strcmp(msg1,'')
    25122541                    msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])
    25132542                    cd(currentdir)
     
    32503279function get_mask_civ1_Callback(hObject, eventdata, handles)
    32513280%------------------------------------------------------------------------
    3252 maskval=get(handles.get_mask_civ1,'Value');
     3281maskval=get(handles.get_mask_civ1,'Value')
    32533282if isequal(maskval,0)
    32543283    set(handles.mask_civ1,'String','')
     
    35073536    str=num2str(num);
    35083537end
    3509 
    3510 % %------------------------------------------------------------------------
    3511 % function mask_civ1_Callback(hObject, eventdata, handles)
    3512 % %------------------------------------------------------------------------
    3513 % set(handles.mask_civ1,'UserData',[])
    3514 % set(handles.mask_civ1,'String','')
    3515 %
    3516 % %------------------------------------------------------------------------
    3517 % function mask_civ2_Callback(hObject, eventdata, handles)
    3518 % %------------------------------------------------------------------------
    3519 % set(handles.mask_civ2,'UserData',[])
    3520 % set(handles.mask_civ2,'String','')
    3521 %
    3522 % %------------------------------------------------------------------------
    3523 % function mask_fix1_Callback(hObject, eventdata, handles)
    3524 % %------------------------------------------------------------------------
    3525 % set(handles.mask_fix1,'UserData',[])
    3526 % set(handles.mask_fix1,'String','')
    3527 %
    3528 % %------------------------------------------------------------------------
    3529 % function mask_fix2_Callback(hObject, eventdata, handles)
    3530 % %------------------------------------------------------------------------
    3531 % set(handles.mask_fix2,'UserData',[])
    3532 % set(handles.mask_fix2,'String','')
    35333538
    35343539%------------------------------------------------------------------------
     
    37843789% if ~isempty(patch_newBin)
    37853790set(handles.test_interp,'Visible','off');
     3791stereo_test=get(handles.compare,'Value');
     3792if stereo_test==3
     3793    set(handles.test_stereo1,'Visible','on')
     3794end
    37863795% end
    3787 set(handles.get_gridpatch1,'Visible','on')
    3788 set(handles.grid_patch1,'string','none');
    3789 set(handles.grid_patch1,'Visible','on')
     3796%set(handles.get_gridpatch1,'Visible','on')
     3797%set(handles.grid_patch1,'string','none');
     3798%set(handles.grid_patch1,'Visible','on')
    37903799
    37913800%------------------------------------------------------------------------
     
    38033812set(handles.nx_patch1_title,'Visible','off')
    38043813set(handles.ny_patch1_title,'Visible','off')
     3814set(handles.test_stereo1,'Visible','off')
    38053815%set(handles.test_interp,'Visible','off')
    3806 set(handles.get_gridpatch1,'Visible','off')
    3807 set(handles.grid_patch1,'Visible','off')
     3816%set(handles.get_gridpatch1,'Visible','off')
     3817%set(handles.grid_patch1,'Visible','off')
    38083818
    38093819%------------------------------------------------------------------------
     
    39343944set(handles.nx_patch2_title,'Visible','on')
    39353945set(handles.ny_patch2_title,'Visible','on')
    3936 set(handles.get_gridpatch2,'Visible','on')
    3937 set(handles.grid_patch2,'Visible','on')
     3946% set(handles.get_gridpatch2,'Visible','on')
     3947% set(handles.grid_patch2,'Visible','on')
    39383948set(handles.list_pair_civ2,'Visible','on')
    39393949set(handles.subdir_civ2,'Visible','on')
    39403950set(handles.subdir_civ2_text,'Visible','on')
     3951stereo_test=get(handles.compare,'Value');
     3952if stereo_test==3
     3953    set(handles.test_stereo2,'Visible','on')
     3954end
    39413955
    39423956%------------------------------------------------------------------------
     
    39543968set(handles.nx_patch2_title,'Visible','off')
    39553969set(handles.ny_patch2_title,'Visible','off')
    3956 set(handles.get_gridpatch2,'Visible','off')
    3957 set(handles.grid_patch2,'Visible','off')
     3970% set(handles.get_gridpatch2,'Visible','off')
     3971% set(handles.grid_patch2,'Visible','off')
    39583972if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0)
    39593973    set(handles.list_pair_civ2,'Visible','off')
     
    39613975    set(handles.subdir_civ2_text,'Visible','off')
    39623976end
    3963 
     3977set(handles.test_stereo2,'Visible','off')
    39643978%------------------------------------------------------------------------
    39653979function enable_pair1(handles,state)
     
    45184532    set(handles.test_stereo2,'Value',0)
    45194533end
     4534if test==3 && get(handles.PATCH1,'Value')
     4535    set(handles.stereo1,'Visible','on')
     4536else
     4537    set(handles.stereo1,'Visible','off')
     4538end
     4539if test==3 && get(handles.PATCH2,'Value')
     4540    set(handles.stereo2,'Visible','on')
     4541else
     4542    set(handles.stereo2,'Visible','off')
     4543end
    45204544mode_Callback(hObject, eventdata, handles)
    45214545
     
    47104734    Param.Civ1=par_civ1;
    47114735    Data=civ_uvmat(Param);
    4712 %     stepx=str2num(par_civ1.dx);
    4713 %     stepy=str2num(par_civ1.dy);
    4714 %     ibx2=ceil(str2num(par_civ1.ibx)/2);
    4715 %     iby2=ceil(str2num(par_civ1.iby)/2);
    4716 %     isx2=ceil(str2num(par_civ1.isx)/2);
    4717 %     isy2=ceil(str2num(par_civ1.isy)/2);
    4718 %     shiftx=str2num(par_civ1.shiftx);
    4719 %     shifty=str2num(par_civ1.shifty);
    4720 % %             ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
    4721 % %             iby=2*iby2-1;
    4722 %     miniy=max(1+isy2-shifty,1+iby2)
    4723 %     minix=max(1+isx2-shiftx,1+ibx2)
    4724 %     maxiy=min(size(Data.A,1)-isy2-shifty,size(Data.A,1)-iby2)
    4725 %     maxix=min(size(Data.A,2)-isx2-shiftx,size(Data.A,2)-ibx2)
    4726 % %             maxix=stepx*(floor(size(image1_roi,2)/stepx))-(2*ibx2-2)+ibx2;
    4727 %     [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
    4728 %     PointCoord(:,1)=reshape(GridX,[],1);
    4729 %     PointCoord(:,2)=reshape(GridY,[],1);
    47304736    Data.ListVarName=[Data.ListVarName {'ny','nx','A'}];
    47314737    Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}];
     
    47374743    hhview_field=guihandles(hview_field);
    47384744    set(hview_field,'CurrentAxes',hhview_field.axes3)
    4739     %hpoints=line(PointCoord(:,1),PointCoord(:,2),'Color','y','LineStyle','.','Marker','*','LineWidth',4,'Tag','grid_points');
    47404745    ViewData=get(hview_field,'UserData');
    47414746    ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field
     
    47744779val=get(handles.status,'Value');
    47754780if val==0
     4781    set(handles.status,'BackgroundColor',[0 1 0])
    47764782    hfig=findobj(allchild(0),'name','civ_status');
    47774783    if ~isempty(hfig)
     
    47804786    return
    47814787end
     4788set(handles.status,'BackgroundColor',[1 1 0])
     4789drawnow
    47824790listtype={'civ1','fix1','patch1','civ2','fix2','patch2'};
    47834791box_test(1)=get(handles.CIV1,'Value');
     
    47884796box_test(6)=get(handles.PATCH2,'Value');
    47894797option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test)
    4790 filecell=get(handles.civ,'UserData');
     4798filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV
     4799test_new=0;
    47914800if ~isfield(filecell,'nc')
     4801    test_new=1;
    47924802    [ref_i,ref_j,errormsg]=find_ref_indices(handles);
    47934803    if ~isempty(errormsg)
     
    47954805        return
    47964806    end
    4797     filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the list of output files expected from the GUI status
    4798 end
    4799 
     4807    filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status
     4808end
    48004809if ~isequal(box_test(4:6),[0 0 0])
    4801     civ_files=filecell.nc.civ2;
     4810    civ_files=filecell.nc.civ2;%case of civ2 operations
    48024811else
    48034812    civ_files=filecell.nc.civ1;
     
    48074816hfig=findobj(allchild(0),'name','civ_status');
    48084817if isempty(hfig)
    4809     hfig=figure;
     4818    hfig=figure('DeleteFcn',@stop_status);
    48104819    set(hfig,'name','civ_status')
    48114820    hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
    4812     uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox');
     4821    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    48134822    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    48144823    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
    48154824    BarPosition=[0.05 0.81 0.01 0.05];
    48164825    hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     4826    drawnow
    48174827end
    48184828% datnum=[];
     
    48764886        [first,ind]=min(datnum);
    48774887        [last,indlast]=max(datnum);
     4888        if test_new
     4889            message='existing file status, no processing launched yet';
     4890        else
    48784891        message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    48794892            ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
     4893        end
    48804894    end
    48814895    hfig=findobj(allchild(0),'name','civ_status');
    4882     if isempty(hfig)
    4883         set(handles.status,'Value',0)%stop program if the figure has been suppressed
     4896    if isempty(hfig)% the status list has been deleted
    48844897        return
    48854898    else
     
    48894902        set(hlist,'String',Tabchar)
    48904903        set(hmsgbox,'String', message)
    4891         if count>0
     4904        if count>0 && ~test_new
    48924905            BarPosition(3)=0.9*count/nbfiles;
    48934906            set(hwaitbar,'Position',BarPosition)
     
    48954908    end
    48964909    set(hlist,'UserData',rootroot)
    4897     pause(5)% wait 5 seconds for next check
     4910    pause(10)% wait 10 seconds for next check
    48984911end
    48994912
    49004913   
    4901 %-------------------------------------------------------------------   
    4902 % call 'view_field.fig' to display the selected field
     4914%------------------------------------------------------------------------   
     4915% call 'view_field.fig' to display the  field selected in the list of 'status'
    49034916function open_view_field(hObject, eventdata)
    4904 %-------------------------------------------------------------------
    4905      list=get(hObject,'String');
    4906      index=get(hObject,'Value');
    4907      rootroot=get(hObject,'UserData');
    4908      filename=list{index};
    4909      ind_dot=findstr(filename,'...');
    4910      filename=filename(1:ind_dot-1);
    4911       filename=fullfile(rootroot,filename);
    4912       delete(get(hObject,'parent'))%delete the display figure to stop the check process
    4913       if exist(filename,'file')%visualise the vel field if it exists
    4914         uvmat(filename)
    4915         set(gcbo,'Value',1)
    4916       end
    4917 
    4918 %-------------------------------------------------------------------   
    4919 % call 'view_field.fig' to display the selected field
     4917%------------------------------------------------------------------------
     4918list=get(hObject,'String');
     4919index=get(hObject,'Value');
     4920rootroot=get(hObject,'UserData');
     4921filename=list{index};
     4922ind_dot=findstr(filename,'...');
     4923filename=filename(1:ind_dot-1);
     4924filename=fullfile(rootroot,filename);
     4925delete(get(hObject,'parent'))%delete the display figure to stop the check process
     4926if exist(filename,'file')%visualise the vel field if it exists
     4927    uvmat(filename)
     4928    set(gcbo,'Value',1)
     4929end
     4930
     4931%------------------------------------------------------------------------   
     4932% launched by pressing OK on the status figure
    49204933function close_GUI(hObject, eventdata)
    4921 %-------------------------------------------------------------------
    4922      delete(gcbf)
    4923 
    4924 
     4934%------------------------------------------------------------------------
     4935    delete(gcbf)
     4936   
     4937%------------------------------------------------------------------------   
     4938% launched by deleting the status figure
     4939function stop_status(hObject, eventdata)
     4940%------------------------------------------------------------------------
     4941hciv=findobj(allchild(0),'tag','civ');
     4942hhciv=guidata(hciv);
     4943set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
     4944set(hhciv.status,'BackgroundColor',[0 1 0])
     4945
     4946%------------------------------------------------------------------------
    49254947% --- Executes on button press in CivAll.
    49264948function CivAll_Callback(hObject, eventdata, handles)
     4949%------------------------------------------------------------------------
    49274950Listprog=get(handles.CivAll,'String');
    49284951index=get(handles.CivAll,'Value');
     
    49324955        set(handles.thresh_patch1,'Visible','off')
    49334956        set(handles.thresh_text1,'Visible','off')
     4957        set(handles.thresh_patch2,'Visible','off')
     4958        set(handles.thresh_text2,'Visible','off')
    49344959        set(handles.rho,'Style','edit')
    49354960        set(handles.rho,'String','1')
     4961        set(handles.BATCH,'Enable','on')
    49364962    case 'CivAll'
    49374963        if get(handles.PATCH1,'Value')
     
    49414967        set(handles.rho,'Style','edit')
    49424968        set(handles.rho,'String','1')
     4969        set(handles.BATCH,'Enable','on')
    49434970    case 'CivUvmat'
    49444971        if get(handles.PATCH1,'Value')
     
    49464973            set(handles.thresh_text1,'Visible','on')
    49474974        end
     4975        if get(handles.PATCH2,'Value')
     4976            set(handles.thresh_patch2,'Visible','on')
     4977            set(handles.thresh_text2,'Visible','on')
     4978        end
    49484979        set(handles.rho,'Style','popupmenu')
    49494980        set(handles.rho,'Value',1)
    49504981        set(handles.rho,'String',{'1';'2'})
    4951 end
    4952 
     4982        set(handles.BATCH,'Enable','off')
     4983end
     4984
Note: See TracChangeset for help on using the changeset viewer.