Changeset 1102 for trunk


Ignore:
Timestamp:
May 8, 2021, 11:07:13 AM (4 years ago)
Author:
sommeria
Message:

introduce user defined export function for uvmat

Location:
trunk/src
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r1101 r1102  
    216216path_list{1}='';
    217217for ilist=2:UvData.OpenParam.NbBuiltin
    218 path_list{ilist}=transform_path; % set transform_path to the path_list
    219 end
     218    path_list{ilist}=transform_path; % set transform_path to the path_list
     219end
     220
     221%% EXPORT menu
     222export_menu={'as field in workspace';'in new figure';'on existing axis';'make movie';'more...'};
     223export_path=fullfile(path_uvmat,'export_fct');
    220224
    221225%% load the list of previously browsed files in menus Open, Open_1 and TransformName
     
    238242    end
    239243    if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user
    240         for ilist=1:length(h.transform_fct);
     244        for ilist=1:length(h.transform_fct)
    241245            if exist(h.transform_fct{ilist},'file')
    242246                [path,file]=fileparts(h.transform_fct{ilist});
    243247                transform_menu=[transform_menu; {file}];
    244248                path_list=[path_list; {path}];
     249            end
     250        end
     251    end
     252    if isfield(h,'export_fct') && iscell(h.export_fct) % load the menu of export fct set by user
     253        for ilist=1:length(h.export_fct)
     254            if exist(h.export_fct{ilist},'file')
     255                [path,file]=fileparts(h.export_fct{ilist});
     256                export_menu=[export_menu; {file}];
    245257            end
    246258        end
     
    252264set(handles.TransformPath,'String','')
    253265set(handles.TransformPath,'UserData',[])
     266export_menu=[export_menu;{'more...'}];%append the option more.. to the menu
     267%set(handles.TransformName,'String',transform_menu)% display the menu of transform fcts
    254268
    255269%% case of an input argument for uvmat
     
    877891delete(hObject)
    878892
     893% --------------------------------------------------------------------
     894function MenuExportCustom_Callback(hObject, eventdata, handles)
     895export_fct_name=get(handles.MenuExportCustom,'label');
     896current_dir=pwd;%current working dir
     897cd(fullfile(fileparts(which('uvmat')),'export_fct'))
     898export_handle=str2func(export_fct_name);
     899cd(current_dir)
     900export_handle(handles)
     901       
     902% --------------------------------------------------------------------
     903function MenuExportMore_Callback(hObject, eventdata, handles)
     904
     905prev_path=fullfile(fileparts(which('uvmat')),'export_fct');
     906transform_fct_chosen=uigetfile_uvmat('Pick the export function',prev_path,'.m');
     907if ~isempty(transform_fct_chosen)
     908    [PathName,transform_name]=fileparts(transform_fct_chosen);
     909    set(handles.MenuExportCustom,'label',transform_name)
     910    set(handles.MenuExportCustom,'checked','on')
     911    MenuExportCustom_Callback(hObject, eventdata, handles)
     912end
    879913
    880914%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.