GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • » Octave core
  • » by package
  • » alphabetical

This view

  • Original page
  • New address

GeezerVison is showing octave.sourceforge.io — Function Reference: waitbar

Octave-Forge - Extra packages for GNU Octave
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code

Navigation

Operators and Keywords

Function List:

  • » Octave core
  • » by package
  • » alphabetical

C++ API

: h = waitbar (frac)
: h = waitbar (frac, msg)
: h = waitbar (…, "createcancelbtn", fcn, …)
: h = waitbar (…, prop, val, …)
: waitbar (frac)
: waitbar (frac, h)
: waitbar (frac, h, msg)

Return a handle h to a new progress indicator ("waitbar") object.

The waitbar is filled to fraction frac which must be in the range [0, 1].

The optional message msg is centered and displayed above the waitbar.

A cancel button can be added to the bottom of the waitbar using the "createcancelbtn" property of waitbar figures. The action to be executed when the user presses the button is specified using a string or function handle fcn.

The appearance of the waitbar figure window can be configured by passing prop/val pairs to the function.

When called with a single input the current waitbar, if it exists, is updated to the new value frac. If there are multiple outstanding waitbars they can be updated individually by passing the handle h of the specific waitbar to modify.

See also: delete.

Demonstration 1

The following code

 h = waitbar (0, '0.00%');
 for i = 0:0.01:1
   waitbar (i, h, sprintf ('%.2f%%', 100*i));
 endfor
 close (h);

gives an example of how 'waitbar' is used.

Demonstration 2

The following code

 h = waitbar (0, 'please wait...');
 for i = 0:0.01:0.6
   waitbar (i);
 endfor
 i = 0.3;
 waitbar (i, h, 'don''t you hate taking a step backward?');
 pause (0.5);
 for i = i:0.005:0.7
   waitbar (i, h);
 endfor
 waitbar (i, h, 'or stalling?');
 pause (1);
 for i = i:0.003:0.8
   waitbar (i, h, 'just a little longer now');
 endfor
 for i = i:0.001:1
   waitbar (i, h, 'please don''t be impatient');
 endfor
 close (h);

gives an example of how 'waitbar' is used.

Demonstration 3

The following code

 h1 = waitbar (0, 'Waitbar #1');
 h2 = waitbar (0, 'Waitbar #2');
 h2pos = get (h2, 'position');
 h2pos(1) = h2pos(1) + (h2pos(3) + 50);
 set (h2, 'position', h2pos);
 pause (0.5);
 for i = 1:4
   waitbar (i/4, h1);
   pause (0.5);
   waitbar (i/4, h2);
   pause (0.5);
 endfor
 pause (0.5);
 close (h1);
 close (h2);

gives an example of how 'waitbar' is used.

Demonstration 4

The following code

 clf ();
 niter = 9;
 l = 1;
 xx = [0 l];
 yy = [0 0];
 hli = plot (xx, yy);

 disp ("Push the cancel to stop the process.");
 hf = waitbar(0,"0","Name","Building Koch curve ...",...
              "createcancelbtn", "setappdata (gcbf,'interrupt', true)");
 for ii = 1:niter
   ## Check cancel request
   if (! ishandle (hf))
     break;
   elseif (getappdata (hf, "interrupt"))
     delete (hf);
     break;
   else
     waitbar (ii/niter, hf, sprintf ("Step %d/%d", ii, niter));
   endif

   ## Increasingly lengthy computation
   l /= 3;
   theta = angle (complex (diff (xx), diff (yy)));

   xy = @(th, x0, y0) [cos(th) -sin(th) x0
                       sin(th) cos(th) y0] * [0 l l*3/2      2*l;
                                              0 0 l*(3)^.5/2 0;
                                              1 1 1          1];
   tmp = arrayfun (xy, theta, xx(1:end-1), yy(1:end-1),
                  "uniformoutput", false);

   tmp = cell2mat (tmp);
   xx = [tmp(1,:) xx(end)];
   yy = [tmp(2,:) yy(end)];
   set (hli, "xdata", xx, "ydata", yy);
   drawnow ();
   pause (0.5);
 endfor

 if (ishandle (hf))
   delete (hf);
 endif

Produces the following output

Push the cancel to stop the process.

and the following figure

Figure 1

Package: octave

SourceForge.net Logo
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.