Changeset 781 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 29, 2014, 6:17:00 PM (10 years ago)
Author:
sommeria
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r778 r781  
    190190LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
    191191set(hObject,'Position',[LeftX LowY Width Height])
    192 UvData.OpenParam.PosColorbar=[0.80 0.02 0.018 0.445];
     192UvData.PosColorbar=[0.80 0.02 0.018 0.445];
    193193AxeData.LimEditBox=1; %initialise AxeData
    194194set(handles.PlotAxes,'UserData',AxeData)
     
    373373    set(handles.TableDisplay,'Position',pos_1)
    374374    % reset position of CheckTable
    375     set(handles.CheckTable,'Unit','pixels')
     375    set(handles.CheckTable,'Units','pixels')
    376376pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
    377377pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
     
    20772077% in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i)
    20782078errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    2079 
     2079ResizeFcn(handles.uvmat,[],handles)
    20802080if isempty(errormsg)
    20812081    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
     
    26482648        PlotParam{1}.Vectors.ColorCode= {'rgb'};
    26492649    end
    2650     PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
     2650    %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
    26512651   
    26522652    %% second projection object (view_field display)
     
    26572657            haxes(2)=plot_handles{2}.PlotAxes;
    26582658            PlotParam{2}=read_GUI(view_field_handle);
    2659             PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
     2659            %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    26602660        end
    26612661    end
     
    27202720                view_field(ObjectData)
    27212721            else
    2722               %  ObjectData.VarAttribute{5}.Role='scalar';TODO    CORRECT
    2723                 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
     2722                [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap});
    27242723                if imap==1
    27252724                    errormsg=fill_GUI(PlotParamOut,handles.uvmat);
     
    27952794    CheckEditObject_Callback(handles.uvmat, [], handles)
    27962795end   
    2797 ResizeFcn(handles.uvmat,[],handles)
     2796%ResizeFcn(handles.uvmat,[],handles)
    27982797set(handles.uvmat,'Pointer',pointer)
    27992798
     
    42324231%------------------------------------------------------------------------
    42334232%get the image of the color display button 'VecColBar' in pixels
    4234 set(handles.VecColBar,'Unit','pixel');
     4233set(handles.VecColBar,'Units','pixel');
    42354234pos_vert=get(handles.VecColBar,'Position');
    4236 set(handles.VecColBar,'Unit','Normalized');
     4235set(handles.VecColBar,'Units','Normalized');
    42374236width=ceil(pos_vert(3));
    42384237height=ceil(pos_vert(4));
     
    46574656% --------------------------------------------------------------------
    46584657function MenuExportAxis_Callback(hObject, eventdata, handles)
     4658% --------------------------------------------------------------------   
    46594659ListFig=findobj(allchild(0),'Type','figure');
    46604660nb_option=0;
     
    47154715% --------------------------------------------------------------------
    47164716set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
    4717 huvmat=get(handles.InputFileREFRESH,'parent');
    4718 % UvData=get(huvmat,'UserData');
    4719 %[xx,xx,FileBase]=read_file_boxes(handles);
     4717
    47204718[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    47214719FileBase=fullfile(RootPath,RootFile);
    4722  %read the current input file name
    4723 prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'};
    4724 dlg_title = 'select properties of the output avi movie';
    4725 num_lines= 1;
    4726 def     = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
    4727 answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
    4728 aviname=answer{1};
    4729 fps=str2double(answer{2});
    4730 % check for existing file with output name aviname
    4731 if exist(aviname,'file')
    4732     backup=aviname;
     4720
     4721%% create a fig and axis for movies
     4722figure_movie=findobj(allchild(0),'name','figure_movie');
     4723
     4724if ~isempty(figure_movie)
     4725    delete(figure_movie)%delete existing figure_movie
     4726end
     4727figure_movie=figure;
     4728nbpix=[512 384];% resolution XVGA
     4729set(figure_movie,'name','figure_movie','Position',[1 1 nbpix])
     4730newaxes=copyobj(handles.PlotAxes,figure_movie);%new plotting axes in the new figure
     4731set(newaxes,'Tag','movieaxes')
     4732
     4733%% display time if defined in uvmat
     4734time_str=get(handles.TimeValue,'String');
     4735if ~isempty(time_str)
     4736    htitle=get(newaxes,'Title');
     4737%     xlim=get(newaxes,'XLim');
     4738%     ylim=get(newaxes,'YLim');
     4739%     set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
     4740   
     4741    set(htitle,'String',['t=' time_str])
     4742end
     4743map=colormap(handles.PlotAxes);
     4744colormap(map);%transmit the current colormap to the zoom fig
     4745colorbar
     4746
     4747%% create the GUI set_movie
     4748%set(0,'Units','points')
     4749%ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
     4750Position=get(figure_movie,'Position');
     4751Position(2)=Position(2)+1.2*Position(4);
     4752Position(3)=1.5*Position(3);
     4753Position(4)=Position(4)/2;
     4754hfig=findobj(allchild(0),'Tag','set_movie');
     4755if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI
     4756hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',...
     4757    'Position',Position);
     4758BackgroundColor=get(hfig,'Color');
     4759hh=0.14; % box height (relative)
     4760% first raw of the GUI
     4761uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.95-hh/2 0.9 hh/2],'BackgroundColor',BackgroundColor,...
     4762    'String','movie name:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     4763uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.95-1.5*hh 0.9 hh],'tag','MovieName','BackgroundColor',[1 1 1],...
     4764    'String',fullfile(RootPath,[SubDir '.movie'], [RootFile '.avi']),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''MovieName'': name (with path) of the movie to create');%edit box
     4765uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.95-2.5*hh 0.45 hh/2],'BackgroundColor',BackgroundColor,...
     4766    'String','frames per second:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     4767uicontrol('Style','text','Units','normalized', 'Position', [0.55 0.95-2.5*hh 0.45 hh/2],'BackgroundColor',BackgroundColor,...
     4768    'String','total nbre of frames:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     4769uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.95-3.5*hh 0.3 hh],'tag','num_FramePerSecond','BackgroundColor',[1 1 1],...
     4770    'String','10','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_FramePerSecond'': nbre of frames per second');%edit box
     4771uicontrol('Style','edit','Units','normalized', 'Position', [0.65 0.95-3.5*hh 0.3 hh],'tag','num_FrameNumber','BackgroundColor',[1 1 1],...
     4772    'String','10','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_FrameNumber'': total nbre of frames');%edit box
     4773uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.05 0.15 0.25 hh],'BackgroundColor',[1 0 0],'String','START','Callback',@(hObject,eventdata)set_movie_START_Callback(hObject,eventdata),...
     4774    'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''APPLY'': apply the output to the current field series in uvmat');
     4775uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.15 0.25 hh],'Callback',@(hObject,eventdata)set_movie_Cancel_Callback(hObject,eventdata),...
     4776    'String','Cancel','FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''Cancel'': quit GUI without action');
     4777uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.05 0.9 hh/2],'BackgroundColor',BackgroundColor,...
     4778    'String','will extract the result of ++> on uvmat: adjust figure_movie with its Matlab edit menu, then press ''START ''','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     4779drawnow
     4780
     4781%------------------------------------------------------------------------
     4782% function called by pressing APPLY in the GUI  set_slices
     4783function set_movie_START_Callback(hObject,eventdata)
     4784%------------------------------------------------------------------------   
     4785%% read info from the GUI set_movie
     4786hset_movie=get(hObject,'parent');
     4787hMovieName=findobj(hset_movie,'Tag','MovieName');
     4788MovieName=get(hMovieName,'String');
     4789hFramePerSecond=findobj(hset_movie,'Tag','num_FramePerSecond');
     4790fps=str2double(get(hFramePerSecond,'String'));
     4791hFrameNumber=findobj(hset_movie,'Tag','num_FrameNumber');
     4792FrameNumber=str2double(get(hFrameNumber,'String'));% total nbre of frames
     4793
     4794%% create the movie file
     4795MovieDir=fileparts(MovieName);
     4796if ~exist(MovieDir,'dir')
     4797    [success,message]=mkdir(MovieDir);
     4798    if ~isequal(success,1)
     4799        msgbox_uvmat('ERROR',message)
     4800        return
     4801    end
     4802    [success,message] = fileattrib(MovieDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder
     4803    if success==0
     4804        msgbox_uvmat('WARNING',{['unable to set group write access to ' MovieDir ':']; message});%error message for directory creation
     4805    end
     4806end
     4807if exist(MovieName,'file')
     4808    backup=MovieName;
    47334809    testexist=2;
    47344810    while testexist==2
     
    47364812        testexist=exist(backup,'file');     
    47374813    end
    4738     [success,message]=copyfile(aviname,backup);%make backup of the existing file
     4814    [success,message]=copyfile(MovieName,backup);%make backup of the existing file
    47394815    if isequal(success,1)
    4740         delete(aviname)%delete existing file
     4816        delete(MovieName)%delete existing file
    47414817    else
    47424818        msgbox_uvmat('ERROR',message)
     
    47454821end
    47464822%create avi open
    4747 aviobj=avifile(aviname,'Compression','None','fps',fps);
    4748 
    4749 %display first view for tests
    4750 newfig=figure;
    4751 newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure
    4752 set(newaxes,'Tag','movieaxes')
    4753 nbpix=[512 384]*str2double(answer{3});
    4754 set(gcf,'Position',[1 1 nbpix])% resolution XVGA
    4755 set(newaxes,'Position',eval(answer{4}));
    4756 map=colormap(handles.PlotAxes);
    4757 colormap(map);%transmit the current colormap to the zoom fig
    4758 msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
    4759         ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
    4760 % UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
    4761 % set(huvmat,'UserData',UvData);
    4762 increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d
    4763 set(handles.STOP,'Visible','on')
    4764 set(handles.speed,'Visible','on')
    4765 set(handles.speed_txt,'Visible','on')
    4766 set(handles.Movie,'BusyAction','queue')
    4767 
    4768 %imin=str2double(get(handles.i1,'String'));
    4769 imax=str2double(answer{5});
    4770 % if isfield(UvData,'Time')
    4771 htitle=get(newaxes,'Title');
    4772 xlim=get(newaxes,'XLim');
    4773 ylim=get(newaxes,'YLim');
    4774 set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
    4775 time_str=get(handles.TimeValue,'String');
    4776 set(htitle,'String',['t=' time_str])
    4777 set(handles.speed,'Value',1)
    4778 AxesPos=get(newaxes,'Position');
    4779 handles.PlotAxes=newaxes;% the axis in the new figure becomes the current main plotting axes
    4780 for i=1:imax
    4781     if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
    4782             runpm(hObject,eventdata,handles,increment)% run plus
    4783             set(newaxes,'Position',AxesPos)
     4823aviobj=avifile(MovieName,'Compression','None','fps',fps);
     4824
     4825%% get info from uvmat and adjust it
     4826huvmat=findobj(allchild(0),'Tag','uvmat');
     4827hhuvmat=guidata(huvmat);
     4828increment=str2num(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat
     4829set(hhuvmat.STOP,'Visible','on')
     4830set(hhuvmat.speed,'Visible','on')
     4831set(hhuvmat.speed_txt,'Visible','on')
     4832set(hhuvmat.Movie,'BusyAction','queue')
     4833set(hhuvmat.speed,'Value',1)
     4834figure_movie=findobj(allchild(0),'name','figure_movie');
     4835hhuvmat.PlotAxes=findobj(figure_movie,'Tag','movieaxes');% the axis in the new figure becomes the current main plotting axes
     4836for i=1:FrameNumber
     4837    if get(hhuvmat.speed,'Value')~=0 && isequal(get(hhuvmat.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
     4838            runpm(hObject,eventdata,hhuvmat,increment)% run plus
    47844839            drawnow
    4785             time_str=get(handles.TimeValue,'String');
    4786             if ishandle(htitle)
    4787              set(htitle,'String',['t=' time_str])
    4788             end
    4789             mov=getframe(newfig);
     4840            time_str=get(hhuvmat.TimeValue,'String');
     4841            htitle=get(hhuvmat.PlotAxes,'Title');
     4842            Title=get(htitle,'String');
     4843            set(htitle,'String',regexprep(Title,'t=\d+.\d*',['t=' time_str]))
     4844            mov=getframe(figure_movie);
    47904845            aviobj=addframe(aviobj,mov);
    47914846    end
    47924847end
    47934848aviobj=close(aviobj);
    4794 % UvData=rmfield(UvData,'plotaxes');
    4795 % set(huvmat,'UserData',UvData);
    4796 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
    4797 
     4849msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']})
     4850
     4851
     4852%------------------------------------------------------------------------
     4853% function called by pressing APPLY in the GUI  set_slices
     4854function set_movie_Cancel_Callback(hObject,eventdata)
     4855%------------------------------------------------------------------------   
     4856delete(hObject)
     4857%
     4858%
     4859%
     4860%  %read the current input file name
     4861% prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'};
     4862% dlg_title = 'select properties of the output avi movie';
     4863% num_lines= 1;
     4864% def     = {[FileBase '_out.avi'];'10';'1';'[0.05 0.07 0.9 0.9]';'10'};
    47984865
    47994866%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    50775144
    50785145%% create the GUI set_slice
    5079 set(0,'Unit','points')
     5146set(0,'Units','points')
    50805147ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
    50815148Width=350;% fig width in points (1/72 inch)
     
    50855152hfig=findobj(allchild(0),'Tag','set_slice');
    50865153if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI
    5087 hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib);
     5154hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Units','pixels','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib);
    50885155BackgroundColor=get(hfig,'Color');
    50895156hh=0.14; % box height (relative)
     
    54825549        mask_dir=fileparts(answer);
    54835550        if ~exist(mask_dir,'dir')
    5484             [xx,msg1]=mkdir(mask_dir);
    5485             if ~strcmp(msg1,'')
    5486                 errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation
     5551            [success,msg]=mkdir(mask_dir);
     5552            if success==0
     5553                msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation
    54875554                return
     5555            end
     5556            [success,msg] = fileattrib(mask_dir,'+w','g','s');% allow writing access for the group of users, recursively in the folder
     5557            if success==0
     5558                msgbox_uvmat('WARNING',{['unable to set group write access to ' mask_dir ':']; msg});%error message for directory creation
    54885559            end
    54895560        end
Note: See TracChangeset for help on using the changeset viewer.