source: trunk/src/update_waitbar.m @ 758

Last change on this file since 758 was 623, checked in by sommeria, 12 years ago

waitbar system for series improved to aloow use as stand alone fcts.

to add at the head of series fcts:
hseries=findobj(allchild(0),'Tag','series');
RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
WaitbarHandle?=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series

call to waitbar:

update_waitbar(WaitbarHandle?,index/nbfield)
if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction?'),'queue')

disp('program stopped by user')
break

end

File size: 871 bytes
Line 
1%'update_waitbar': update the waitbar display, used for ACTION functions in the GUI 'series'
2%------------------------------------------------------------------
3%INPUT:
4% hwaitbar:  handles of the waitbar to update
5% advance_ratio: number between 0 and 1 representing the advancement of the calculation (loop index relative to the total length)
6
7function update_waitbar(hwaitbar,advance_ratio)
8if ishandle(hwaitbar)
9set(hwaitbar,'Units','pixels')
10pos=get(hwaitbar,'Position');%read waitbar position in pixels
11set(hwaitbar,'Units','normalized')%set back to normalize(the waitbar scales with the GUI)
12CData=ones(floor(pos(4)),floor(pos(3)),3);
13CData(:,:,3)=0 ;% initial color yellow (rgb=[1 1 0])
14CData(:,1:floor(advance_ratio*size(CData,2)),2)=0; % advancement part in red (suppress the second color component green)
15set(hwaitbar,'CData',CData)
16drawnow
17end
Note: See TracBrowser for help on using the repository browser.