Mercurial > octave
annotate scripts/plot/appearance/annotation.m @ 30326:cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
* bsxfun.cc, graphics.cc, annotation.m, __interp_cube__.m,
__marching_cube__.m, subplot.m, spline.m, betainc.m, gallery.m: Use +
and - instead of .+ and .- in Octave sources and tests.
* pt-eval.cc (get_operator_function_name): Note that .+ and .- are
deprecated.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 23 Nov 2021 12:36:01 -0500 |
parents | 205033e01792 |
children | 363fb10055df |
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 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
3 ## Copyright (C) 2016-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27816
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/>. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
7 ## |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
8 ## This file is part of Octave. |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24388
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
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:
24388
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:
22623
diff
changeset
|
13 ## (at your option) any later version. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
14 ## |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
18 ## GNU General Public License for more details. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
19 ## |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22623
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:
24388
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 ######################################################################## |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
25 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
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:
20735
diff
changeset
|
27 ## @deftypefn {} {} annotation (@var{type}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
28 ## @deftypefnx {} {} annotation ("line", @var{x}, @var{y}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
29 ## @deftypefnx {} {} annotation ("arrow", @var{x}, @var{y}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
30 ## @deftypefnx {} {} annotation ("doublearrow", @var{x}, @var{y}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
31 ## @deftypefnx {} {} annotation ("textarrow", @var{x}, @var{y}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
32 ## @deftypefnx {} {} annotation ("textbox", @var{pos}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
33 ## @deftypefnx {} {} annotation ("rectangle", @var{pos}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
34 ## @deftypefnx {} {} annotation ("ellipse", @var{pos}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
35 ## @deftypefnx {} {} annotation (@dots{}, @var{prop}, @var{val}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
36 ## @deftypefnx {} {} annotation (@var{hf}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
37 ## @deftypefnx {} {@var{h} =} annotation (@dots{}) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
38 ## Draw annotations to emphasize parts of a figure. |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
39 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
40 ## You may build a default annotation by specifying only the @var{type} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
41 ## of the annotation. |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
42 ## |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
43 ## Otherwise you can select the type of annotation and then set its position |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
44 ## using either @var{x} and @var{y} coordinates for line-based annotations or a |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
45 ## position vector @var{pos} for others. In either case, coordinates are |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
46 ## interpreted using the @qcode{"units"} property of the annotation object. |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
47 ## The default is @qcode{"normalized"}, which means the lower left hand corner |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
48 ## of the figure has coordinates @samp{[0 0]} and the upper right hand corner |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
49 ## @samp{[1 1]}. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
50 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
51 ## If the first argument @var{hf} is a figure handle, then plot into this |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
52 ## figure, rather than the current figure returned by @code{gcf}. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
53 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
54 ## Further arguments can be provided in the form of @var{prop}/@var{val} pairs |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
55 ## to customize the annotation appearance. |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
56 ## |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
57 ## The optional return value @var{h} is a graphics handle to the created |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
58 ## annotation object. This can be used with the @code{set} function to |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
59 ## customize an existing annotation object. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
60 ## |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
61 ## All annotation objects share two properties: |
19795
ca7599ae464d
doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents:
19741
diff
changeset
|
62 ## |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
63 ## @itemize |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
64 ## @item @qcode{"units"}: the units in which coordinates are interpreted.@* |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
65 ## Its value may be one of @qcode{"centimeters"} | @qcode{"characters"} | |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
66 ## @qcode{"inches"} | @qcode{"@{normalized@}"} | @qcode{"pixels"} | |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
67 ## @qcode{"points"}. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
68 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
69 ## @item @qcode{"position"}: a four-element vector [x0 y0 width height].@* |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
70 ## The vector specifies the coordinates (x0,y0) of the origin of the annotation |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
71 ## object, its width, and its height. The width and height may be negative, |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
72 ## depending on the orientation of the object. |
19795
ca7599ae464d
doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents:
19741
diff
changeset
|
73 ## |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
74 ## @end itemize |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
75 ## |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
76 ## Valid annotation types and their specific properties are described |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
77 ## below: |
19795
ca7599ae464d
doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents:
19741
diff
changeset
|
78 ## |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
79 ## @table @asis |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
80 ## @item @qcode{"line"} |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
81 ## Constructs a line. @var{x} and @var{y} must be two-element vectors |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
82 ## specifying the x and y coordinates of the two ends of the line. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
83 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
84 ## The line can be customized using @qcode{"linewidth"}, @qcode{"linestyle"}, |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
85 ## and @qcode{"color"} properties the same way as for @code{line} objects. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
86 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
87 ## @item @qcode{"arrow"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
88 ## Construct an arrow. The second point in vectors @var{x} and @var{y} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
89 ## specifies the arrowhead coordinates. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
90 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
91 ## Besides line properties, the arrowhead can be customized using |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
92 ## @qcode{"headlength"}, @qcode{"headwidth"}, and @qcode{"headstyle"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
93 ## properties. Supported values for @qcode{"headstyle"} property are: |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
94 ## [@qcode{"diamond"} | @qcode{"ellipse"} | @qcode{"plain"} | |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
95 ## @qcode{"rectangle"} | @qcode{"vback1"} | @qcode{"@{vback2@}"} | |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
96 ## @qcode{"vback3"}] |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
97 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
98 ## @item @qcode{"doublearrow"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
99 ## Construct a double arrow. Vectors @var{x} and @var{y} specify the |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
100 ## arrowhead coordinates. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
101 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
102 ## The line and the arrowhead can be customized as for arrow annotations, but |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
103 ## some property names are duplicated: |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
104 ## @qcode{"head1length"}/@qcode{"head2length"}, |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
105 ## @qcode{"head1width"}/@qcode{"head2width"}, etc. The index 1 marks the |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
106 ## properties of the arrowhead at the first point in @var{x} and @var{y} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
107 ## coordinates. |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
108 ## |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
109 ## @item @qcode{"textarrow"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
110 ## Construct an arrow with a text label at the opposite end from the arrowhead. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
111 ## |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20714
diff
changeset
|
112 ## Use the @qcode{"string"} property to change the text string. |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
113 ## The line and the arrowhead can be customized as for arrow annotations, and |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
114 ## the text can be customized using the same properties as @code{text} graphics |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
115 ## objects. Note, however, that some text property names are prefixed with |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
116 ## "text" to distinguish them from arrow properties: |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
117 ## @qcode{"textbackgroundcolor"}, @qcode{"textcolor"}, |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
118 ## @qcode{"textedgecolor"}, @qcode{"textlinewidth"}, |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
119 ## @qcode{"textmargin"}, @qcode{"textrotation"}. |
19795
ca7599ae464d
doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents:
19741
diff
changeset
|
120 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
121 ## @item @qcode{"textbox"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
122 ## Construct a box with text inside. @var{pos} specifies the |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
123 ## @qcode{"position"} property of the annotation. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
124 ## |
20716
1ecee53513d7
doc: Peridodic grammar check of documentation.
Rik <rik@octave.org>
parents:
20714
diff
changeset
|
125 ## Use the @qcode{"string"} property to change the text string. |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
126 ## You may use @qcode{"backgroundcolor"}, @qcode{"edgecolor"}, |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
127 ## @qcode{"linestyle"}, and @qcode{"linewidth"} properties to customize |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
128 ## the box background color and edge appearance. A limited set of @code{text} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
129 ## objects properties are also available; Besides @qcode{"font@dots{}"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
130 ## properties, you may also use @qcode{"horizontalalignment"} and |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
131 ## @qcode{"verticalalignment"} to position the text inside the box. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
132 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
133 ## Finally, the @qcode{"fitboxtotext"} property controls the actual extent of |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
134 ## the box. If @qcode{"on"} (the default) the box limits are fitted to the |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
135 ## text extent. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
136 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
137 ## @item @qcode{"rectangle"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
138 ## Construct a rectangle. @var{pos} specifies the @qcode{"position"} property |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
139 ## of the annotation. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
140 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
141 ## You may use @qcode{"facecolor"}, @qcode{"color"}, @qcode{"linestyle"}, and |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
142 ## @qcode{"linewidth"} properties to customize the rectangle background color |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
143 ## and edge appearance. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
144 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
145 ## @item @qcode{"ellipse"} |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
146 ## Construct an ellipse. @var{pos} specifies the @qcode{"position"} property |
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
147 ## of the annotation. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
148 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
149 ## See @qcode{"rectangle"} annotations for customization. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
150 ## @end table |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
151 ## |
20194
b0f7ee81d974
doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
152 ## @seealso{xlabel, ylabel, zlabel, title, text, gtext, legend, colorbar} |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
153 ## @end deftypefn |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
154 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
155 function varargout = annotation (varargin) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
156 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
157 nargin = numel (varargin); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
158 if (nargin == 0) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
159 print_usage (); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
160 endif |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
161 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
162 objtype = ""; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
163 hf = []; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
164 lims = []; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
165 x = y = []; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
166 opts = {}; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
167 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
168 ## Parent figure |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
169 if (isfigure (varargin{1})) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
170 hf = varargin{1}; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
171 varargin(1) = []; nargin -= 1; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
172 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
173 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
174 ## Annotation type |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
175 if (! ischar (varargin{1})) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
176 print_usage (); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
177 endif |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
178 objtype = varargin{1}; |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
179 varargin(1) = []; nargin -= 1; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
180 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
181 switch (objtype) |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
182 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
183 case {"line", "arrow", "doublearrow", "textarrow"} |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
184 if (nargin == 0) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
185 lims = []; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
186 elseif (nargin >= 2) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
187 x = varargin{1}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
188 y = varargin{2}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
189 varargin(1:2) = []; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
190 |
19865
e9f89866074c
maint: Cleanup some .m files to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19851
diff
changeset
|
191 if (isnumeric (x) && isnumeric (y) |
e9f89866074c
maint: Cleanup some .m files to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19851
diff
changeset
|
192 && length (x) == 2 && length (y) == 2) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
193 lims = [x(1), y(1), diff(x), diff(y)]; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
194 else |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20525
diff
changeset
|
195 error ("annotation: X and Y must be 2-element vectors"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
196 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
197 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
198 print_usage (); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
199 endif |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
200 |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
201 case {"textbox", "ellipse", "rectangle"} |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
202 if (nargin == 0) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
203 lims = []; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
204 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
205 lims = varargin{1}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
206 varargin(1) = []; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
207 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
208 if (! isvector (lims) || numel (lims) != 4) |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20525
diff
changeset
|
209 error ("annotation: POS must be a 4-element vector"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
210 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
211 endif |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
212 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
213 otherwise |
22760
c4d80b9d2898
maint: Capitalize variable names appearing in error() messages of m-files.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
214 error ("annotation: unknown annotation TYPE %s", objtype); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
215 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
216 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
217 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
218 ## options |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
219 opts = varargin; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
220 if (! isempty (opts)) |
28901
3c37ae43996a
maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
221 if (mod (numel (opts), 2) != 0 || ! all (cellfun (@ischar, opts(1:2:end)))) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
222 warning ("annotation: couldn't parse PROP/VAL pairs, skipping"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
223 opts = {}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
224 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
225 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
226 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
227 ## Create annotation |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
228 showhidden = get (0, "showhiddenhandles"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
229 set (0, "showhiddenhandles", "on"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
230 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
231 unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
232 if (isempty (hf)) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
233 hf = gcf (); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
234 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
235 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
236 ## Axes |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
237 hca = get (hf, "currentaxes"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
238 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
239 hax = findall (hf, "-depth", 1, "tag", "scribeoverlay"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
240 if (isempty (hax)) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
241 hax = buildoverlay (hf); |
19820
4569903d6c5a
axes.m: reworks axes restacking for ML compatibility (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19797
diff
changeset
|
242 else |
4569903d6c5a
axes.m: reworks axes restacking for ML compatibility (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19797
diff
changeset
|
243 ## Make sure the annotations are on top of other axes |
4569903d6c5a
axes.m: reworks axes restacking for ML compatibility (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19797
diff
changeset
|
244 axes (hax); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
245 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
246 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
247 ## Build annotation |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
248 htmp = buildannot (hax, objtype, lims); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
249 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
250 ## Set user defined properties |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
251 if (! isempty (opts)) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
252 set (htmp, opts{:}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
253 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
254 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
255 unwind_protect_cleanup |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
256 set (0, "showhiddenhandles", showhidden); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
257 set (hf, "currentaxes", hca); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
258 end_unwind_protect |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
259 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
260 if (nargout != 0) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
261 varargout{1} = htmp; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
262 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
263 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
264 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
265 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
266 function hax = buildoverlay (hf) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
267 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
268 hax = axes ("parent", hf, "visible", "off", "tag", "scribeoverlay", ... |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
269 "position", [0 0 1 1], "xlim", [0 1], "ylim", [0 1], ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
270 "handlevisibility", "off"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
271 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
272 ## Hidden property to store figure size in absolute (points) coordinates. |
22623
76f1164d2135
Rename [xyz]mtick properties to [xyz]minortickvalues (bug #49205).
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
273 addproperty ("figsize_points", hax, "axesxminortickvalues", []); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
274 update_figsize_points (hf, {}, hax); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
275 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
276 listener = {@update_figsize_points, hax}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
277 addlistener (hf, "position", listener); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
278 |
28563
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
279 delfcn = @(~, ~) dellistener (hf, "position", listener); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
280 set (hax, "deletefcn", delfcn); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
281 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
282 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
283 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
284 function update_figsize_points (hf, ~, hax) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
285 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
286 persistent recursive = false; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
287 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
288 if (! recursive) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
289 recursive = true; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
290 units = get (hf, "units"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
291 set (hf, "units", "points"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
292 pos = get (hf, "position"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
293 set (hf, "units", units); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
294 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
295 set (hax, "figsize_points", pos(3:4)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
296 recursive = false; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
297 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
298 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
299 endfunction |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
300 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
301 function h = buildannot (hax, objtype, pos) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
302 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
303 ## Base hggroup |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
304 h = hggroup ("parent", hax); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
305 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
306 ## Base context menu |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
307 hui = uicontextmenu (get (hax, "parent")); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
308 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
309 ## Add common properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
310 if (strcmp (graphics_toolkit (), "gnuplot")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
311 ## FIXME: this is a workaround for bug #39394 (gnuplot toolkit) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
312 defprops = {"position", "axesposition", [0.3 0.3 0.1 0.1], ... |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
313 "units", "textunits", "data"}; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
314 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
315 defprops = {"position", "axesposition", [0.3 0.3 0.1 0.1], ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
316 "units", "axesunits", "normalized"}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
317 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
318 addbaseprops (h, defprops); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
319 setappdata (h, "__former_units__", "normalized"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
320 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
321 ## Add common menus |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
322 prop = "units"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
323 vals = set (h, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
324 addbasemenu (hui, h, prop, vals, "Units"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
325 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
326 ## Common updaters |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
327 listener = {@update_position, h, true}; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
328 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
329 addlistener (hax, "figsize_points", listener); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
330 |
28563
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
331 delfcn = @(~, ~) dellistener (hax, "figsize_points", listener); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
332 set (h, "deletefcn", delfcn); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
333 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
334 addlistener (h, "units", {@update_position, h}); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
335 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
336 ## Now work with normalized coordinates |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
337 if (! isempty (pos)) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
338 set (h, "position", pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
339 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
340 pos = getnormpos (h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
341 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
342 ## Build annotation object and its specific properties/updaters |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
343 switch (objtype) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
344 case {"line", "arrow", "doublearrow", "textarrow"} |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
345 ## Add properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
346 proptable = lineprops (); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
347 if (strcmp (objtype, "arrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
348 proptable = [proptable arrowprops()]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
349 elseif (strcmp (objtype, "doublearrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
350 proptable = [proptable dblarrowprops()]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
351 elseif (strcmp (objtype, "textarrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
352 proptable = [proptable arrowprops()]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
353 proptable = [proptable textprops()]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
354 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
355 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
356 addbaseprops (h, proptable); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
357 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
358 ## create line |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
359 hli = line ([pos(1); (pos(1) + pos(3))], |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
360 [pos(2); (pos(2) + pos(4))], |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
361 "color", get (h, "color"), |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
362 "linestyle", get (h, "linestyle"), |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
363 "linewidth", get (h, "linewidth"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
364 "parent", h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
365 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
366 linemenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
367 set (hli, "uicontextmenu", hui); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
368 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
369 ## create patch(s) and text |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
370 if (strcmp (objtype, "arrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
371 [x, y] = arrowcoordinates (h); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
372 hpa = patch (x, y, get (h, "color"), "edgecolor", get (h, "color"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
373 "parent", h); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
374 update_arrow (h, {}, "position", hpa); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
375 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
376 arrowmenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
377 set (hpa, "uicontextmenu", hui); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
378 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
379 elseif (strcmp (objtype, "doublearrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
380 [x, y] = arrowcoordinates (h, 1); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
381 hpa = patch (x, y, get (h, "color"), "edgecolor", get (h, "color"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
382 "parent", h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
383 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
384 [x, y] = arrowcoordinates (h, 2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
385 hpa(2) = patch (x, y, get (h, "color"), "edgecolor", get (h, "color"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
386 "parent", h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
387 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
388 update_arrow (h, {}, "position", hpa); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
389 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
390 dblarrowmenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
391 set (hpa, "uicontextmenu", hui); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
392 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
393 elseif (strcmp (objtype, "textarrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
394 [x, y] = arrowcoordinates (h); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
395 hpa = patch (x, y, get (h, "color"), "edgecolor", get (h, "color"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
396 "parent", h); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
397 update_arrow (h, {}, "position", hpa); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
398 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
399 hte = text (get (h, "position")(1), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
400 get (h, "position")(2), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
401 get (h, "string"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
402 "color", get (h, "color"), "parent", h); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
403 propnames = textprops ("names"); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
404 for i = 1 : numel (propnames) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
405 update_text (h, {}, propnames{i}, hte); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
406 endfor |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
407 update_text (h, {}, "position", hte); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
408 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
409 arrowmenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
410 textmenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
411 set (hpa, "uicontextmenu", hui); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
412 set (hte, "uicontextmenu", hui); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
413 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
414 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
415 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
416 ## updaters |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
417 addlistener (h, "color", {@update_line, "color", hli}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
418 addlistener (h, "linestyle", {@update_line, "linestyle", hli}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
419 addlistener (h, "linewidth", {@update_line, "linewidth", hli}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
420 addlistener (h, "x", {@update_line, "x", hli}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
421 addlistener (h, "y", {@update_line, "y", hli}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
422 addlistener (h, "position", {@update_line, "position", hli}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
423 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
424 if (strcmp (objtype, "arrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
425 addlistener (h, "position", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
426 addlistener (h, "headwidth", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
427 addlistener (h, "headstyle", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
428 addlistener (h, "headlength", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
429 addlistener (h, "color", {@update_arrow, "color", hpa}); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
430 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
431 elseif (strcmp (objtype, "doublearrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
432 addlistener (h, "position", {@update_arrow, "position", hpa}); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
433 addlistener (h, "head1width", |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
434 {@update_arrow, "position", [hpa(1), 0]}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
435 addlistener (h, "head2width", |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
436 {@update_arrow, "position", [0, hpa(2)]}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
437 addlistener (h, "head1style", |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
438 {@update_arrow, "position", [hpa(1), 0]}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
439 addlistener (h, "head2style", |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
440 {@update_arrow, "position", [0, hpa(2)]}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
441 addlistener (h, "head1length", |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
442 {@update_arrow, "position", [hpa(1), 0]}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
443 addlistener (h, "head2length", |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
444 {@update_arrow, "position", [0, hpa(2)]}); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
445 addlistener (h, "color", {@update_arrow, "color", hpa}); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
446 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
447 elseif (strcmp (objtype, "textarrow")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
448 addlistener (h, "position", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
449 addlistener (h, "headwidth", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
450 addlistener (h, "headstyle", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
451 addlistener (h, "headlength", {@update_arrow, "position", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
452 addlistener (h, "color", {@update_arrow, "color", hpa}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
453 propnames = textprops ("names"); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
454 for i = 1 : numel (propnames) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
455 addlistener (h, propnames{i}, |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
456 {@update_text, propnames{i}, hte}); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
457 if (any (strcmp (propnames{i}, |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
458 {"fontangle", "fontname", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
459 "fontsize", "fontweight", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
460 "horizontalalignment", "string", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
461 "textmargin", "textrotation", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
462 "verticalalignment"}))) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
463 addlistener (h, propnames{i}, {@update_text, "position", hte}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
464 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
465 endfor |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
466 addlistener (h, "position", {@update_text, "position", hte}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
467 addlistener (h, "color", {@update_text, "color", hte}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
468 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
469 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
470 case {"rectangle", "ellipse"} |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
471 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
472 ## Add properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
473 addbaseprops (h, rectprops ()); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
474 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
475 ## Create rectangle/ellipse |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
476 if (strcmp (objtype, "rectangle")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
477 [x, y] = pos2rect (pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
478 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
479 [x, y] = pos2ell (pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
480 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
481 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
482 hr = patch (x, y, "parent", h); |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
483 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
484 propnames = rectprops ("names"); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
485 for i = 1 : numel (propnames) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
486 update_rect (h, {}, propnames{i}, hr, objtype); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
487 endfor |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
488 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
489 rectmenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
490 set (hr, "uicontextmenu", hui); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
491 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
492 ## Updaters |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
493 addlistener (h, "position", {@update_rect, "position", hr, objtype}); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
494 for i = 1 : numel (propnames) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
495 addlistener (h, propnames{i}, |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
496 {@update_rect, propnames{i}, hr, objtype}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
497 endfor |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
498 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
499 case "textbox" |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
500 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
501 ## Add properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
502 addbaseprops (h, textboxprops()); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
503 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
504 ## Create textbox |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
505 hpa = patch ("parent", h); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
506 hte = text (pos(1), pos(2), get (h, "string"), |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
507 "color", get (h, "color"), "parent", h); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
508 update_textbox (h, {}, "position", [hte hpa]); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
509 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
510 propnames = textboxprops ("names"); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
511 for i = 1 : numel (propnames) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
512 update_textbox (h, {}, propnames{i}, [hte hpa]); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
513 endfor |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
514 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
515 textboxmenu (hui, h); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
516 set (hpa, "uicontextmenu", hui); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
517 set (hte, "uicontextmenu", hui); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
518 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
519 ## Updaters |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
520 addlistener (h, "position", {@update_textbox, "position", [hte hpa]}); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
521 for i = 1 : numel (propnames) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
522 addlistener (h, propnames{i}, |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
523 {@update_textbox, propnames{i}, [hte hpa]}); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
524 endfor |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
525 addlistener (h, "horizontalalignment", |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
526 {@update_textbox, "position", [hte hpa]}); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
527 addlistener (h, "verticalalignment", |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
528 {@update_textbox, "position", [hte hpa]}); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
529 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
530 endswitch |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
531 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
532 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
533 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
534 function props = lineprops (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
535 |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
536 ## FIXME: Use "axesx(y)lim" instead of "linex(y)data" |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
537 props = {"color", "color", [0 0 0], ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
538 "linestyle", "linelinestyle", "-", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
539 "linewidth", "linelinewidth", 0.5, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
540 "x", "linexdata", [0.3 0.4], ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
541 "y", "lineydata", [0.3 0.4]}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
542 if (strcmp (varargin, "names")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
543 props = props(1:3:end); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
544 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
545 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
546 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
547 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
548 function col = basecolors () |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
549 col = {"blue", "black", "cyan", "green", "magenta", "red", ... |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
550 "white", "yellow", "none"}; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
551 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
552 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
553 function linemenu (hui, hpar) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
554 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
555 hm = uimenu ("parent", hui, "label", "Line"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
556 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
557 ## Color |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
558 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
559 addbasemenu (hm, hpar, "Color", vals); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
560 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
561 ## Linestyle |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
562 vals = set (hpar, "linestyle"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
563 addbasemenu (hm, hpar, "Linestyle", vals); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
564 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
565 ## Linewidth |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
566 vals = [0.5 1 1.5 2]; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
567 addbasemenu (hm, hpar, "Linewidth", vals); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
568 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
569 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
570 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
571 function props = arrowprops (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
572 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
573 props = {"headlength", "data", 10, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
574 "headstyle", "radio", "diamond|ellipse|none|plain|rectangle|vback1|{vback2}|vback3", ... |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
575 "headwidth", "data", 10}; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
576 if (strcmp (varargin, "names")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
577 props = props(1:3:end); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
578 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
579 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
580 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
581 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
582 function arrowmenu (hui, hpar) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
583 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
584 hm = uimenu ("parent", hui, "label", "Arrowhead"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
585 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
586 ## Headlength/width |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
587 vals = 6:2:16; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
588 addbasemenu (hm, hpar, "headlength", vals, "Length"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
589 addbasemenu (hm, hpar, "headwidth", vals, "Width"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
590 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
591 ## Headstyle |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
592 vals = set (hpar, "headstyle"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
593 addbasemenu (hm, hpar, "Headstyle", vals); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
594 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
595 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
596 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
597 function props = dblarrowprops (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
598 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
599 props = {"head1length", "data", 10, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
600 "head1style", "radio", "diamond|ellipse|none|plain|rectangle|vback1|{vback2}|vback3", ... |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
601 "head1width", "data", 10, ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
602 "head2length", "data", 10, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
603 "head2style", "radio", "diamond|ellipse|none|plain|rectangle|vback1|{vback2}|vback3", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
604 "head2width", "data", 10}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
605 if (strcmp (varargin, "names")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
606 props = props(1:3:end); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
607 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
608 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
609 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
610 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
611 function dblarrowmenu (hui, hpar) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
612 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
613 hm1 = uimenu ("parent", hui, "label", "Arrowhead #1"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
614 hm2 = uimenu ("parent", hui, "label", "Arrowhead #2"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
615 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
616 ## Headlength/width |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
617 vals = 6:2:16; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
618 addbasemenu (hm1, hpar, "head1length", vals, "Length"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
619 addbasemenu (hm1, hpar, "head1width", vals, "Width"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
620 addbasemenu (hm2, hpar, "head2length", vals, "Length"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
621 addbasemenu (hm2, hpar, "head2width", vals, "Width"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
622 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
623 ## Headstyle |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
624 vals = set (hpar, "head1style"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
625 addbasemenu (hm1, hpar, "head1style", vals, "Headstyle"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
626 addbasemenu (hm2, hpar, "head2style", vals, "Headstyle"); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
627 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
628 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
629 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
630 function props = textprops (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
631 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
632 props = {"fontangle", "textfontangle", "normal", ... |
26748
2a0004e7c574
annotation.m: use "*" rather than "Helvetica" as default font name (bug #53091)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
633 "fontname", "textfontname", "*", ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
634 "fontsize", "textfontsize", 10, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
635 "fontunits", "textfontunits", "points", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
636 "fontweight", "textfontweight", "normal", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
637 "horizontalalignment", "texthorizontalalignment", "left", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
638 "interpreter", "textinterpreter", "tex", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
639 "string", "textstring", "", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
640 "textbackgroundcolor", "textbackgroundcolor", "none", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
641 "textcolor", "textcolor", "k", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
642 "textedgecolor", "textedgecolor", "none", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
643 "textlinewidth", "textlinewidth",0.5, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
644 "textmargin", "textmargin", 5, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
645 "textrotation", "textrotation", 0, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
646 "verticalalignment", "textverticalalignment", "middle"}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
647 if (strcmp (varargin, "names")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
648 props = props(1:3:end); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
649 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
650 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
651 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
652 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
653 function stringdlg (hpar, prop) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
654 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
655 def = get (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
656 if (iscell (def)) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
657 prompt = arrayfun (@(n) sprintf ("Line #%d:", n), 1 : numel (def), |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
658 "uniformoutput", false); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
659 else |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
660 prompt = ""; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
661 def = {def}; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
662 endif |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
663 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
664 cstr = inputdlg (prompt, prop, 1, def); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
665 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
666 if (! isempty (cstr)) |
21385
89fa0694aa2e
Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
667 set (hpar, prop, cstr); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
668 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
669 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
670 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
671 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
672 function textmenu (hui, hpar) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
673 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
674 hm = uimenu ("parent", hui, "label", "Text"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
675 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
676 ## String; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
677 prop = "String"; |
29536
205033e01792
annotation.m: Fix callbacks called with too many inputs
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29359
diff
changeset
|
678 fcn = @(~, ~) stringdlg (hpar, prop); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
679 uimenu (hm, "label", prop, "callback", fcn); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
680 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
681 ## Font properties |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
682 prop = "textcolor"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
683 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
684 addbasemenu (hm, hpar, prop, vals, "Color"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
685 prop = "fontsize"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
686 vals = 8:2:20; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
687 addbasemenu (hm, hpar, prop, vals, "Size"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
688 prop = "fontangle"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
689 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
690 addbasemenu (hm, hpar, prop, vals, "Angle"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
691 prop = "fontweight"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
692 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
693 addbasemenu (hm, hpar, prop, vals, "Weight"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
694 prop = "textrotation"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
695 vals = 0:90:270; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
696 addbasemenu (hm, hpar, prop, vals, "Rotation"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
697 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
698 prop = "horizontalalignment"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
699 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
700 addbasemenu (hm, hpar, prop, vals, "Horizontal Alignment", ... |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
701 "separator", "on"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
702 prop = "verticalalignment"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
703 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
704 addbasemenu (hm, hpar, prop, vals, "Vertical Alignment"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
705 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
706 ## FIXME: Add text background properties (Bug #57407). |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
707 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
708 prop = "interpreter"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
709 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
710 addbasemenu (hm, hpar, prop, vals, "Interpreter", ... |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
711 "separator", "on"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
712 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
713 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
714 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
715 function props = textboxprops (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
716 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
717 props = {"backgroundcolor", "patchfacecolor", "none", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
718 "color", "textcolor", [0 0 0], ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
719 "edgecolor", "patchedgecolor", [0 0 0], ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
720 "facealpha", "patchfacealpha", 1, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
721 "fontangle", "textfontangle", "normal", ... |
26748
2a0004e7c574
annotation.m: use "*" rather than "Helvetica" as default font name (bug #53091)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
722 "fontname", "textfontname", "*", ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
723 "fontsize", "textfontsize", 10, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
724 "fontunits", "textfontunits", "points", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
725 "fontweight", "textfontweight", "normal", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
726 "horizontalalignment", "texthorizontalalignment", "left", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
727 "interpreter", "textinterpreter", "tex", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
728 "linestyle", "linelinestyle", "-", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
729 "linewidth", "linelinewidth", 0.5, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
730 "string", "textstring", "", ... |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
731 "fitboxtotext", "radio", "{on}|off", ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
732 "margin", "data", 5, ... |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
733 "verticalalignment", "textverticalalignment", "middle"}; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
734 if (strcmp (varargin, "names")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
735 props = props(1:3:end); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
736 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
737 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
738 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
739 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
740 function textboxmenu (hui, hpar) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
741 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
742 ## Text properties |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
743 hm1 = uimenu ("parent", hui, "label", "Text"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
744 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
745 prop = "String"; |
29536
205033e01792
annotation.m: Fix callbacks called with too many inputs
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29359
diff
changeset
|
746 fcn = @(~, ~) stringdlg (hpar, prop); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
747 uimenu (hm1, "label", prop, "callback", fcn); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
748 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
749 prop = "Color"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
750 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
751 addbasemenu (hm1, hpar, prop, vals); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
752 prop = "fontsize"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
753 vals = 8:2:20; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
754 addbasemenu (hm1, hpar, prop, vals, "Size"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
755 prop = "fontangle"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
756 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
757 addbasemenu (hm1, hpar, prop, vals, "Angle"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
758 prop = "fontweight"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
759 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
760 addbasemenu (hm1, hpar, prop, vals, "Weight"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
761 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
762 prop = "horizontalalignment"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
763 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
764 addbasemenu (hm1, hpar, prop, vals, "Horizontal Alignment", ... |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
765 "separator", "on"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
766 prop = "verticalalignment"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
767 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
768 addbasemenu (hm1, hpar, prop, vals, "Vertical Alignment"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
769 prop = "Margin"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
770 vals = 2:2:10; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
771 addbasemenu (hm1, hpar, prop, vals); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
772 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
773 prop = "interpreter"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
774 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
775 addbasemenu (hm1, hpar, prop, vals, "Interpreter", ... |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
776 "separator", "on"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
777 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
778 ## Background properties |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
779 hm2 = uimenu ("parent", hui, "label", "Background"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
780 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
781 prop = "fitboxtotext"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
782 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
783 addbasemenu (hm2, hpar, prop, vals, "Fit box to text"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
784 prop = "backgroundcolor"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
785 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
786 addbasemenu (hm2, hpar, prop, vals, "Face Color"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
787 prop = "edgecolor"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
788 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
789 addbasemenu (hm2, hpar, prop, vals, "Edge Color"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
790 prop = "linestyle"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
791 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
792 addbasemenu (hm2, hpar, prop, vals, "Line Style"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
793 prop = "linewidth"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
794 vals = 0.5:.5:2; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
795 addbasemenu (hm2, hpar, prop, vals, "Line Width"); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
796 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
797 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
798 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
799 function props = rectprops (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
800 |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
801 props = {"color", "patchedgecolor", "k", ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
802 "facealpha", "patchfacealpha", 1, ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
803 "facecolor", "patchfacecolor", "none", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
804 "linestyle", "patchlinestyle", "-", ... |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
805 "linewidth", "patchlinewidth", 0.5}; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
806 if (strcmp (varargin, "names")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
807 props = props(1:3:end); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
808 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
809 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
810 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
811 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
812 function rectmenu (hui, hpar) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
813 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
814 prop = "facecolor"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
815 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
816 addbasemenu (hui, hpar, prop, vals, "Face Color"); |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
817 prop = "color"; |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
818 vals = basecolors (); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
819 addbasemenu (hui, hpar, prop, vals, "Edge Color"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
820 prop = "linestyle"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
821 vals = set (hpar, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
822 addbasemenu (hui, hpar, prop, vals, "Line Style"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
823 prop = "linewidth"; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
824 vals = 0.5:.5:2; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
825 addbasemenu (hui, hpar, prop, vals, "Line Width"); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
826 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
827 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
828 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
829 function addbaseprops (h, proptable) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
830 cellfun (@(pname, ptype, parg) addproperty (pname, h, ptype, parg), |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
831 proptable(1:3:end), proptable(2:3:end), proptable(3:3:end)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
832 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
833 |
28563
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
834 ## FIXME: there are some calls to addbasemenu with option-like arguments |
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
835 ## but we don't do anything with varargin here. What is the right thing |
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
836 ## to do? |
5a07c798eb08
avoid function call input or output argument number mismatch
John W. Eaton <jwe@octave.org>
parents:
27939
diff
changeset
|
837 function addbasemenu (hm, hpar, pname, vals, mainlabel = "", varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
838 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
839 if (isempty (mainlabel)) |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
840 mainlabel = pname; |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
841 endif |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
842 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
843 h = uimenu ("parent", hm, "label", mainlabel); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
844 |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
845 is_numeric = ! iscell (vals); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
846 nv = numel (vals); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
847 htmp = zeros (1, nv); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
848 for i = 1:nv |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
849 if (! is_numeric) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
850 val = label = vals{i}; |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
851 else |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
852 val = vals(i); |
26869
992f55ef87f5
Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26752
diff
changeset
|
853 label = disp (val); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
854 endif |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
855 |
29536
205033e01792
annotation.m: Fix callbacks called with too many inputs
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29359
diff
changeset
|
856 fcn = @(~, ~) set (hpar, pname, val); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
857 htmp(i) = uimenu (h, "label", label, "callback", fcn); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
858 endfor |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
859 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
860 handle_check (hpar, {}, htmp, pname, is_numeric); |
21385
89fa0694aa2e
Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
861 addlistener (hpar, pname, {@handle_check, htmp, pname, is_numeric}); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
862 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
863 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
864 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
865 function handle_check (h, ~, hmenus, prop, is_numeric) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
866 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
867 vals = get (hmenus, "label"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
868 current = get (h, prop); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
869 if (is_numeric) |
26869
992f55ef87f5
Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26752
diff
changeset
|
870 current = disp (current); |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
871 endif |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
872 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
873 idx = strcmp (vals, current); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
874 set (hmenus(idx), "checked", "on"); |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
875 set (hmenus(! idx), "checked", "off"); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
876 |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
877 endfunction |
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
878 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
879 function update_position (h1, ~, h, force = false) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
880 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
881 if (! force) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
882 pos = convertposition (h, getappdata (h, "__former_units__"), |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
883 get (h, "units")); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
884 setappdata (h, "__former_units__", get (h, "units")); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
885 set (h, "position", pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
886 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
887 ## FIXME: Inefficient trick to force all objects to be redrawn |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
888 set (h, "position", [0 0 .5 .5], "position", get (h, "position")); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
889 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
890 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
891 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
892 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
893 function update_line (h, ~, prop, hli) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
894 persistent recursive = false; |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
895 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
896 if (! recursive) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
897 switch (prop) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
898 case "color" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
899 set (hli, "color", get (h, "color")); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
900 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
901 case "linestyle" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
902 set (hli, "linestyle", get (h, "linestyle")); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
903 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
904 case "linewidth" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
905 set (hli, "linewidth", get (h, "linewidth")); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
906 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
907 case "x" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
908 ## Update position |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
909 x = get (h, "x"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
910 pos = get (h, "position"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
911 pos(1) = x(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
912 pos(3) = diff (x); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
913 recursive = true; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
914 set (h, "position", pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
915 recursive = false; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
916 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
917 ## Draw in normalized coordinates |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
918 pos = getnormpos (h); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
919 x = [pos(1) (pos(1) + pos(3))]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
920 set (hli, "xdata", x); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
921 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
922 case "y" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
923 ## Update position |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
924 y = get (h, "y"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
925 pos = get (h, "position"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
926 pos(2) = y(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
927 pos(4) = diff (y); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
928 recursive = true; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
929 set (h, "position", pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
930 recursive = false; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
931 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
932 ## Draw in normalized coordinates |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
933 pos = getnormpos (h); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
934 y = [pos(2) (pos(2) + pos(4))]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
935 set (hli, "ydata", y); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
936 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
937 case "position" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
938 ## Update x and y |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
939 pos = get (h, "position"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
940 x = [pos(1) (pos(1) + pos(3))]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
941 y = [pos(2) (pos(2) + pos(4))]; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
942 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
943 recursive = true; |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
26869
diff
changeset
|
944 set (h, "x", x, "y", y); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
945 recursive = false; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
946 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
947 ## Draw in normalized coordinates |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
948 pos = getnormpos (h); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
949 x = [pos(1) (pos(1) + pos(3))]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
950 y = [pos(2) (pos(2) + pos(4))]; |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
26869
diff
changeset
|
951 set (hli, "xdata", x, "ydata", y); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
952 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
953 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
954 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
955 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
956 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
957 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
958 function [x, y] = arrowcoordinates (h, nar = []) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
959 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
960 pos = getnormpos (h); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
961 ppos = norm2pts (h, pos(3:4).'); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
962 ang = angle (complex (ppos(1), ppos(2))); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
963 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
964 if (isempty (nar)) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
965 ln = get (h, "headlength"); # in points |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
966 wd = get (h, "headwidth"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
967 headstyle = get (h, "headstyle"); |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
29536
diff
changeset
|
968 pos = pos(1:2) + pos(3:4); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
969 elseif (nar == 1) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
970 ln = get (h, "head1length"); # in points |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
971 wd = get (h, "head1width"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
972 headstyle = get (h, "head1style"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
973 pos = pos(1:2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
974 ang += pi; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
975 elseif (nar == 2) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
976 ln = get (h, "head2length"); # in points |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
977 wd = get (h, "head2width"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
978 headstyle = get (h, "head2style"); |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
29536
diff
changeset
|
979 pos = pos(1:2) + pos(3:4); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
980 else |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20525
diff
changeset
|
981 error ("annotation: %d, no such arrow number"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
982 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
983 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
984 switch (headstyle) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
985 case "diamond" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
986 x = [0 -ln/2 -ln -ln/2 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
987 y = [0 -wd/2 0 wd/2 0]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
988 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
989 case "ellipse" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
990 pts = linspace (0, 2*pi, 12); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
991 x = ln/2 * (cos (pts) - 1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
992 y = wd/2 * sin (pts); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
993 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
994 case "rectangle" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
995 x = [0 0 -ln -ln 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
996 y = [wd/2 -wd/2 -wd/2 wd/2 wd/2]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
997 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
998 case "vback1" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
999 x = [0 -ln -0.85*ln -ln 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1000 y = [0 wd/2 0 -wd/2 0]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1001 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1002 case "vback2" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1003 x = [0 -ln -0.65*ln -ln 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1004 y = [0 wd/2 0 -wd/2 0]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1005 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1006 case "vback3" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1007 x = [0 -ln -0.2*ln -ln 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1008 y = [0 wd/2 0 -wd/2 0]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1009 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1010 case "plain" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1011 x = [0 -ln -ln -ln 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1012 y = [0 wd/2 0 -wd/2 0]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1013 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1014 case "none" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1015 x = [0 0 0]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1016 y = [0 0 0]; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1017 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1018 otherwise |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1019 ## FIXME: This code is not reachable (12/13/2019) |
24370
b1d1229d9e83
maint: Use single quotes to simplify excessive backslash escapes in code.
Rik <rik@octave.org>
parents:
23396
diff
changeset
|
1020 error ('annotation: "%s" headstyle not implemented', headstyle); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1021 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1022 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1023 R = [cos(ang), -sin(ang); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1024 sin(ang), cos(ang)]; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1025 XY = R * [x; y]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1026 XY = pts2norm (h, XY); |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
29536
diff
changeset
|
1027 XY = pos(1:2).' + XY; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1028 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1029 x = XY(1,:).'; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1030 y = XY(2,:).'; |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1031 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1032 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1033 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1034 function update_arrow (h, ~, prop, hpa = []) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1035 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1036 nar = []; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1037 for i = 1 : numel (hpa) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1038 if (numel (hpa) == 2) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1039 nar = i; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1040 endif |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1041 if (hpa(i)) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1042 switch (prop) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1043 case "position" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1044 [x, y] = arrowcoordinates (h, nar); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1045 set (hpa(i), "xdata", x, "ydata", y); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1046 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1047 case "color" |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1048 set (hpa(i), "facecolor", get (h, "color"), |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
26869
diff
changeset
|
1049 "edgecolor", get (h, "color")); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1050 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1051 endif |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1052 endfor |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1053 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1054 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1055 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1056 function update_text (h, ~, prop, hte) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1057 persistent recursive = false; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1058 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1059 if (! recursive) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1060 switch (prop) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1061 case "position" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1062 if (isempty (get (h, "string"))) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1063 return; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1064 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1065 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1066 pos = getnormpos (h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1067 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1068 set (hte, "position", [textcoordinates(hte, pos) 0]); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1069 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1070 otherwise |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1071 if (strncmp (prop, "text", 4)) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1072 set (hte, prop(5:end), get (h, prop)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1073 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1074 set (hte, prop, get (h, prop)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1075 endif |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1076 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1077 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1078 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1079 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1080 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1081 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1082 function update_textbox (h, ~, prop, htb) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1083 persistent recursive = false; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1084 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1085 hte = htb(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1086 hpa = htb(2); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1087 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1088 if (! recursive) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1089 switch (prop) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1090 case {"edgecolor", "facealpha", "linestyle", "linewidth"} |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1091 set (hpa, prop, get (h, prop)); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1092 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1093 case {"backgroundcolor"} |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1094 set (hpa, "facecolor", get (h, prop)); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1095 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1096 otherwise |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1097 if (! any (strcmp (prop, {"fitboxtotext", "position"}))) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1098 set (hte, prop, get (h, prop)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1099 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1100 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1101 pos = getnormpos (h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1102 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1103 if (strcmp (get (h, "fitboxtotext"), "on")) |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19865
diff
changeset
|
1104 pos(3:4) = get (hte, "extent")(3:4) .* sign (pos(3:4)); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1105 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1106 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1107 [x, y] = pos2rect (pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1108 set (hpa, "xdata", x', "ydata", y'); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1109 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1110 switch (get (h, "horizontalalignment")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1111 case "left" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1112 x = x(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1113 case "center" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1114 x = mean (x(1:2)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1115 case "right" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1116 x = x(2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1117 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1118 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1119 switch (get (h, "verticalalignment")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1120 case {"top", "cap"} |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1121 y = y(3); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1122 case "middle" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1123 y = mean (y(2:3)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1124 case {"bottom", "baseline"} |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1125 y = y(2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1126 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1127 set (hte, "position", [x y 0]); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1128 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1129 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1130 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1131 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1132 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1133 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1134 function XY = textcoordinates (hte, pos) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1135 ## Get the "tight" extent of the text object in points units |
28912
0de38a6ef693
maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents:
28901
diff
changeset
|
1136 textpos = get (hte, "position"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1137 rot = get (hte, "rotation"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1138 units = get (hte, "units"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1139 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1140 set (hte, "rotation", 0, "units", "points", "position", [0 0 0]); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1141 ext = get (hte, "extent"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1142 set (hte, "rotation", rot, "units", units, "position", textpos); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1143 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1144 ## Find which one of the 8 following points we should align the |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1145 ## arrow with |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1146 ## 8-----7-----6 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1147 ## 1 text box 5 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1148 ## 2-----3-----4 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1149 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1150 ## FIXME: Matlab's horizontal/verticalalignment properties are |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1151 ## interpreted differently: horizontalalignment is passed to the |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1152 ## underlying text object whereas the verticalalignement controls |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1153 ## the vertical alignment of the arrow. |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1154 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1155 ang = angle (complex (pos(3), pos(4))); |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20194
diff
changeset
|
1156 rot *= pi / 180; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1157 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1158 [~, pt] = min (abs ((-pi:pi/4:pi) - ang)); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1159 pt -= floor (rot / (pi/4)); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1160 if (pt <= 0) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1161 pt = rem (pt, 8) + 8; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1162 elseif (pt > 8) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1163 pt = rem (pt, 8); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1164 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1165 |
27939
12edd3774db6
annotation.m: For textarrow, space text 2 points away from the line (bug #57553).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27923
diff
changeset
|
1166 ## Compute the actual text "position" property and move the text object |
12edd3774db6
annotation.m: For textarrow, space text 2 points away from the line (bug #57553).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27923
diff
changeset
|
1167 ## 2 points away from the arrow. |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1168 dx = ext(3)/2; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1169 dy = ext(4)/2; |
27939
12edd3774db6
annotation.m: For textarrow, space text 2 points away from the line (bug #57553).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27923
diff
changeset
|
1170 XY = [-dx-2, -dx-2, 0, dx+2, dx+2, dx+2, 0, -dx-2; |
12edd3774db6
annotation.m: For textarrow, space text 2 points away from the line (bug #57553).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27923
diff
changeset
|
1171 0, -dy-2, -dy-2, -dy-2, 0, dy+2, dy+2, dy+2]; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1172 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1173 switch (get (hte, "horizontalalignment")) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1174 case "left" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1175 XY(1,:) += dx; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1176 case "right" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1177 XY(1,:) -= dx; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1178 endswitch |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1179 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1180 switch (get (hte, "verticalalignment")) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1181 case {"baseline", "bottom"} |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1182 XY(2,:) += dy; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1183 case {"cap", "top"} |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1184 XY(2,:) -= dy; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1185 endswitch |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1186 |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1187 R = [cos(rot), -sin(rot); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1188 sin(rot), cos(rot)]; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1189 XY = R * XY; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1190 XY = pts2norm (get (hte, "parent"), XY); |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
29536
diff
changeset
|
1191 XY = pos(1:2) - XY(:,pt).'; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1192 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1193 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1194 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1195 function nXY = pts2norm (h, pXY) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1196 sz = get (get (h, "parent"), "figsize_points"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1197 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1198 nXY(1,:) = pXY(1,:) ./ sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1199 nXY(2,:) = pXY(2,:) ./ sz(2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1200 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1201 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1202 function pXY = norm2pts (h, nXY) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1203 sz = get (get (h, "parent"), "figsize_points"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1204 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1205 pXY(1,:) = nXY(1,:) .* sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1206 pXY(2,:) = nXY(2,:) .* sz(2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1207 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1208 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1209 function pos = convertposition (h, from, to) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1210 ## FIXME: handle "characters" units |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1211 pos = get (h, "position"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1212 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1213 ## First convert to normalized coordinates |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1214 sz = get (get (h, "parent"), "figsize_points"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1215 switch (from) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1216 case "centimeters" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1217 pos /= 2.54; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1218 pos *= 72; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1219 pos(1:2:end) /= sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1220 pos(2:2:end) /= sz(2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1221 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1222 case "inches" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1223 pos *= 72; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1224 pos(1:2:end) /= sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1225 pos(2:2:end) /= sz(2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1226 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1227 case "pixels" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1228 pos /= get (0, "screenpixelsperinch"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1229 pos *= 72; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1230 pos(1:2:end) /= sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1231 pos(2:2:end) /= sz(2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1232 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1233 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1234 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1235 ## Then convert to requested coordinates |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1236 switch (to) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1237 case "centimeters" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1238 sz /= 72; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1239 sz *= 2.54; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1240 pos(1:2:end) *= sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1241 pos(2:2:end) *= sz(2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1242 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1243 case "inches" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1244 sz /= 72; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1245 pos(1:2:end) *= sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1246 pos(2:2:end) *= sz(2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1247 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1248 case "pixels" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1249 sz /= 72; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1250 sz *= get (0, "screenpixelsperinch"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1251 pos(1:2:end) *= sz(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1252 pos(2:2:end) *= sz(2); |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1253 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1254 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1255 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1256 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1257 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1258 function pos = getnormpos (h) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1259 units = get (h, "units"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1260 pos = convertposition (h, units, "normalized"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1261 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1262 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1263 function [x, y] = pos2rect (pos) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1264 x = [pos(1) pos(1)+pos(3) pos(1)+pos(3) pos(1)]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1265 y = [pos(2) pos(2) pos(2)+pos(4) pos(2)+pos(4)]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1266 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1267 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1268 function [x, y] = pos2ell (pos) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1269 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1270 a = pos(3)/2; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1271 b = pos(4)/2; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1272 |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1273 ## Arbitrarily use 100 points when it is spread over |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1274 ang = linspace (0, 2*pi, 100); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1275 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1276 x = a * cos (ang); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1277 y = b * sin (ang); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1278 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1279 x += pos(1) + a; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1280 y += pos(2) + b; |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1281 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1282 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1283 |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1284 function update_rect (h, ~, prop, hre, typ) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1285 persistent recursive = false; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1286 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1287 if (! recursive) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1288 switch (prop) |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1289 case "position" |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1290 pos = getnormpos (h); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1291 if (strcmp (typ, "rectangle")) |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1292 [x, y] = pos2rect (pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1293 else |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1294 [x, y] = pos2ell (pos); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1295 endif |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1296 set (hre, "xdata", x, "ydata", y); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1297 |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1298 case "color" |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1299 set (hre, "edgecolor", get (h, prop)); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1300 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1301 otherwise |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1302 set (hre, prop, get (h, prop)); |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1303 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1304 endswitch |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1305 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1306 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1307 endfunction |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1308 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1309 |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
1310 ## FIXME: the additional regular axes is necessary for fltk to draw the |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1311 ## annotation axes. |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1312 %!demo |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1313 %! clf; axes ("visible", "off"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1314 %! annotation ("textbox", [.25 .9 .5 .09], "string", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1315 %! {"Right Click on annotation objects", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1316 %! "to customize their appearance"}, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1317 %! "horizontalalignment", "center", "fitboxtotext", "off"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1318 %! annotation ("ellipse", [.2 .2 .6 .6], "linewidth", 4); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1319 %! ang = pi/2:-pi/2:-pi; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1320 %! lab = {"N", "W", "S", "E"}; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1321 %! x0 = 0.5; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1322 %! y0 = 0.5; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1323 %! r = 0.3; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1324 %! for i = 1:4 |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1325 %! x = r * cos (ang(i)) + x0; |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1326 %! y = r * sin (ang(i)) + y0; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1327 %! annotation ("textarrow", [x x0], [y y0], ... |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1328 %! "string", lab{i}, "fontsize", 20); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1329 %! endfor |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1330 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1331 %! h = annotation ("doublearrow", [x0 x0], [y0-r y0+r], ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1332 %! "head1style", "diamond", "head1length", 60, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1333 %! "head2style", "diamond", "head2length", 60); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1334 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1335 %!demo |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1336 %! clf; axes ("visible", "off"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1337 %! plot (1:10); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1338 %! xlabel ("X-LABEL"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1339 %! ylabel ("LARGE Y-LABEL", "fontsize", 20); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1340 %! title ("FIGURE LAYOUT", "fontsize", 24); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1341 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1342 %! ti = get (gca, "tightinset"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1343 %! pos = get (gca, "position"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1344 %! pos(1:2) = pos(1:2) - ti(1:2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1345 %! pos(3) = pos(3) + ti (1) + ti (3); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1346 %! pos(4) = pos(4) + ti (2) + ti (4); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1347 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1348 %! ht = annotation ("textbox", pos, "string", " Position + tighinset", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1349 %! "fitboxtotext", "off", "linestyle", "--", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1350 %! "edgecolor", "g", "linewidth", 3, "color", "g", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1351 %! "verticalalignment", "bottom", "fontsize", 15); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1352 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1353 %! ho = annotation ("textbox", get (gca, "outerposition"), ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1354 %! "string", " Outerposition","fitboxtotext", "off", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1355 %! "linestyle", "--", "edgecolor", "r", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1356 %! "linewidth", 3, "color", "r", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1357 %! "verticalalignment", "bottom", "fontsize", 15); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1358 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1359 %! hi = annotation ("textbox", get (gca, "position"), ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1360 %! "string", " Position","fitboxtotext", "off", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1361 %! "linestyle", "--", "edgecolor", "b", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1362 %! "linewidth", 3, "color", "b", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1363 %! "verticalalignment", "bottom", "fontsize", 15); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1364 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1365 %!demo |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1366 %! clf; axes ("visible", "off"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1367 %! h = annotation ("arrow"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1368 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1369 %! ## Get allowed headstyles |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1370 %! styles = set (h, "headstyle"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1371 %! delete (h); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1372 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1373 %! ## Textbox for the title |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1374 %! annotation ("textbox", [0.1 0 0.8 1], "string", ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1375 %! '"headstyle" property:', ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1376 %! "backgroundcolor", [0.7 0.7 0.7], "fontsize", 20, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1377 %! "fitboxtotext", "off", "verticalalignment", "top", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1378 %! "horizontalalignment", "center"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1379 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1380 %! ## Textarrows |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1381 %! ns = numel (styles); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1382 %! nrows = ceil (ns/2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1383 %! dy = 1/nrows; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1384 %! y = 1 - dy/2; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1385 %! |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1386 %! jj = 1; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1387 %! for i = 1:nrows |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1388 %! annotation ("textarrow", [0.3 0.5], [y y], ... |
22320
c563396c5bf1
annotation.m: Fix %!demo #3 to work with dump_plots.m
Rik <rik@octave.org>
parents:
22302
diff
changeset
|
1389 %! "string", styles{jj}, "fontsize", 15, ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1390 %! "headstyle", styles{jj}, "textcolor", "b"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1391 %! jj = jj + 1; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1392 %! if (jj <= ns) |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1393 %! annotation ("textarrow", [0.7 0.5], [y y], ... |
22320
c563396c5bf1
annotation.m: Fix %!demo #3 to work with dump_plots.m
Rik <rik@octave.org>
parents:
22302
diff
changeset
|
1394 %! "string", styles{jj}, "fontsize", 15, ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1395 %! "headstyle", styles{jj}, "textcolor", "b"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1396 %! jj = jj + 1; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1397 %! endif |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1398 %! y = y - dy; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1399 %! endfor |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1400 %! annotation ("line", [0.5 0.5], [dy/2 1-dy/2], "linestyle", "-."); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1401 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1402 %!demo |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1403 %! clf; axes ("visible", "off"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1404 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1405 %! ## Textbox for the title |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1406 %! annotation ("textbox", [0.1 0 0.8 1], "string", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1407 %! "Text arrows: text rotation", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1408 %! "backgroundcolor", [0.7 0.7 0.7], "fontsize", 20, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1409 %! "fitboxtotext", "off", "verticalalignment", "top", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1410 %! "horizontalalignment", "center"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1411 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1412 %! ## Textarrows |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1413 %! for i = 1:10 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1414 %! rot = floor (rand (1) * 360 / 90) * 90; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1415 %! annotation ("textarrow", 0.5 + [(0.6 * (rand(1) - .5)) 0], ... |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1416 %! 0.5 + [(0.6 * (rand(1) - .5)) 0], ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1417 %! "string", "A text", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1418 %! "headstyle", "none", "textrotation", rot); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1419 %! endfor |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1420 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1421 %!demo |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1422 %! clf; axes ("visible", "off"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1423 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1424 %! ## Textbox for the title |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1425 %! annotation ("textbox", [0.1 0 0.8 1], "string", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1426 %! "Text arrows: text alignment", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1427 %! "backgroundcolor", [0.7 0.7 0.7], "fontsize", 20, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1428 %! "fitboxtotext", "off", "verticalalignment", "top", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1429 %! "horizontalalignment", "center"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1430 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1431 %! ## Textarrows |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1432 %! halig = {"right", "center", "left"}; |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1433 %! i = 1; |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1434 %! for x = .3:.2:.7 |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1435 %! annotation ("textarrow", [x .5], [.5 .9], ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1436 %! "string", {"Multiple lines", "text"}, ... |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1437 %! "headstyle", "none", "horizontalalignment", halig{i}); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1438 %! i = i + 1; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1439 %! endfor |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1440 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1441 %!demo |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1442 %! clf; axes ("visible", "off"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1443 %! |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1444 %! x = 0:0.01:2*pi; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1445 %! y = sin (x); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1446 %! plot (x, y); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1447 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1448 %! ## Extrema |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1449 %! x0 = [pi/2 3*pi/2]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1450 %! y0 = [1 -1]; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1451 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1452 %! ## Convert axes coordinates into normalized coordinates |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1453 %! xl = xlim (); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1454 %! yl = [-1.2 1.5]; |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1455 %! ylim (yl); |
28912
0de38a6ef693
maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents:
28901
diff
changeset
|
1456 %! x0 = (x0 - xl(1)) / diff (xl); |
0de38a6ef693
maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents:
28901
diff
changeset
|
1457 %! y0 = (y0 - yl(1)) / diff (yl); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1458 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1459 %! pos = get (gca (), "position"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1460 %! x0 = x0*pos(3) + pos(1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1461 %! y0 = y0*pos(4) + pos(2); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1462 %! |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1463 %! |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1464 %! ## Textarrows |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1465 %! for i = 1:2 |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1466 %! annotation ("doublearrow", [(x0(i) - .05) (x0(i) + .05)], ... |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1467 %! [y0(i) y0(i)], "head1style", "vback3", ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1468 %! "head2style", "vback3", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1469 %! "head1width", 4, "head2width", 4) |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1470 %! h = annotation ("textarrow", [0.5 x0(i)], [.85 y0(i)], ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1471 %! "linestyle", "--", "headstyle", "none"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1472 %! endfor |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
1473 %! set (h, "string", "Extrema", "fontsize", 15); |
24388 | 1474 %! title ("annotation() demo of TextArrows"); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1475 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1476 ## test line properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1477 %!test |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1478 %! hf = figure ("visible", "off"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1479 %! hax = axes (); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1480 %! unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1481 %! h = annotation ("line", [0.2 0.7], [0.2 0.7], "linewidth", 2, |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1482 %! "linestyle", "--", "color", "r"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1483 %! hli = get (h, "children"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1484 %! assert (get (hli, "linewidth"), 2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1485 %! assert (get (hli, "linestyle"), "--"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1486 %! assert (get (hli, "color"), [1 0 0]); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1487 %! assert (gca (), hax); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1488 %! unwind_protect_cleanup |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1489 %! close (hf); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1490 %! end_unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1491 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1492 ## test textarrow properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1493 %!test |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1494 %! hf = figure ("visible", "off"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1495 %! unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1496 %! h = annotation ("textarrow", [0.2 0.7], [0.2 0.7], |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1497 %! "string", "Hello!", "fontsize", 20, |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1498 %! "textrotation", 90, "textcolor", "r"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1499 %! hte = findobj (h, "-depth", 1, "type", "text"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1500 %! assert (get (hte, "string"), "Hello!"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1501 %! assert (get (hte, "fontsize"), 20); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1502 %! assert (get (hte, "rotation"), 90); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1503 %! assert (get (hte, "color"), [1 0 0]); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1504 %! unwind_protect_cleanup |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1505 %! close (hf); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1506 %! end_unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1507 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1508 ## test textbox properties |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1509 %!test |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1510 %! hf = figure ("visible", "off"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1511 %! unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1512 %! h = annotation ("textbox", [0.2 0.2 0.7 0.3], "string", "Hello!", |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1513 %! "horizontalalignment", "left", |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1514 %! "verticalalignment", "bottom", |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1515 %! "backgroundcolor", "r"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1516 %! hte = findobj (h, "-depth", 1, "type", "text"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1517 %! hpa = findobj (h, "-depth", 1, "type", "patch"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1518 %! assert (get (hte, "string"), "Hello!"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1519 %! assert (get (hte, "verticalalignment"), "bottom"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1520 %! assert (get (hte, "horizontalalignment"), "left"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1521 %! assert (get (hpa, "facecolor"), [1 0 0]); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1522 %! unwind_protect_cleanup |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1523 %! close (hf); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1524 %! end_unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1525 |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1526 ## test rectangle properties |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1527 %!test |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1528 %! hf = figure ("visible", "off"); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1529 %! hax = axes (); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1530 %! unwind_protect |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1531 %! h = annotation ("rectangle", [0.2 0.7 0.2 0.2], "linewidth", 2, |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1532 %! "linestyle", "--", "color", "r", "facecolor", "b", |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1533 %! "facealpha", .6, "units", "normalized"); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1534 %! hpa = get (h, "children"); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1535 %! assert (get (hpa, "xdata"), [0.2; 0.4; 0.4; 0.2], eps); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1536 %! assert (get (hpa, "ydata"), [0.7; 0.7; 0.9; 0.9], eps); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1537 %! assert (get (hpa, "linewidth"), 2); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1538 %! assert (get (hpa, "linestyle"), "--"); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1539 %! assert (get (hpa, "edgecolor"), [1 0 0]); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1540 %! assert (get (hpa, "edgecolor"), get (h, "color")); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1541 %! assert (get (hpa, "facecolor"), [0 0 1]); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1542 %! assert (get (hpa, "facealpha"), .6); |
23396
945b53af4655
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1543 %! |
23176
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1544 %! assert (gca (), hax); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1545 %! unwind_protect_cleanup |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1546 %! close (hf); |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1547 %! end_unwind_protect |
5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23084
diff
changeset
|
1548 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1549 ## test units conversion |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1550 %!test |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1551 %! hf = figure ("visible", "off"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1552 %! unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1553 %! h = annotation ("arrow", [0.1 0.2], [0.5 0.2]); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1554 %! set (h, "units", "inches"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1555 %! pos = get (h, "position"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1556 %! x = get (h, "x"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1557 %! y = get (h, "y"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1558 %! set (h, "units", "centimeters"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1559 %! assert (get (h, "position"), pos * 2.54, 20*eps); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1560 %! assert (get (h, "x"), x * 2.54, 20*eps); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1561 %! assert (get (h, "y"), y * 2.54, 20*eps); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1562 %! unwind_protect_cleanup |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1563 %! close (hf); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1564 %! end_unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1565 |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1566 ## test annotated figure |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1567 %!test |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1568 %! hf1 = figure ("visible", "off"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1569 %! hf2 = figure ("visible", "off"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1570 %! unwind_protect |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1571 %! h = annotation (hf1, "doublearrow"); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1572 %! assert (ancestor (h, "figure"), hf1); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1573 %! assert (gcf (), hf2); |
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1574 %! unwind_protect_cleanup |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1575 %! close (hf1); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21385
diff
changeset
|
1576 %! close (hf2); |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1577 %! end_unwind_protect |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19820
diff
changeset
|
1578 |
19741
b8e4104a8f55
Add the annotation function (bug #43282)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
1579 ## Test input validation |
28896
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28563
diff
changeset
|
1580 %!error <Invalid call> annotation () |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1581 %!error <Invalid call to annotation> annotation ({"line"}, 1:2, 1:2) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1582 %!error <X and Y must be 2-element vectors> annotation ("line", {1:2}, 1:2) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1583 %!error <X and Y must be 2-element vectors> annotation ("line", 1:2, {1:2}) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1584 %!error <X and Y must be 2-element vectors> annotation ("line", 1:3, 1:2) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1585 %!error <X and Y must be 2-element vectors> annotation ("line", 1:2, 1:3) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1586 %!error <Invalid call to annotation> annotation ("line", 1:2) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1587 %!error <POS must be a 4-element vector> annotation ("textbox", ones (4,4)) |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1588 %!error <POS must be a 4-element vector> annotation ("textbox", 1:3) |
22765
01aae08a0105
maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents:
22760
diff
changeset
|
1589 %!error <unknown annotation TYPE foo> annotation ("foo") |
27816
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1590 %!warning <couldn't parse PROP/VAL pairs, skipping> |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1591 %! hf = figure ("visible", "off"); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1592 %! unwind_protect |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1593 %! annotation ("line", 1:2, 1:2, "color"); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1594 %! unwind_protect_cleanup |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1595 %! close (hf); |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1596 %! end_unwind_protect |
9a498cde5bc5
annotation.m: Octave coding style changes.
Rik <rik@octave.org>
parents:
27815
diff
changeset
|
1597 %!error <unknown annotation TYPE foo> annotation ("foo") |