Changeset 781 for trunk/src/uvmat.m
- Timestamp:
- May 29, 2014, 6:17:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r778 r781 190 190 LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen 191 191 set(hObject,'Position',[LeftX LowY Width Height]) 192 UvData. OpenParam.PosColorbar=[0.80 0.02 0.018 0.445];192 UvData.PosColorbar=[0.80 0.02 0.018 0.445]; 193 193 AxeData.LimEditBox=1; %initialise AxeData 194 194 set(handles.PlotAxes,'UserData',AxeData) … … 373 373 set(handles.TableDisplay,'Position',pos_1) 374 374 % reset position of CheckTable 375 set(handles.CheckTable,'Unit ','pixels')375 set(handles.CheckTable,'Units','pixels') 376 376 pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold 377 377 pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3); % set 'CheckHold' to the right of the fig … … 2077 2077 % in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i) 2078 2078 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); 2079 2079 ResizeFcn(handles.uvmat,[],handles) 2080 2080 if isempty(errormsg) 2081 2081 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull … … 2648 2648 PlotParam{1}.Vectors.ColorCode= {'rgb'}; 2649 2649 end 2650 PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface2650 %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface 2651 2651 2652 2652 %% second projection object (view_field display) … … 2657 2657 haxes(2)=plot_handles{2}.PlotAxes; 2658 2658 PlotParam{2}=read_GUI(view_field_handle); 2659 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field2659 %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2660 2660 end 2661 2661 end … … 2720 2720 view_field(ObjectData) 2721 2721 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}); 2724 2723 if imap==1 2725 2724 errormsg=fill_GUI(PlotParamOut,handles.uvmat); … … 2795 2794 CheckEditObject_Callback(handles.uvmat, [], handles) 2796 2795 end 2797 ResizeFcn(handles.uvmat,[],handles)2796 %ResizeFcn(handles.uvmat,[],handles) 2798 2797 set(handles.uvmat,'Pointer',pointer) 2799 2798 … … 4232 4231 %------------------------------------------------------------------------ 4233 4232 %get the image of the color display button 'VecColBar' in pixels 4234 set(handles.VecColBar,'Unit ','pixel');4233 set(handles.VecColBar,'Units','pixel'); 4235 4234 pos_vert=get(handles.VecColBar,'Position'); 4236 set(handles.VecColBar,'Unit ','Normalized');4235 set(handles.VecColBar,'Units','Normalized'); 4237 4236 width=ceil(pos_vert(3)); 4238 4237 height=ceil(pos_vert(4)); … … 4657 4656 % -------------------------------------------------------------------- 4658 4657 function MenuExportAxis_Callback(hObject, eventdata, handles) 4658 % -------------------------------------------------------------------- 4659 4659 ListFig=findobj(allchild(0),'Type','figure'); 4660 4660 nb_option=0; … … 4715 4715 % -------------------------------------------------------------------- 4716 4716 set(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 4720 4718 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 4721 4719 FileBase=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 4722 figure_movie=findobj(allchild(0),'name','figure_movie'); 4723 4724 if ~isempty(figure_movie) 4725 delete(figure_movie)%delete existing figure_movie 4726 end 4727 figure_movie=figure; 4728 nbpix=[512 384];% resolution XVGA 4729 set(figure_movie,'name','figure_movie','Position',[1 1 nbpix]) 4730 newaxes=copyobj(handles.PlotAxes,figure_movie);%new plotting axes in the new figure 4731 set(newaxes,'Tag','movieaxes') 4732 4733 %% display time if defined in uvmat 4734 time_str=get(handles.TimeValue,'String'); 4735 if ~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]) 4742 end 4743 map=colormap(handles.PlotAxes); 4744 colormap(map);%transmit the current colormap to the zoom fig 4745 colorbar 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 4750 Position=get(figure_movie,'Position'); 4751 Position(2)=Position(2)+1.2*Position(4); 4752 Position(3)=1.5*Position(3); 4753 Position(4)=Position(4)/2; 4754 hfig=findobj(allchild(0),'Tag','set_movie'); 4755 if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI 4756 hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',... 4757 'Position',Position); 4758 BackgroundColor=get(hfig,'Color'); 4759 hh=0.14; % box height (relative) 4760 % first raw of the GUI 4761 uicontrol('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 4763 uicontrol('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 4765 uicontrol('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 4767 uicontrol('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 4769 uicontrol('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 4771 uicontrol('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 4773 uicontrol('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'); 4775 uicontrol('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'); 4777 uicontrol('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 4779 drawnow 4780 4781 %------------------------------------------------------------------------ 4782 % function called by pressing APPLY in the GUI set_slices 4783 function set_movie_START_Callback(hObject,eventdata) 4784 %------------------------------------------------------------------------ 4785 %% read info from the GUI set_movie 4786 hset_movie=get(hObject,'parent'); 4787 hMovieName=findobj(hset_movie,'Tag','MovieName'); 4788 MovieName=get(hMovieName,'String'); 4789 hFramePerSecond=findobj(hset_movie,'Tag','num_FramePerSecond'); 4790 fps=str2double(get(hFramePerSecond,'String')); 4791 hFrameNumber=findobj(hset_movie,'Tag','num_FrameNumber'); 4792 FrameNumber=str2double(get(hFrameNumber,'String'));% total nbre of frames 4793 4794 %% create the movie file 4795 MovieDir=fileparts(MovieName); 4796 if ~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 4806 end 4807 if exist(MovieName,'file') 4808 backup=MovieName; 4733 4809 testexist=2; 4734 4810 while testexist==2 … … 4736 4812 testexist=exist(backup,'file'); 4737 4813 end 4738 [success,message]=copyfile( aviname,backup);%make backup of the existing file4814 [success,message]=copyfile(MovieName,backup);%make backup of the existing file 4739 4815 if isequal(success,1) 4740 delete( aviname)%delete existing file4816 delete(MovieName)%delete existing file 4741 4817 else 4742 4818 msgbox_uvmat('ERROR',message) … … 4745 4821 end 4746 4822 %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) 4823 aviobj=avifile(MovieName,'Compression','None','fps',fps); 4824 4825 %% get info from uvmat and adjust it 4826 huvmat=findobj(allchild(0),'Tag','uvmat'); 4827 hhuvmat=guidata(huvmat); 4828 increment=str2num(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat 4829 set(hhuvmat.STOP,'Visible','on') 4830 set(hhuvmat.speed,'Visible','on') 4831 set(hhuvmat.speed_txt,'Visible','on') 4832 set(hhuvmat.Movie,'BusyAction','queue') 4833 set(hhuvmat.speed,'Value',1) 4834 figure_movie=findobj(allchild(0),'name','figure_movie'); 4835 hhuvmat.PlotAxes=findobj(figure_movie,'Tag','movieaxes');% the axis in the new figure becomes the current main plotting axes 4836 for 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 4784 4839 drawnow 4785 time_str=get(h andles.TimeValue,'String');4786 if ishandle(htitle)4787 set(htitle,'String',['t=' time_str])4788 end4789 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); 4790 4845 aviobj=addframe(aviobj,mov); 4791 4846 end 4792 4847 end 4793 4848 aviobj=close(aviobj); 4794 % UvData=rmfield(UvData,'plotaxes'); 4795 % set(huvmat,'UserData',UvData); 4796 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) 4797 4849 msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']}) 4850 4851 4852 %------------------------------------------------------------------------ 4853 % function called by pressing APPLY in the GUI set_slices 4854 function set_movie_Cancel_Callback(hObject,eventdata) 4855 %------------------------------------------------------------------------ 4856 delete(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'}; 4798 4865 4799 4866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 5077 5144 5078 5145 %% create the GUI set_slice 5079 set(0,'Unit ','points')5146 set(0,'Units','points') 5080 5147 ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 5081 5148 Width=350;% fig width in points (1/72 inch) … … 5085 5152 hfig=findobj(allchild(0),'Tag','set_slice'); 5086 5153 if ~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);5154 hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Units','pixels','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib); 5088 5155 BackgroundColor=get(hfig,'Color'); 5089 5156 hh=0.14; % box height (relative) … … 5482 5549 mask_dir=fileparts(answer); 5483 5550 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 creation5551 [success,msg]=mkdir(mask_dir); 5552 if success==0 5553 msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation 5487 5554 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 5488 5559 end 5489 5560 end
Note: See TracChangeset
for help on using the changeset viewer.