Mercurial > hg > octave-nkf
annotate examples/code/unwinddemo.cc @ 20454:0bb456e9423b stable
Allow interactive annotations in other figures than the currentfigure.
* Canvas.cc (Canvas::canvasMouseReleaseEvent): prepend the figure handle argument when calling annotation function.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 02 Jun 2015 19:24:44 +0200 |
parents | 95c533ed464b |
children | 2f8500ca91d3 |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/unwind-prot.h> | |
3 | |
4 void | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
5 my_err_handler (const char *fmt, ...) |
6572 | 6 { |
7 // Do nothing!! | |
8 } | |
9 | |
19607
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
10 void |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
11 my_err_with_id_handler (const char *id, const char *fmt, ...) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
12 { |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
13 // Do nothing!! |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
14 } |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
15 |
6572 | 16 DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo") |
17 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
18 octave_value retval; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
19 int nargin = args.length (); |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
20 |
6572 | 21 if (nargin < 2) |
22 print_usage (); | |
23 else | |
24 { | |
25 NDArray a = args(0).array_value (); | |
26 NDArray b = args(1).array_value (); | |
27 | |
28 if (! error_state) | |
29 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
30 // Declare unwind_protect frame which lasts as long as |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
31 // the variable frame has scope. |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
32 unwind_protect frame; |
19607
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
33 frame.add_fcn (set_liboctave_warning_handler, |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
34 current_liboctave_warning_handler); |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
35 |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
36 frame.add_fcn (set_liboctave_warning_with_id_handler, |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
37 current_liboctave_warning_with_id_handler); |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
38 |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
39 set_liboctave_warning_handler (my_err_handler); |
19607
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
40 set_liboctave_warning_with_id_handler (my_err_with_id_handler); |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
41 |
6572 | 42 retval = octave_value (quotient (a, b)); |
43 } | |
44 } | |
19607
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
45 |
6572 | 46 return retval; |
47 } |