Mercurial > octave
annotate scripts/plot/appearance/gtext.m @ 31706:597f3ee61a48 stable
update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 06 Jan 2023 13:11:27 -0500 |
parents | 796f54d4ddbf |
children | 2e484f9f1f18 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3 ## Copyright (C) 2008-2023 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27794
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 ## |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 ## |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 ## |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
25 |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 ## @deftypefn {} {} gtext (@var{s}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
28 ## @deftypefnx {} {} gtext (@{@var{s1}, @var{s2}, @dots{}@}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
29 ## @deftypefnx {} {} gtext (@{@var{s1}; @var{s2}; @dots{}@}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
30 ## @deftypefnx {} {} gtext (@dots{}, @var{prop}, @var{val}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
31 ## @deftypefnx {} {@var{h} =} gtext (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
15072
diff
changeset
|
32 ## Place text on the current figure using the mouse. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
15072
diff
changeset
|
33 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
34 ## The string argument @var{s} may be a character array or a cell array |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
35 ## of strings. If @var{s} has more than one row, each row is used |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27113
diff
changeset
|
36 ## to create a separate text object after a mouse click. For example: |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
37 ## |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
38 ## Place a single string after one mouse click |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27113
diff
changeset
|
39 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
40 ## @example |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
41 ## gtext ("I clicked here") |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
42 ## @end example |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
15072
diff
changeset
|
43 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
44 ## Place two strings after two mouse clicks |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27113
diff
changeset
|
45 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
46 ## @example |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
47 ## gtext (@{"I clicked here"; "and there"@}) |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
48 ## @end example |
15070
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
49 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
50 ## Place two strings, each with two lines, after two mouse clicks |
27794
45ad2127582b
doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents:
27113
diff
changeset
|
51 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
52 ## @example |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
53 ## gtext (@{"I clicked", "here"; "and", "there"@}) |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
54 ## @end example |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
55 ## |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
56 ## Optional @var{property}/@var{value} pairs are passed directly to the |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
57 ## underlying text objects. |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
58 ## |
28733
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27923
diff
changeset
|
59 ## The full list of text object properties is documented at |
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27923
diff
changeset
|
60 ## @ref{Text Properties}. |
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27923
diff
changeset
|
61 ## |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
62 ## The optional return value @var{h} holds the graphics handle(s) to the |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
63 ## created text object(s). |
9307
c2923c27c877
Various documentation improvements
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
64 ## @seealso{ginput, text} |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
65 ## @end deftypefn |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
66 |
15070
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
67 function h = gtext (s, varargin) |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
68 |
13259
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
69 if (nargin < 1) |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
70 print_usage (); |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
71 endif |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
72 |
13259
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
73 if (! (ischar (s) || iscellstr (s))) |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
74 error ("gtext: S must a character array or cell array of strings"); |
13259
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
75 endif |
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
76 |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
77 htmp = []; |
13259
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
78 if (! isempty (s)) |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
79 for i = 1:rows (s) |
15070
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
80 [x, y] = ginput (1); |
27113
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
81 htmp = [htmp, text(x, y, s(i,:), varargin{:})]; |
d6372c07bac2
Overhaul gtext for compatibility (bug #56386)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
82 endfor |
15070
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
83 endif |
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
84 |
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
85 if (nargout > 0) |
1feefc5e5630
gtext.m: Allow multiple text placements--one per mouse click.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
86 h = htmp; |
13259
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
87 endif |
b6efe55f97c7
Allow gtext() to have multi-line text strings (Bug #33232)
Rik <octave@nomad.inbox5.com>
parents:
13123
diff
changeset
|
88 |
7674
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
89 endfunction |
52d8d50e74c1
Add gtext, waitforbuttonpress. Attempt to get ginput working under windows
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
90 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
91 |
13123
6efa1a691713
Add further tests for scripts/plot.
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
92 ## Remove from test statistics. No real tests possible. |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
93 %!assert (1) |