Changeset 508 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jul 31, 2012, 6:55:39 PM (12 years ago)
Author:
sommeria
Message:

various improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r507 r508  
    232232
    233233%% refresh projection plane
    234 set(handles.ListObject,'Value',1)% default: empty projection objectproj_field
    235 set(handles.ListObject,'String',{'plane'})
    236 set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field
    237 set(handles.ListObject_1,'String',{'plane'})
     234% set(handles.ListObject,'Value',1)% default: empty projection objectproj_field
     235% set(handles.ListObject,'String',{''})
     236% set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field
     237% set(handles.ListObject_1,'String',{''})
    238238set(handles.Fields,'Value',1)
    239239set(handles.Fields,'string',{''})
     
    685685    case 'xml'                % edit xml files
    686686        t=xmltree(fileinput);
     687        % the xml file marks a project or project link, open datatree_browser
    687688        if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir')
    688689            datatree_browser(fileinput)
    689         else
     690        else % other xml file, open the xml editor
    690691            editxml(fileinput);
    691692        end
    692         %             if exist(regexprep(fileinput,'.project.xml$','.link'),'dir')
    693         %                 datatree_browser(regexprep(fileinput,'.project.xml$','.link'))
    694         %                 check_project=1;
    695         %         elseif exist(regexprep(fileinput,'.project.xml$',''),'dir')
    696         %                 datatree_browser(regexprep(fileinput,'.project.xml$',''))
    697         %                 check_project=1;
    698         %             end
    699         %         end
    700         %         if ~check_project
    701         %         editxml(fileinput);
    702     case 'xls'
     693    case 'xls'% Excel file opended by editxml
    703694        editxml(fileinput);
    704695    otherwise
     
    833824    return
    834825end
    835 % nbfield=[];%default
    836 % nbfield_j=[];%default
    837826
    838827%% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     
    849838    imainfo=get(VideoObject);
    850839    testima=1;
    851 %     nbfield_j=1;
    852840    TimeUnit='s';
    853841    if isempty(j1_series); %frame index along i
     
    987975            set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
    988976        end
    989         if isfield(GeometryCalib,'SliceCoord')
    990            
     977        if isfield(GeometryCalib,'SliceCoord')           
    991978           siz=size(GeometryCalib.SliceCoord);
    992979           if siz(1)>1
     
    10991086end
    11001087
    1101 %% view the field 
    1102 run0_Callback([],[], handles); %view field
     1088%% apply the effect of the transform fct and view the field 
     1089transform_fct_Callback([],[],handles)
     1090%run0_Callback([],[], handles); %view field
    11031091mask_test=get(handles.CheckMask,'value');
    11041092if mask_test
     
    19351923
    19361924%% determine the main input file information for action
    1937 FileType=[];%default
     1925% UvData.FileType{1}=[];%default
    19381926if ~exist(FileName,'file')
    19391927    errormsg=['input file ' FileName ' does not exist'];
     
    19451933    NomType_1=get(handles.NomType_1,'String');
    19461934end
    1947 % NomType=get(handles.FileIndex,'UserData');
    19481935%update the z position index
    19491936nbslice_str=get(handles.num_NbSlice,'String');
     
    19721959    case {'civx','civdata','netcdf'};
    19731960        list_fields=get(handles.Fields,'String');% list menu fields
    1974 %          index_fields=get(handles.Fields,'Value');% selected string index
    19751961        FieldName= list_fields{get(handles.Fields,'Value')}; % selected field
    19761962        if ~strcmp(FieldName,'get_field...')
     
    22822268set(handles.abs_time,'String',num2str(abstime,5))
    22832269set(handles.abs_time_1,'String',num2str(abstime_1,5))
    2284 % if testimedoc && isfield(UvData,'dt')
    2285 %     dt=UvData.dt;
    2286 % end
    22872270if isempty(dt)||isequal(dt,0)
    22882271    set(handles.Dt_txt,'String','')
     
    23272310    end
    23282311end
    2329     %% check whether tps is needed, then calculate tps coefficients if needed
     2312
     2313%% check whether tps is needed, then calculate tps coefficients if needed
    23302314check_proj_tps=0;
    23312315if isfield(UvData,'Object')&& (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
     
    23392323check_tps=0;         
    23402324if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamOut.FieldName,'velocity')&&~strcmp(ParamOut.FieldName,'get_field...')
    2341        check_tps=1;
     2325       check_tps=1;%tps needed to get the requested field
    23422326end
    23432327if (check_tps ||check_proj_tps)&&~isfield(Field{1},'Coord_tps')
    2344     SubDomain=1000; %default, estimated nbre of vectors in a subdomain used for tps
    2345     if isfield(Field{1},'SubDomain')
    2346         SubDomain=Field{1}.SubDomain;%
    2347     end
    2348     [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
    2349        filter_tps([Field{1}.X(Field{1}.FF==0) Field{1}.Y(Field{1}.FF==0)],Field{1}.U(Field{1}.FF==0),Field{1}.V(Field{1}.FF==0),[],SubDomain,0);
    2350     nbvar=numel(Field{1}.ListVarName);
    2351     Field{1}.ListVarName=[Field{1}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
    2352     Field{1}.VarDimName=[Field{1}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
    2353         {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
    2354     Field{1}.VarAttribute{nbvar+3}.Role='coord_tps';
    2355     Field{1}.VarAttribute{nbvar+4}.Role='vector_x_tps';
    2356     Field{1}.VarAttribute{nbvar+5}.Role='vector_y_tps';
    2357     if isfield(Field{1},'ListDimName')%cleaning
    2358         Field{1}=rmfield(Field{1},'ListDimName');
    2359     end
    2360     if isfield(Field{1},'DimValue')%cleaning
    2361         Field{1}=rmfield(Field{1},'DimValue');
    2362     end
    2363 end
     2328    Field{1}=calc_tps(Field{1});
     2329end
     2330Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    23642331
    23652332%% calculate scalar
    23662333if isstruct(ParamOut)&&~strcmp(ParamOut.FieldName,'get_field...')&& (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))...
    23672334         &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut.FieldName,'get_field...')
    2368     if check_proj_tps
    2369         Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    2370     else
     2335    if ~check_proj_tps
    23712336        Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
    23722337    end
     
    23822347
    23832348%% combine the two input fields (e.g. substract velocity fields)
    2384 %Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    23852349if numel(Field)==2
    23862350   [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); 
     
    25112475    end
    25122476    % default projection plane
    2513     if ~isfield(UvData,'Object')
     2477    if ~isfield(UvData,'Object')||isempty(UvData.Object{1})
    25142478        UvData.Object{1}.Type='plane';%main plotting plane
    25152479        UvData.Object{1}.ProjMode='projection';%main plotting plane
     
    25762540    [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.axes3,read_GUI(handles.uvmat));
    25772541    write_plot_param(handles,PlotParamOut) %update the auto plot parameters
    2578 %     if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
    2579 %         ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
    2580 %     end
    25812542   
    25822543%% 2D or 3D fields are generally projected
     
    25902551    list_object=get(handles.ListObject_1,'String');
    25912552    if isequal(list_object,{''})%refresh list of objects if the menu is empty
    2592         UvData.Object={[]};
     2553        set(handles.ListObject,'Value',1)
     2554        set(handles.ListObject,'String',{'plane'})
     2555        UvData.Object{1}.Type='plane';%main plotting plane
     2556        UvData.Object{1}.ProjMode='projection';%main plotting plane
     2557        UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2558        UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    25932559        set(handles.ListObject_1,'Value',1)
     2560        set(handles.ListObject_1,'String',{'plane'})
    25942561    end
    25952562    IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
     
    26362603    for imap=1:numel(IndexObj)
    26372604        iobj=IndexObj(imap);
    2638         %      if imap==2 || check_proj==0  % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
    2639         % %          [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field);
    2640         % %      else
    26412605        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
    2642         %      end
    26432606        if ~isempty(errormsg)
    26442607            return
     
    27062669                end
    27072670            end
    2708 %             if isequal(PlotType,'none')
    2709 %                 hget_field=findobj(allchild(0),'name','get_field');
    2710 %                 if isempty(hget_field)
    2711 %                     get_field(FileName)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
    2712 %                 end
    2713 %                 errormsg='The field defined by get_field cannot be plotted';
    2714 %                 return
    2715 %             end
    27162671        end
    27172672    end
     
    34243379else
    34253380    set(handles.VOLUME,'BackgroundColor',[0 1 0])
    3426     UvData.MouseAction='none';
     3381%     UvData.MouseAction='none';
    34273382end
    34283383set(handles.uvmat,'UserData',UvData)
     
    34523407    set(handles.record,'Visible','off')
    34533408    set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
    3454 %     UvData.MouseAction='none';
    3455 end
    3456 % set(handles.uvmat,'UserData',UvData)
     3409end
    34573410
    34583411%----------------------------------------------
     
    35463499%-------------------------------------------------------------
    35473500% --- Executes on selection change in transform_fct.
     3501
    35483502function transform_fct_Callback(hObject, eventdata, handles)
    35493503%-------------------------------------------------------------
    35503504UvData=get(handles.uvmat,'UserData');
    3551 menu=get(handles.transform_fct,'String');
     3505menu=get(handles.transform_fct,'String');refresh
    35523506ichoice=get(handles.transform_fct,'Value');%item number in the menu
    35533507transform_name=menu{ichoice};% choice of the transform fct
     
    35553509
    35563510%% add a new item to the menu if the option 'more...' has been selected
     3511prev_path=fullfile(get(handles.path_transform,'String'));
     3512if ~exist(prev_path,'dir')
     3513    prev_path=fullfile(fileparts(which('uvmat')),'transform_field');
     3514end
    35573515if strcmp(transform_name,'more...');
    35583516    [FileName, PathName] = uigetfile( ...
     
    35603518        '*.m',  '.m files '; ...
    35613519        '*.*', 'All Files (*.*)'}, ...
    3562         'Pick the transform function', get(handles.path_transform,'String'));
     3520        'Pick the transform function', prev_path);
    35633521    path_transform_fct =fullfile(PathName,FileName);
    35643522    if ~exist(path_transform_fct,'file')% cancel has been activated
     
    35773535    end
    35783536    list_path{ichoice}=PathName;%update the list fo fct paths
     3537    set(handles.transform_fct,'String',menu)
     3538    set(handles.transform_fct,'Value',ichoice)
    35793539   
    35803540    % save the new menu in the personal file 'uvmat_perso.mat'
     
    35843544        nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat
    35853545        for ilist=nb_builtin+1:numel(list_path)
    3586             transform_fct{ilist-nb_builtin}=fullfile(list_path{ilist},menu{ilist});
     3546            transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m'];
    35873547        end
    35883548        save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
     
    36033563    cd(current_dir)
    36043564end
     3565set(handles.path_transform,'String',list_path{ichoice})
    36053566set(handles.path_transform,'UserData',transform_handle)
    36063567
     
    36183579
    36193580%% adapt the GUI to the input/output conditions of the selected transform fct
    3620 if isempty(list_path{ichoice})% case of no selected fct
    3621     DataOut=[];
    3622 else
    3623     if nargin(transform_handle)>1
    3624         if isfield(UvData,'XmlData')&&~isempty(UvData.XmlData)
    3625             XmlData=UvData.XmlData{1};
    3626             DataOut=feval(transform_handle,'*',XmlData);
    3627         end
     3581DataOut=[];
     3582CoordUnit='';
     3583CoordUnitPrev='';
     3584if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit')
     3585    CoordUnitPrev=UvData.Field.CoordUnit;
     3586end
     3587if ~isempty(list_path{ichoice})
     3588    if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData)
     3589        XmlData=UvData.XmlData{1};
     3590        DataOut=feval(transform_handle,'*',XmlData);
     3591        if isfield(DataOut,'CoordUnit')
     3592            CoordUnit=DataOut.CoordUnit;
     3593        end
     3594        if isfield(DataOut,'InputFieldType')
     3595            UvData.InputFieldType=DataOut.InputFieldType;
     3596        end
     3597    else
     3598        DataOut=feval(transform_handle,'*');
    36283599    end
    36293600end
     
    36323603set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
    36333604
    3634 %% execute the function to set input an output conditions
    3635 
    3636 
    3637 %% delete drawn objects
    3638 hother=findobj('Tag','proj_object');%find all the proj objects
    3639 for iobj=1:length(hother)
    3640     delete_object(hother(iobj))
    3641 end
    3642 hother=findobj('Tag','DeformPoint');%find all the proj objects
    3643 for iobj=1:length(hother)
    3644     delete_object(hother(iobj))
    3645 end
    3646 hh=findobj('Tag','calib_points');
    3647 if ~isempty(hh)
    3648     delete(hh)
    3649 end
    3650 hhh=findobj('Tag','calib_marker');
    3651 if ~isempty(hhh)
    3652     delete(hhh)
    3653 end
    3654 if isfield(UvData,'Object')
    3655      UvData.Object=UvData.Object(1);
    3656 end
    3657 set(handles.ListObject,'Value',1)
    3658 set(handles.ListObject,'String',{'plane'})
    3659 set(handles.ListObject_1,'Value',1)
    3660 set(handles.ListObject_1,'String',{'plane'})
    3661 
    3662 %delete mask if it is displayed
    3663 % if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
    3664 %    UvData=rmfield(UvData,'MaskName'); %will impose mask refresh 
    3665 % end
     3605%% delete drawn objects if the output CooordUnit is different from the previous one
     3606if ~strcmp(CoordUnit,CoordUnitPrev)
     3607    hother=findobj('Tag','proj_object');%find all the proj objects
     3608    for iobj=1:length(hother)
     3609        delete_object(hother(iobj))
     3610    end
     3611    hother=findobj('Tag','DeformPoint');%find all the proj objects
     3612    for iobj=1:length(hother)
     3613        delete_object(hother(iobj))
     3614    end
     3615    hh=findobj('Tag','calib_points');
     3616    if ~isempty(hh)
     3617        delete(hh)
     3618    end
     3619    hhh=findobj('Tag','calib_marker');
     3620    if ~isempty(hhh)
     3621        delete(hhh)
     3622    end
     3623%     if isfield(UvData,'Object')
     3624%         UvData.Object=UvData.Object(1);
     3625%     end
     3626    set(handles.ListObject,'Value',1)
     3627    set(handles.ListObject,'String',{''})
     3628    set(handles.ListObject_1,'Value',1)
     3629    set(handles.ListObject_1,'String',{''})
     3630    set(handles.ViewObject,'value',0)
     3631    ViewObject_Callback(hObject, eventdata, handles)
     3632    set(handles.ViewField,'value',0)
     3633    ViewField_Callback(hObject, eventdata, handles)
     3634    set(handles.edit_object,'Value',0)
     3635    edit_object_Callback(hObject, eventdata, handles)
     3636    UvData.Object={[]};
     3637end
    36663638set(handles.uvmat,'UserData',UvData)
     3639
     3640%% refresh the current plot
    36673641run0_Callback(hObject, eventdata, handles)
    36683642
     
    43414315colorbar
    43424316
    4343 % %------------------------------------------------------
    4344 % % --- Executes on button press in Menu/Export/extract figure.
    4345 % %------------------------------------------------------
    4346 % function MenuExport_plot_Callback(hObject, eventdata, handles)
    4347 % huvmat=get(handles.MenuExport_plot,'parent');
    4348 % UvData=get(huvmat,'UserData');
    4349 % hfig=figure;
    4350 % newaxes=copyobj(handles.axes3,hfig);
    4351 % map=colormap(handles.axes3);
    4352 % colormap(map);%transmit the current colormap to the zoom fig
    4353 % colorbar
    4354 
    4355 %
    4356 % % --------------------------------------------------------------------
    4357 % function Insert_Callback(hObject, eventdata, handles)
    4358 %
     4317% --------------------------------------------------------------------
     4318function MenuExportAxis_Callback(hObject, eventdata, handles)
     4319answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported')
     4320if strcmp(answer,'Yes')
     4321hchild=get(handles.axes3,'children');
     4322copyobj(hchild,gca);
     4323end
    43594324
    43604325%------------------------------------------------------------------------
     
    48794844ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory');
    48804845datatree_browser(ProjectDir)
     4846
     4847
     4848
Note: See TracChangeset for help on using the changeset viewer.