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 |
|
---|
7 | %=======================================================================
|
---|
8 | % Copyright 2008-2015, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
|
---|
9 | % http://www.legi.grenoble-inp.fr
|
---|
10 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
|
---|
11 | %
|
---|
12 | % This file is part of the toolbox UVMAT.
|
---|
13 | %
|
---|
14 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
15 | % it under the terms of the GNU General Public License as published
|
---|
16 | % by the Free Software Foundation; either version 2 of the license,
|
---|
17 | % or (at your option) any later version.
|
---|
18 | %
|
---|
19 | % UVMAT is distributed in the hope that it will be useful,
|
---|
20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
22 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
23 | %=======================================================================
|
---|
24 |
|
---|
25 | function update_waitbar(hwaitbar,advance_ratio)
|
---|
26 | if ishandle(hwaitbar)
|
---|
27 | set(hwaitbar,'Units','pixels')
|
---|
28 | pos=get(hwaitbar,'Position');%read waitbar position in pixels
|
---|
29 | set(hwaitbar,'Units','normalized')%set back to normalize(the waitbar scales with the GUI)
|
---|
30 | CData=ones(floor(pos(4)),floor(pos(3)),3);
|
---|
31 | CData(:,:,3)=0 ;% initial color yellow (rgb=[1 1 0])
|
---|
32 | CData(:,1:floor(advance_ratio*size(CData,2)),2)=0; % advancement part in red (suppress the second color component green)
|
---|
33 | set(hwaitbar,'CData',CData)
|
---|
34 | drawnow
|
---|
35 | end
|
---|