annotate libinterp/corefcn/graphics.cc @ 19629:be7ac98fab43 gui-release

strip trailing whitespace from most source files * NEWS, etc/NEWS.3, libgui/graphics/Backend.h, libgui/graphics/ButtonControl.h, libgui/graphics/EditControl.cc, libgui/graphics/Object.h, libgui/graphics/QtHandlesUtils.cc, libgui/graphics/ToolBarButton.h, libgui/graphics/__init_qt__.cc, libgui/graphics/gl-select.cc, libgui/qterminal/libqterminal/unix/TerminalView.cpp, libgui/qterminal/libqterminal/unix/TerminalView.h, libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp, libgui/src/m-editor/file-editor-tab.cc, libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/file-editor.h, libgui/src/m-editor/octave-qscintilla.cc, libgui/src/settings-dialog.cc, libgui/src/shortcut-manager.cc, libgui/src/workspace-view.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/input.cc, libinterp/parse-tree/pt-unop.cc, liboctave/array/dSparse.h, scripts/pkg/pkg.m, scripts/polynomial/polyeig.m, test/io.tst: Strip trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 09:43:29 -0500
parents fe689210525c
children 0e1f5a750d00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1 /*
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17652
diff changeset
3 Copyright (C) 2007-2013 John W. Eaton
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
10 option) any later version.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
11
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
15 for more details.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
16
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
19 <http://www.gnu.org/licenses/>.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
20
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
21 */
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
22
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
25 #endif
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
26
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
27 #include <cctype>
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
28 #include <cfloat>
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
29 #include <cstdlib>
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
30 #include <ctime>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
31
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
32 #include <algorithm>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
33 #include <list>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
34 #include <map>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
35 #include <set>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
36 #include <string>
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
37 #include <sstream>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
38
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
39 #include "cmd-edit.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
40 #include "file-ops.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
41 #include "file-stat.h"
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
42 #include "oct-locbuf.h"
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
43 #include "singleton-cleanup.h"
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
44
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
45 #include "builtins.h"
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
46 #include "cutils.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
47 #include "defun.h"
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
48 #include "display.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
49 #include "error.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
50 #include "graphics.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
51 #include "input.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
52 #include "ov.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
53 #include "oct-obj.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
54 #include "oct-map.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
55 #include "ov-fcn-handle.h"
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
56 #include "pager.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
57 #include "parse.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
58 #include "toplev.h"
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
59 #include "txt-eng-ft.h"
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
60 #include "unwind-prot.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
61
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
62 // forward declarations
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
63 static octave_value xget (const graphics_handle& h, const caseless_str& name);
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
64
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
65 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
66 gripe_set_invalid (const std::string& pname)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
67 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
68 error ("set: invalid value for %s property", pname.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
69 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
70
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
71 // Check to see that PNAME matches just one of PNAMES uniquely.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
72 // Return the full name of the match, or an empty caseless_str object
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
73 // if there is no match, or the match is ambiguous.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
74
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
75 static caseless_str
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
76 validate_property_name (const std::string& who, const std::string& what,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
77 const std::set<std::string>& pnames,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
78 const caseless_str& pname)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
79 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
80 size_t len = pname.length ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
81 std::set<std::string> matches;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
82
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
83 for (std::set<std::string>::const_iterator p = pnames.begin ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
84 p != pnames.end (); p++)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
85 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
86 if (pname.compare (*p, len))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
87 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
88 if (len == p->length ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
89 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
90 // Exact match.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
91 return pname;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
92 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
93
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
94 matches.insert (*p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
95 }
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
96 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
97
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
98 size_t num_matches = matches.size ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
99
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
100 if (num_matches == 0)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
101 {
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
102 error ("%s: unknown %s property %s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
103 who.c_str (), what.c_str (), pname.c_str ());
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
104 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
105 else if (num_matches > 1)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
106 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
107 string_vector sv (matches);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
108
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
109 std::ostringstream os;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
110
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
111 sv.list_in_columns (os);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
112
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
113 std::string match_list = os.str ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
114
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
115 error ("%s: ambiguous %s property name %s; possible matches:\n\n%s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
116 who.c_str (), what.c_str (), pname.c_str (), match_list.c_str ());
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
117 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
118 else if (num_matches == 1)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
119 {
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
120 // Exact match was handled above.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
121
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
122 std::string possible_match = *(matches.begin ());
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
123
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
124 warning_with_id ("Octave:abbreviated-property-match",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
125 "%s: allowing %s to match %s property %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
126 who.c_str (), pname.c_str (), what.c_str (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
127 possible_match.c_str ());
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
128
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
129 return possible_match;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
130 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
131
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
132 return caseless_str ();
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
133 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
134
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
135 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
136 jet_colormap (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
137 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
138 Matrix cmap (64, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
139
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
140 // Produce X in the same manner as linspace so that
15707
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
141 // jet_colormap and jet.m produce *exactly* the same result.
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
142 double delta = 1.0 / 63.0;
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
143
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
144 for (octave_idx_type i = 0; i < 64; i++)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
145 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
146 // This is the jet colormap. It would be nice to be able
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
147 // to feval the jet function but since there is a static
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
148 // property object that includes a colormap_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
149 // object, we need to initialize this before main is even
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
150 // called, so calling an interpreted function is not
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
151 // possible.
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
152
15707
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
153 double x = i*delta;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
154
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
155 if (x >= 3.0/8.0 && x < 5.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
156 cmap(i,0) = 4.0 * x - 3.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
157 else if (x >= 5.0/8.0 && x < 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
158 cmap(i,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
159 else if (x >= 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
160 cmap(i,0) = -4.0 * x + 9.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
161
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
162 if (x >= 1.0/8.0 && x < 3.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
163 cmap(i,1) = 4.0 * x - 1.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
164 else if (x >= 3.0/8.0 && x < 5.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
165 cmap(i,1) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
166 else if (x >= 5.0/8.0 && x < 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
167 cmap(i,1) = -4.0 * x + 7.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
168
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
169 if (x < 1.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
170 cmap(i,2) = 4.0 * x + 1.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
171 else if (x >= 1.0/8.0 && x < 3.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
172 cmap(i,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
173 else if (x >= 3.0/8.0 && x < 5.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
174 cmap(i,2) = -4.0 * x + 5.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
175 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
176
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
177 return cmap;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
178 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
179
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
180 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
181 default_screendepth (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
182 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
183 return display_info::depth ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
184 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
185
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
186 static Matrix
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
187 default_screensize (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
188 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
189 Matrix retval (1, 4, 1.0);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
190
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
191 retval(2) = display_info::width ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
192 retval(3) = display_info::height ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
193
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
194 return retval;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
195 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
196
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
197 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
198 default_screenpixelsperinch (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
199 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
200 return (display_info::x_dpi () + display_info::y_dpi ()) / 2;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
201 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
202
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
203 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
204 default_colororder (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
205 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
206 Matrix retval (7, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
207
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
208 retval(0,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
209
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
210 retval(1,1) = 0.5;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
211
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
212 retval(2,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
213
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
214 retval(3,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
215 retval(3,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
216
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
217 retval(4,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
218 retval(4,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
219
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
220 retval(5,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
221 retval(5,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
222
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
223 retval(6,0) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
224 retval(6,1) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
225 retval(6,2) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
226
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
227 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
228 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
229
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
230 static Matrix
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
231 default_lim (bool logscale = false)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
232 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
233 Matrix m (1, 2, 0);
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
234
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
235 if (logscale)
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
236 {
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
237 m(0) = 0.1;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
238 m(1) = 1.0;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
239 }
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
240 else
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
241 m(1) = 1;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
242
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
243 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
244 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
245
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
246 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
247 default_data (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
248 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
249 Matrix retval (1, 2);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
250
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
251 retval(0) = 0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
252 retval(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
253
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
254 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
255 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
256
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
257 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
258 default_axes_position (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
259 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
260 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
261 m(0) = 0.13;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
262 m(1) = 0.11;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
263 m(2) = 0.775;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
264 m(3) = 0.815;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
265 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
266 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
267
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
268 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
269 default_axes_outerposition (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
270 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
271 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
272 m(2) = m(3) = 1.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
273 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
274 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
275
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
276 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
277 default_axes_tick (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
278 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
279 Matrix m (1, 6, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
280 m(0) = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
281 m(1) = 0.2;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
282 m(2) = 0.4;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
283 m(3) = 0.6;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
284 m(4) = 0.8;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
285 m(5) = 1.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
286 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
287 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
288
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
289 static Matrix
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
290 default_axes_ticklength (void)
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
291 {
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
292 Matrix m (1, 2, 0.0);
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
293 m(0) = 0.01;
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
294 m(1) = 0.025;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
295 return m;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
296 }
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
297
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
298 static Matrix
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
299 default_figure_position (void)
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
300 {
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
301 Matrix m (1, 4, 0.0);
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
302 m(0) = 300;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
303 m(1) = 200;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
304 m(2) = 560;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
305 m(3) = 420;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
306 return m;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
307 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
308
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
309 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
310 default_figure_papersize (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
311 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
312 Matrix m (1, 2, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
313 m(0) = 8.5;
8961
6b87f2f34fdd graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents: 8944
diff changeset
314 m(1) = 11.0;
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
315 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
316 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
317
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
318 static Matrix
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
319 default_figure_paperposition (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
320 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
321 Matrix m (1, 4, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
322 m(0) = 0.25;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
323 m(1) = 2.50;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
324 m(2) = 8.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
325 m(3) = 6.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
326 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
327 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
328
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
329 static Matrix
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
330 default_control_position (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
331 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
332 Matrix retval (1, 4, 0.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
333
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
334 retval(0) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
335 retval(1) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
336 retval(2) = 80;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
337 retval(3) = 30;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
338
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
339 return retval;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
340 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
341
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
342 static Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
343 default_control_sliderstep (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
344 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
345 Matrix retval (1, 2, 0.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
346
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
347 retval(0) = 0.01;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
348 retval(1) = 0.1;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
349
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
350 return retval;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
351 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
352
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
353 static Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
354 default_panel_position (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
355 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
356 Matrix retval (1, 4, 0.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
357
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
358 retval(0) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
359 retval(1) = 0;
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
360 retval(2) = 0.5;
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
361 retval(3) = 0.5;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
362
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
363 return retval;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
364 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
365
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
366 static double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
367 convert_font_size (double font_size, const caseless_str& from_units,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
368 const caseless_str& to_units, double parent_height = 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
369 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
370 // Simple case where from_units == to_units
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
371
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
372 if (from_units.compare (to_units))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
373 return font_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
374
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
375 // Converts the given fontsize using the following transformation:
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
376 // <old_font_size> => points => <new_font_size>
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
377
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
378 double points_size = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
379 double res = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
380
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
381 if (from_units.compare ("points"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
382 points_size = font_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
383 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
384 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
385 res = xget (0, "screenpixelsperinch").double_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
386
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
387 if (from_units.compare ("pixels"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
388 points_size = font_size * 72.0 / res;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
389 else if (from_units.compare ("inches"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
390 points_size = font_size * 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
391 else if (from_units.compare ("centimeters"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
392 points_size = font_size * 72.0 / 2.54;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
393 else if (from_units.compare ("normalized"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
394 points_size = font_size * parent_height * 72.0 / res;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
395 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
396
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
397 double new_font_size = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
398
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
399 if (to_units.compare ("points"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
400 new_font_size = points_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
401 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
402 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
403 if (res <= 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
404 res = xget (0, "screenpixelsperinch").double_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
405
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
406 if (to_units.compare ("pixels"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
407 new_font_size = points_size * res / 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
408 else if (to_units.compare ("inches"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
409 new_font_size = points_size / 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
410 else if (to_units.compare ("centimeters"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
411 new_font_size = points_size * 2.54 / 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
412 else if (to_units.compare ("normalized"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
413 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
414 // Avoid setting font size to (0/0) = NaN
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
415
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
416 if (parent_height > 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
417 new_font_size = points_size * res / (parent_height * 72.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
418 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
419 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
420
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
421 return new_font_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
422 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
423
13804
4f112bebd474 use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents: 13801
diff changeset
424 static Matrix
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
425 convert_position (const Matrix& pos, const caseless_str& from_units,
13799
760e4e88dba3 convert units for figure positions
John W. Eaton <jwe@octave.org>
parents: 13757
diff changeset
426 const caseless_str& to_units, const Matrix& parent_dim)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
427 {
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
428 Matrix retval (1, pos.numel ());
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
429 double res = 0;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
430 bool is_rectangle = (pos.numel () == 4);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
431 bool is_2d = (pos.numel () == 2);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
432
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
433 if (from_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
434 retval = pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
435 else if (from_units.compare ("normalized"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
436 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
437 retval(0) = pos(0) * parent_dim(0) + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
438 retval(1) = pos(1) * parent_dim(1) + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
439 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
440 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
441 retval(2) = pos(2) * parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
442 retval(3) = pos(3) * parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
443 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
444 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
445 retval(2) = 0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
446 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
447 else if (from_units.compare ("characters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
448 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
449 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
450 res = xget (0, "screenpixelsperinch").double_value ();
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
451
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
452 double f = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
453
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
454 // FIXME: this assumes the system font is Helvetica 10pt
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
455 // (for which "x" requires 6x12 pixels at 74.951 pixels/inch)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
456 f = 12.0 * res / 74.951;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
457
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
458 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
459 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
460 retval(0) = 0.5 * pos(0) * f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
461 retval(1) = pos(1) * f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
462 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
463 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
464 retval(2) = 0.5 * pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
465 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
466 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
467 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
468 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
469 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
470 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
471 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
472 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
473 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
474 res = xget (0, "screenpixelsperinch").double_value ();
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
475
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
476 double f = 0.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
477
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
478 if (from_units.compare ("points"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
479 f = res / 72.0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
480 else if (from_units.compare ("inches"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
481 f = res;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
482 else if (from_units.compare ("centimeters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
483 f = res / 2.54;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
484
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
485 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
486 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
487 retval(0) = pos(0) * f + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
488 retval(1) = pos(1) * f + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
489 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
490 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
491 retval(2) = pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
492 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
493 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
494 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
495 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
496 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
497 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
498
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
499 if (! to_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
500 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
501 if (to_units.compare ("normalized"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
502 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
503 retval(0) = (retval(0) - 1) / parent_dim(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
504 retval(1) = (retval(1) - 1) / parent_dim(1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
505 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
506 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
507 retval(2) /= parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
508 retval(3) /= parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
509 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
510 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
511 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
512 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
513 else if (to_units.compare ("characters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
514 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
515 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
516 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
517
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
518 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
519
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
520 f = 12.0 * res / 74.951;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
521
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
522 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
523 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
524 retval(0) = 2 * retval(0) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
525 retval(1) = retval(1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
526 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
527 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
528 retval(2) = 2 * retval(2) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
529 retval(3) = retval(3) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
530 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
531 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
532 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
533 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
534 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
535 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
536 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
537 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
538 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
539
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
540 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
541
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
542 if (to_units.compare ("points"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
543 f = res / 72.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
544 else if (to_units.compare ("inches"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
545 f = res;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
546 else if (to_units.compare ("centimeters"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
547 f = res / 2.54;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
548
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
549 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
550 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
551 retval(0) = (retval(0) - 1) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
552 retval(1) = (retval(1) - 1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
553 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
554 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
555 retval(2) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
556 retval(3) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
557 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
558 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
559 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
560 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
561 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
562 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
563 else if (! is_rectangle && ! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
564 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
565
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
566 return retval;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
567 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
568
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
569 static Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
570 convert_text_position (const Matrix& pos, const text::properties& props,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
571 const caseless_str& from_units,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
572 const caseless_str& to_units)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
573 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
574 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
575 graphics_object ax = go.get_ancestor ("axes");
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
576
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
577 Matrix retval;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
578
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
579 if (ax.valid_object ())
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
580 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
581 const axes::properties& ax_props =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
582 dynamic_cast<const axes::properties&> (ax.get_properties ());
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
583 graphics_xform ax_xform = ax_props.get_transform ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
584 bool is_rectangle = (pos.numel () == 4);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
585 Matrix ax_bbox = ax_props.get_boundingbox (true),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
586 ax_size = ax_bbox.extract_n (0, 2, 1, 2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
587
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
588 if (from_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
589 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
590 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
591 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
592 ColumnVector v1 = ax_xform.transform (pos(0), pos(1), 0),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
593 v2 = ax_xform.transform (pos(0) + pos(2),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
594 pos(1) + pos(3), 0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
595
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
596 retval.resize (1, 4);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
597
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
598 retval(0) = v1(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
599 retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
600 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
601 retval(3) = v1(1) - v2(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
602 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
603 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
604 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
605 ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2));
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
606
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
607 retval.resize (1, 3);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
608
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
609 retval(0) = v(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
610 retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
611 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
612 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
613 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
614 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
615 retval = convert_position (pos, from_units, "pixels", ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
616
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
617 if (! to_units.compare ("pixels"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
618 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
619 if (to_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
620 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
621 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
622 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
623 ColumnVector v1, v2;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
624 v1 = ax_xform.untransform (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
625 retval(0) + ax_bbox(0) - 1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
626 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
627 v2 = ax_xform.untransform (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
628 retval(0) + retval(2) + ax_bbox(0) - 1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
629 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
630
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
631 retval.resize (1, 4);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
632
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
633 retval(0) = v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
634 retval(1) = v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
635 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
636 retval(3) = v2(1) - v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
637 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
638 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
639 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
640 ColumnVector v;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
641 v = ax_xform.untransform (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
642 retval(0) + ax_bbox(0) - 1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
643 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
644
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
645 retval.resize (1, 3);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
646
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
647 retval(0) = v(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
648 retval(1) = v(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
649 retval(2) = v(2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
650 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
651 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
652 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
653 retval = convert_position (retval, "pixels", to_units, ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
654 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
655 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
656
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
657 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
658 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
659
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
660 // This function always returns the screensize in pixels
13804
4f112bebd474 use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents: 13801
diff changeset
661 static Matrix
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
662 screen_size_pixels (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
663 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
664 graphics_object obj = gh_manager::get_object (0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
665 Matrix sz = obj.get ("screensize").matrix_value ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
666 return convert_position (sz, obj.get ("units").string_value (), "pixels",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
667 sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
668 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
669
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
670 static void
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
671 convert_cdata_2 (bool is_scaled, double clim_0, double clim_1,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
672 const double *cmapv, double x, octave_idx_type lda,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
673 octave_idx_type nc, octave_idx_type i, double *av)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
674 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
675 if (is_scaled)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
676 x = xround ((nc - 1) * (x - clim_0) / (clim_1 - clim_0));
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
677 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
678 x = xround (x - 1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
679
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
680 if (xisnan (x))
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
681 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
682 av[i] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
683 av[i+lda] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
684 av[i+2*lda] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
685 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
686 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
687 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
688 if (x < 0)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
689 x = 0;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
690 else if (x >= nc)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
691 x = (nc - 1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
692
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
693 octave_idx_type idx = static_cast<octave_idx_type> (x);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
694
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
695 av[i] = cmapv[idx];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
696 av[i+lda] = cmapv[idx+nc];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
697 av[i+2*lda] = cmapv[idx+2*nc];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
698 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
699 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
700
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
701 template <class T>
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
702 void
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
703 convert_cdata_1 (bool is_scaled, double clim_0, double clim_1,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
704 const double *cmapv, const T *cv, octave_idx_type lda,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
705 octave_idx_type nc, double *av)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
706 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
707 for (octave_idx_type i = 0; i < lda; i++)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
708 convert_cdata_2 (is_scaled, clim_0, clim_1, cmapv, cv[i], lda, nc, i, av);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
709 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
710
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
711 static octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
712 convert_cdata (const base_properties& props, const octave_value& cdata,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
713 bool is_scaled, int cdim)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
714 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
715 dim_vector dv (cdata.dims ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
716
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
717 if (dv.length () == cdim && dv(cdim-1) == 3)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
718 return cdata;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
719
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
720 Matrix cmap (1, 3, 0.0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
721 Matrix clim (1, 2, 0.0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
722
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
723 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
724 graphics_object fig = go.get_ancestor ("figure");
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
725
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
726 if (fig.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
727 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
728 Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
729
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
730 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
731 cmap = _cmap;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
732 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
733
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
734 if (is_scaled)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
735 {
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
736 graphics_object ax = go.get_ancestor ("axes");
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
737
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
738 if (ax.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
739 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
740 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
741
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
742 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
743 clim = _clim;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
744 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
745 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
746
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
747 dv.resize (cdim);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
748 dv(cdim-1) = 3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
749
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
750 NDArray a (dv);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
751
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
752 octave_idx_type lda = a.numel () / static_cast<octave_idx_type> (3);
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
753 octave_idx_type nc = cmap.rows ();
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
754
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
755 double *av = a.fortran_vec ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
756 const double *cmapv = cmap.data ();
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
757
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
758 double clim_0 = clim(0);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
759 double clim_1 = clim(1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
760
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
761 #define CONVERT_CDATA_1(ARRAY_T, VAL_FN) \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
762 do \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
763 { \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
764 ARRAY_T tmp = cdata. VAL_FN ## array_value (); \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
765 \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
766 convert_cdata_1 (is_scaled, clim_0, clim_1, cmapv, \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
767 tmp.data (), lda, nc, av); \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
768 } \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
769 while (0)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
770
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
771 if (cdata.is_uint8_type ())
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
772 CONVERT_CDATA_1 (uint8NDArray, uint8_);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
773 else if (cdata.is_single_type ())
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
774 CONVERT_CDATA_1 (FloatNDArray, float_);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
775 else if (cdata.is_double_type ())
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
776 CONVERT_CDATA_1 (NDArray, );
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
777 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
778 error ("unsupported type for cdata (= %s)", cdata.type_name ().c_str ());
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
779
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
780 #undef CONVERT_CDATA_1
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
781
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
782 return octave_value (a);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
783 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
784
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
785 template<class T>
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
786 static void
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
787 get_array_limits (const Array<T>& m, double& emin, double& emax,
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
788 double& eminp, double& emaxp)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
789 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
790 const T *data = m.data ();
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
791 octave_idx_type n = m.numel ();
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
792
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
793 for (octave_idx_type i = 0; i < n; i++)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
794 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
795 double e = double (data[i]);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
796
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
797 // Don't need to test for NaN here as NaN>x and NaN<x is always false
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
798 if (! xisinf (e))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
799 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
800 if (e < emin)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
801 emin = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
802
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
803 if (e > emax)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
804 emax = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
805
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
806 if (e > 0 && e < eminp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
807 eminp = e;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
808
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
809 if (e < 0 && e > emaxp)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
810 emaxp = e;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
811 }
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
812 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
813 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
814
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
815 static bool
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
816 lookup_object_name (const caseless_str& name, caseless_str& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
817 caseless_str& rest)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
818 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
819 int len = name.length ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
820 int offset = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
821 bool result = false;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
822
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
823 if (len >= 4)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
824 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
825 caseless_str pfx = name.substr (0, 4);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
826
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
827 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
828 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
829 offset = 4;
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
830 else if (len >= 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
831 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
832 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
833
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
834 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
835 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
836 else if (len >= 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
837 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
838 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
839
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
840 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
841 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
842 else if (len >= 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
843 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
844 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
845
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
846 if (pfx.compare ("surface") || pfx.compare ("hggroup")
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
847 || pfx.compare ("uipanel"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
848 offset = 7;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
849 else if (len >= 9)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
850 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
851 pfx = name.substr (0, 9);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
852
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
853 if (pfx.compare ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
854 || pfx.compare ("uitoolbar"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
855 offset = 9;
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
856 else if (len >= 10)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
857 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
858 pfx = name.substr (0, 10);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
859
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
860 if (pfx.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
861 offset = 10;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
862 else if (len >= 12)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
863 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
864 pfx = name.substr (0, 12);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
865
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
866 if (pfx.compare ("uitoggletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
867 offset = 12;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
868 else if (len >= 13)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
869 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
870 pfx = name.substr (0, 13);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
871
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
872 if (pfx.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
873 offset = 13;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
874 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
875 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
876 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
877 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
878 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
879 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
880 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
881
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
882 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
883 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
884 go_name = pfx;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
885 rest = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
886 result = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
887 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
888 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
889
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
890 return result;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
891 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
892
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
893 static base_graphics_object*
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
894 make_graphics_object_from_type (const caseless_str& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
895 const graphics_handle& h = graphics_handle (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
896 const graphics_handle& p = graphics_handle ())
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
897 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
898 base_graphics_object *go = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
899
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
900 if (type.compare ("figure"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
901 go = new figure (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
902 else if (type.compare ("axes"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
903 go = new axes (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
904 else if (type.compare ("line"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
905 go = new line (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
906 else if (type.compare ("text"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
907 go = new text (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
908 else if (type.compare ("image"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
909 go = new image (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
910 else if (type.compare ("patch"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
911 go = new patch (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
912 else if (type.compare ("surface"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
913 go = new surface (h, p);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
914 else if (type.compare ("hggroup"))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
915 go = new hggroup (h, p);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
916 else if (type.compare ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
917 go = new uimenu (h, p);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
918 else if (type.compare ("uicontrol"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
919 go = new uicontrol (h, p);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
920 else if (type.compare ("uipanel"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
921 go = new uipanel (h, p);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
922 else if (type.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
923 go = new uicontextmenu (h, p);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
924 else if (type.compare ("uitoolbar"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
925 go = new uitoolbar (h, p);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
926 else if (type.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
927 go = new uipushtool (h, p);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
928 else if (type.compare ("uitoggletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
929 go = new uitoggletool (h, p);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
930 return go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
931 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
932
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
933 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
934
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
935 bool
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
936 base_property::set (const octave_value& v, bool do_run, bool do_notify_toolkit)
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
937 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
938 if (do_set (v))
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
939 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
940
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
941 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
942 if (id >= 0 && do_notify_toolkit)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
943 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
944 graphics_object go = gh_manager::get_object (parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
945 if (go)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
946 go.update (id);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
947 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
948
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
949 // run listeners
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
950 if (do_run && ! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
951 run_listeners (POSTSET);
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
952
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
953 return true;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
954 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
955
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
956 return false;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
957 }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
958
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
959
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
960 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
961 base_property::run_listeners (listener_mode mode)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
962 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
963 const octave_value_list& l = listeners[mode];
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
964
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
965 for (int i = 0; i < l.length (); i++)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
966 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
967 gh_manager::execute_listener (parent, l(i));
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
968
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
969 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
970 break;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
971 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
972 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
973
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
974 radio_values::radio_values (const std::string& opt_string)
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
975 : default_val (), possible_vals ()
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
976 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
977 size_t beg = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
978 size_t len = opt_string.length ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
979 bool done = len == 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
980
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
981 while (! done)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
982 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
983 size_t end = opt_string.find ('|', beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
984
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
985 if (end == std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
986 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
987 end = len;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
988 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
989 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
990
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
991 std::string t = opt_string.substr (beg, end-beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
992
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
993 // Might want more error checking here...
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
994 if (t[0] == '{')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
995 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
996 t = t.substr (1, t.length () - 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
997 default_val = t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
998 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
999 else if (beg == 0) // ensure default value
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1000 default_val = t;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1001
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1002 possible_vals.insert (t);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1003
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1004 beg = end + 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1005 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1006 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1007
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1008 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1009 radio_values::values_as_string (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1010 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1011 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1012 for (std::set<caseless_str>::const_iterator it = possible_vals.begin ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1013 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1014 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1015 if (retval == "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1016 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1017 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1018 retval = "{" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1019 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1020 retval = *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1021 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1022 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1023 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1024 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1025 retval += " | {" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1026 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1027 retval += " | " + *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1028 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1029 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1030 if (retval != "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1031 retval = "[ " + retval + " ]";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1032 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1033 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1034
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1035 Cell
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1036 radio_values::values_as_cell (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1037 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1038 octave_idx_type i = 0;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1039 Cell retval (nelem (), 1);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1040 for (std::set<caseless_str>::const_iterator it = possible_vals.begin ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1041 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1042 retval(i++) = std::string (*it);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1043 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1044 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1045
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1046 bool
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1047 color_values::str2rgb (std::string str)
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1048 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1049 double tmp_rgb[3] = {0, 0, 0};
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1050 bool retval = true;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
1051 unsigned int len = str.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1052
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
1053 std::transform (str.begin (), str.end (), str.begin (), tolower);
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
1054
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1055 if (str.compare (0, len, "blue", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1056 tmp_rgb[2] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1057 else if (str.compare (0, len, "black", 0, len) == 0
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1058 || str.compare (0, len, "k", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1059 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1060 else if (str.compare (0, len, "red", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1061 tmp_rgb[0] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1062 else if (str.compare (0, len, "green", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1063 tmp_rgb[1] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1064 else if (str.compare (0, len, "yellow", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1065 tmp_rgb[0] = tmp_rgb[1] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1066 else if (str.compare (0, len, "magenta", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1067 tmp_rgb[0] = tmp_rgb[2] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1068 else if (str.compare (0, len, "cyan", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1069 tmp_rgb[1] = tmp_rgb[2] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1070 else if (str.compare (0, len, "white", 0, len) == 0
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1071 || str.compare (0, len, "w", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1072 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1073 else
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1074 retval = false;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1075
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1076 if (retval)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1077 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1078 for (int i = 0; i < 3; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1079 xrgb(i) = tmp_rgb[i];
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1080 }
6563
7a65c1a09ec3 [project @ 2007-04-23 19:26:17 by jwe]
jwe
parents: 6509
diff changeset
1081
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1082 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1083 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1084
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1085 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1086 color_property::do_set (const octave_value& val)
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1087 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1088 if (val.is_string ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1089 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1090 std::string s = val.string_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1091
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1092 if (! s.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1093 {
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1094 std::string match;
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1095
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1096 if (radio_val.contains (s, match))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1097 {
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1098 if (current_type != radio_t || match != current_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1099 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1100 if (s.length () != match.length ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1101 warning_with_id ("Octave:abbreviated-property-match",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1102 "%s: allowing %s to match %s value %s",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1103 "set", s.c_str (), get_name ().c_str (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1104 match.c_str ());
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1105 current_val = match;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1106 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1107 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1108 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1109 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1110 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1111 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1112 color_values col (s);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1113 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1114 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1115 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1116 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1117 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1118 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1119 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1120 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1121 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1122 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1123 error ("invalid value for color property \"%s\" (value = %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1124 get_name ().c_str (), s.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1125 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1126 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1127 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1128 error ("invalid value for color property \"%s\"",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1129 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1130 }
9311
868fbeb2e365 allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents: 9238
diff changeset
1131 else if (val.is_numeric_type ())
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1132 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1133 Matrix m = val.matrix_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1134
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1135 if (m.numel () == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1136 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1137 color_values col (m(0), m(1), m(2));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1138 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1139 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1140 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1141 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1142 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1143 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1144 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1145 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1146 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1147 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1148 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1149 error ("invalid value for color property \"%s\"",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1150 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1151 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1152 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1153 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1154 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1155
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1156 return false;
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1157 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1158
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1159 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1160 double_radio_property::do_set (const octave_value& val)
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1161 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1162 if (val.is_string ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1163 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1164 std::string s = val.string_value ();
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1165 std::string match;
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1166
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1167 if (! s.empty () && radio_val.contains (s, match))
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1168 {
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1169 if (current_type != radio_t || match != current_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1170 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1171 if (s.length () != match.length ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1172 warning_with_id ("Octave:abbreviated-property-match",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1173 "%s: allowing %s to match %s value %s",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1174 "set", s.c_str (), get_name ().c_str (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1175 match.c_str ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1176 current_val = match;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1177 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1178 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1179 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1180 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1181 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1182 error ("invalid value for double_radio property \"%s\"",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1183 get_name ().c_str ());
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1184 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1185 else if (val.is_scalar_type () && val.is_real_type ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1186 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1187 double new_dval = val.double_value ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1188
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1189 if (current_type != double_t || new_dval != dval)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1190 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1191 dval = new_dval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1192 current_type = double_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1193 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1194 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1195 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1196 else
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1197 error ("invalid value for double_radio property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1198 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1199
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1200 return false;
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1201 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1202
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1203 bool
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1204 array_property::validate (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1205 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1206 bool xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1207
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1208 // check value type
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1209 if (type_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1210 {
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1211 if (type_constraints.find (v.class_name ()) != type_constraints.end ())
15069
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1212 xok = true;
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1213
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1214 // check if complex is allowed (it's also of class "double", so
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1215 // checking that alone is not enough to ensure real type)
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1216 if (type_constraints.find ("real") != type_constraints.end ()
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1217 && v.is_complex_type ())
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1218 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1219 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1220 else
9181
86ae7e50dc5d graphics.cc (array_property::validate): require value to be numeric, not necessarily double
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
1221 xok = v.is_numeric_type ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1222
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1223 if (xok)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1224 {
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1225 if (size_constraints.size () == 0)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1226 return true;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1227
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1228 dim_vector vdims = v.dims ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1229 int vlen = vdims.length ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1230
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1231 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1232
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1233 // check dimensional size constraints until a match is found
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1234 for (std::list<dim_vector>::const_iterator it = size_constraints.begin ();
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1235 ! xok && it != size_constraints.end (); ++it)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1236 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1237 dim_vector itdims = (*it);
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1238
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1239 if (itdims.length () == vlen)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1240 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1241 xok = true;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1242
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1243 for (int i = 0; xok && i < vlen; i++)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1244 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1245 if (itdims(i) > 0)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1246 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1247 if (itdims(i) != vdims(i))
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1248 xok = false;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1249 }
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1250 else if (v.is_empty ())
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1251 break;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1252 }
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1253 }
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1254 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1255 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1256
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1257 return xok;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1258 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1259
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1260 bool
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1261 array_property::is_equal (const octave_value& v) const
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1262 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1263 if (data.type_name () == v.type_name ())
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1264 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1265 if (data.dims () == v.dims ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1266 {
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1267
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1268 #define CHECK_ARRAY_EQUAL(T,F,A) \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1269 { \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1270 if (data.numel () == 1) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1271 return data.F ## scalar_value () == \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1272 v.F ## scalar_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1273 else \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1274 { \
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1275 /* Keep copy of array_value to allow sparse/bool arrays */ \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1276 /* that are converted, to not be deallocated early */ \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1277 const A m1 = data.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1278 const T* d1 = m1.data (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1279 const A m2 = v.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1280 const T* d2 = m2.data ();\
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1281 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1282 bool flag = true; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1283 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1284 for (int i = 0; flag && i < data.numel (); i++) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1285 if (d1[i] != d2[i]) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1286 flag = false; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1287 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1288 return flag; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1289 } \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1290 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1291
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
1292 if (data.is_double_type () || data.is_bool_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1293 CHECK_ARRAY_EQUAL (double, , NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1294 else if (data.is_single_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1295 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1296 else if (data.is_int8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1297 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1298 else if (data.is_int16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1299 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1300 else if (data.is_int32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1301 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1302 else if (data.is_int64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1303 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1304 else if (data.is_uint8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1305 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1306 else if (data.is_uint16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1307 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1308 else if (data.is_uint32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1309 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1310 else if (data.is_uint64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1311 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1312 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1313 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1314
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1315 return false;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1316 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1317
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1318 void
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1319 array_property::get_data_limits (void)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1320 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1321 xmin = xminp = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1322 xmax = xmaxp = -octave_Inf;
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1323
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1324 if (! data.is_empty ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1325 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1326 if (data.is_integer_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1327 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1328 if (data.is_int8_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1329 get_array_limits (data.int8_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1330 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1331 else if (data.is_uint8_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1332 get_array_limits (data.uint8_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1333 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1334 else if (data.is_int16_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1335 get_array_limits (data.int16_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1336 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1337 else if (data.is_uint16_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1338 get_array_limits (data.uint16_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1339 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1340 else if (data.is_int32_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1341 get_array_limits (data.int32_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1342 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1343 else if (data.is_uint32_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1344 get_array_limits (data.uint32_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1345 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1346 else if (data.is_int64_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1347 get_array_limits (data.int64_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1348 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1349 else if (data.is_uint64_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1350 get_array_limits (data.uint64_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1351 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1352 }
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1353 else
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1354 get_array_limits (data.array_value (), xmin, xmax, xminp, xmaxp);
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1355 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1356 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1357
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1358 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1359 handle_property::do_set (const octave_value& v)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1360 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1361 double dv = v.double_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1362
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1363 if (! error_state)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1364 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1365 graphics_handle gh = gh_manager::lookup (dv);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1366
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1367 if (xisnan (gh.value ()) || gh.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1368 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1369 if (current_val != gh)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1370 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1371 current_val = gh;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1372 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1373 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1374 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1375 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1376 error ("set: invalid graphics handle (= %g) for property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1377 dv, get_name ().c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1378 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1379 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1380 error ("set: invalid graphics handle for property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1381 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1382
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1383 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1384 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1385
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1386 Matrix
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1387 children_property::do_get_children (bool return_hidden) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1388 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1389 Matrix retval (children_list.size (), 1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1390 octave_idx_type k = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1391
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1392 graphics_object go = gh_manager::get_object (0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1393
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1394 root_figure::properties& props =
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1395 dynamic_cast<root_figure::properties&> (go.get_properties ());
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1396
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1397 if (! props.is_showhiddenhandles ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1398 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1399 for (const_children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1400 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1401 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1402 graphics_handle kid = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1403
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1404 if (gh_manager::is_handle_visible (kid))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1405 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1406 if (! return_hidden)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1407 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1408 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1409 else if (return_hidden)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1410 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1411 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1412
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1413 retval.resize (k, 1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1414 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1415 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1416 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1417 for (const_children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1418 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1419 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1420 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1421
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1422 return retval;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1423 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1424
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1425 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1426 children_property::do_delete_children (bool clear)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1427 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1428 for (children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1429 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1430 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1431 graphics_object go = gh_manager::get_object (*p);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1432
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1433 if (go.valid_object ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1434 gh_manager::free (*p);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1435
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1436 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1437
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1438 if (clear)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1439 children_list.clear ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1440 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1441
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1442 bool
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1443 callback_property::validate (const octave_value& v) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1444 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1445 // case 1: function handle
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1446 // case 2: cell array with first element being a function handle
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1447 // case 3: string corresponding to known function name
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1448 // case 4: evaluatable string
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1449 // case 5: empty matrix
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1450
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1451 if (v.is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1452 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1453 else if (v.is_string ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1454 // complete validation will be done at execution-time
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1455 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1456 else if (v.is_cell () && v.length () > 0
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
1457 && (v.rows () == 1 || v.columns () == 1)
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1458 && v.cell_value ()(0).is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1459 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1460 else if (v.is_empty ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1461 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1462
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1463 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1464 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1465
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1466 // If TRUE, we are executing any callback function, or the functions it
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1467 // calls. Used to determine handle visibility inside callback
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1468 // functions.
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1469 static bool executing_callback = false;
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1470
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1471 void
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1472 callback_property::execute (const octave_value& data) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1473 {
13323
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1474 unwind_protect frame;
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1475
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1476 // We are executing the callback function associated with this
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1477 // callback property. When set to true, we avoid recursive calls to
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1478 // callback routines.
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1479 frame.protect_var (executing);
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1480
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1481 // We are executing a callback function, so allow handles that have
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1482 // their handlevisibility property set to "callback" to be visible.
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1483 frame.protect_var (executing_callback);
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1484
13323
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1485 if (! executing)
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1486 {
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1487 executing = true;
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1488 executing_callback = true;
13323
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1489
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1490 if (callback.is_defined () && ! callback.is_empty ())
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1491 gh_manager::execute_callback (get_parent (), callback, data);
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1492 }
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1493 }
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1494
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1495 // Used to cache dummy graphics objects from which dynamic
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1496 // properties can be cloned.
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1497 static std::map<caseless_str, graphics_object> dprop_obj_map;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1498
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1499 property
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1500 property::create (const std::string& name, const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1501 const caseless_str& type, const octave_value_list& args)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1502 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1503 property retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1504
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1505 if (type.compare ("string"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1506 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1507 std::string val = (args.length () > 0 ? args(0).string_value () : "");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1508
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1509 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1510 retval = property (new string_property (name, h, val));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1511 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1512 else if (type.compare ("any"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1513 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1514 octave_value val = args.length () > 0 ? args(0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1515 : octave_value (Matrix ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1516
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1517 retval = property (new any_property (name, h, val));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1518 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1519 else if (type.compare ("radio"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1520 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1521 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1522 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1523 std::string vals = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1524
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1525 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1526 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1527 retval = property (new radio_property (name, h, vals));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1528
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1529 if (args.length () > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1530 retval.set (args(1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1531 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1532 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1533 error ("addproperty: invalid argument for radio property, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1534 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1535 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1536 error ("addproperty: missing possible values for radio property");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1537 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1538 else if (type.compare ("double"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1539 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1540 double d = (args.length () > 0 ? args(0).double_value () : 0);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1541
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1542 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1543 retval = property (new double_property (name, h, d));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1544 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1545 else if (type.compare ("handle"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1546 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1547 double hh = (args.length () > 0 ? args(0).double_value () : octave_NaN);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1548
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1549 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1550 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1551 graphics_handle gh (hh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1552
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1553 retval = property (new handle_property (name, h, gh));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1554 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1555 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1556 else if (type.compare ("boolean"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1557 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1558 retval = property (new bool_property (name, h, false));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1559
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1560 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1561 retval.set (args(0));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1562 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1563 else if (type.compare ("data"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1564 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1565 retval = property (new array_property (name, h, Matrix ()));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1566
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1567 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1568 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1569 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1570
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1571 // FIXME: additional argument could define constraints,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1572 // but is this really useful?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1573 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1574 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1575 else if (type.compare ("color"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1576 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1577 color_values cv (0, 0, 0);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1578 radio_values rv;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1579
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1580 if (args.length () > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1581 rv = radio_values (args(1).string_value ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1582
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1583 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1584 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1585 retval = property (new color_property (name, h, cv, rv));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1586
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1587 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1588 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1589 if (args.length () > 0 && ! args(0).is_empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1590 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1591 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1592 retval.set (rv.default_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1593 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1594 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1595 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1596 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1597 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1598 caseless_str go_name, go_rest;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1599
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1600 if (lookup_object_name (type, go_name, go_rest))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1601 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1602 graphics_object go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1603
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1604 std::map<caseless_str, graphics_object>::const_iterator it =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1605 dprop_obj_map.find (go_name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1606
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1607 if (it == dprop_obj_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1608 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1609 base_graphics_object *bgo =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1610 make_graphics_object_from_type (go_name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1611
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1612 if (bgo)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1613 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1614 go = graphics_object (bgo);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1615
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1616 dprop_obj_map[go_name] = go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1617 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1618 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1619 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1620 go = it->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1621
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1622 if (go.valid_object ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1623 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1624 property prop = go.get_properties ().get_property (go_rest);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1625
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1626 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1627 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1628 retval = prop.clone ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1629
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1630 retval.set_parent (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1631 retval.set_name (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1632
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1633 if (args.length () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1634 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1635 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1636 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1637 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1638 error ("addproperty: invalid object type (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1639 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1640 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1641 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1642 error ("addproperty: unsupported type for dynamic property (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1643 type.c_str ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1644 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1645
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1646 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1647 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1648
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1649 static void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1650 finalize_r (const graphics_handle& h)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1651 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1652 graphics_object go = gh_manager::get_object (h);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1653
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1654 if (go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1655 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1656 Matrix children = go.get_properties ().get_all_children ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1657
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1658 for (int k = 0; k < children.numel (); k++)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1659 finalize_r (children(k));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1660
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1661 go.finalize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1662 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1663 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1664
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1665 static void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1666 initialize_r (const graphics_handle& h)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1667 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1668 graphics_object go = gh_manager::get_object (h);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1669
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1670 if (go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1671 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1672 Matrix children = go.get_properties ().get_all_children ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1673
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1674 go.initialize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1675
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1676 for (int k = 0; k < children.numel (); k++)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1677 initialize_r (children(k));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1678 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1679 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1680
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1681 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1682 figure::properties::set_toolkit (const graphics_toolkit& b)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1683 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1684 if (toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1685 finalize_r (get___myhandle__ ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1686
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1687 toolkit = b;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1688 __graphics_toolkit__ = b.get_name ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1689 __plot_stream__ = Matrix ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1690
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1691 if (toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1692 initialize_r (get___myhandle__ ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1693
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1694 mark_modified ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1695 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1696
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1697 // ---------------------------------------------------------------------
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1698
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1699 void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1700 property_list::set (const caseless_str& name, const octave_value& val)
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1701 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1702 size_t offset = 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1703
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1704 size_t len = name.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1705
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1706 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1707 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1708 caseless_str pfx = name.substr (0, 4);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1709
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1710 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1711 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1712 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1713 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1714 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1715 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1716
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1717 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1718 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1719 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1720 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1721 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1722
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1723 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1724 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1725 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1726 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1727 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1728
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1729 if (pfx.compare ("surface") || pfx.compare ("hggroup")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1730 || pfx.compare ("uipanel"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1731 offset = 7;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1732 else if (len > 9)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1733 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1734 pfx = name.substr (0, 9);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1735
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1736 if (pfx.compare ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1737 || pfx.compare ("uitoolbar"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1738 offset = 9;
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1739 else if (len > 10)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1740 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1741 pfx = name.substr (0, 10);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1742
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1743 if (pfx.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1744 offset = 10;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1745 else if (len > 12)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1746 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1747 pfx = name.substr (0, 12);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1748
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1749 if (pfx.compare ("uitoogletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1750 offset = 12;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1751 else if (len > 13)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1752 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1753 pfx = name.substr (0, 13);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1754
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1755 if (pfx.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1756 offset = 13;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1757 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1758 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1759 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1760 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1761 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1762 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1763 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1764
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1765 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1766 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1767 // FIXME: should we validate property names and values here?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1768
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1769 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1770
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1771 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1772 std::transform (pname.begin (), pname.end (), pname.begin (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1773 tolower);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1774
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1775 bool has_property = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1776 if (pfx == "axes")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1777 has_property = axes::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1778 else if (pfx == "line")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1779 has_property = line::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1780 else if (pfx == "text")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1781 has_property = text::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1782 else if (pfx == "image")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1783 has_property = image::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1784 else if (pfx == "patch")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1785 has_property = patch::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1786 else if (pfx == "figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1787 has_property = figure::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1788 else if (pfx == "surface")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1789 has_property = surface::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1790 else if (pfx == "hggroup")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1791 has_property = hggroup::properties::has_core_property (pname);
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents: 11259
diff changeset
1792 else if (pfx == "uimenu")
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1793 has_property = uimenu::properties::has_core_property (pname);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1794 else if (pfx == "uicontrol")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1795 has_property = uicontrol::properties::has_core_property (pname);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1796 else if (pfx == "uipanel")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1797 has_property = uipanel::properties::has_core_property (pname);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1798 else if (pfx == "uicontextmenu")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1799 has_property = uicontextmenu::properties::has_core_property (pname);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1800 else if (pfx == "uitoolbar")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1801 has_property = uitoolbar::properties::has_core_property (pname);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1802 else if (pfx == "uipushtool")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1803 has_property = uipushtool::properties::has_core_property (pname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1804
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1805 if (has_property)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1806 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1807 bool remove = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1808 if (val.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1809 {
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
1810 std::string tval = val.string_value ();
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
1811
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
1812 remove = (tval.compare ("remove") == 0);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1813 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1814
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1815 pval_map_type& pval_map = plist_map[pfx];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1816
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1817 if (remove)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1818 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1819 pval_map_iterator p = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1820
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1821 if (p != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1822 pval_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1823 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1824 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1825 pval_map[pname] = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1826 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1827 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
1828 error ("invalid %s property '%s'", pfx.c_str (), pname.c_str ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1829 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1830 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1831
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
1832 if (! error_state && offset == 0)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1833 error ("invalid default property specification");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1834 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1835
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1836 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1837 property_list::lookup (const caseless_str& name) const
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1838 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1839 octave_value retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1840
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1841 size_t offset = 0;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1842
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1843 size_t len = name.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1844
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1845 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1846 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1847 caseless_str pfx = name.substr (0, 4);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1848
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1849 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1850 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1851 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1852 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1853 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1854 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1855
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1856 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1857 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1858 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1859 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1860 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1861
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1862 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1863 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1864 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1865 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1866 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1867
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1868 if (pfx.compare ("surface") || pfx.compare ("hggroup")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1869 || pfx.compare ("uipanel"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1870 offset = 7;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1871 else if (len > 9)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1872 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1873 pfx = name.substr (0, 9);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1874
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1875 if (pfx.compare ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1876 || pfx.compare ("uitoolbar"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1877 offset = 9;
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1878 else if (len > 10)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1879 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1880 pfx = name.substr (0, 10);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1881
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1882 if (pfx.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1883 offset = 10;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1884 else if (len > 12)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1885 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1886 pfx = name.substr (0, 12);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1887
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1888 if (pfx.compare ("uitoggletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1889 offset = 12;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1890 else if (len > 13)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1891 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1892 pfx = name.substr (0, 13);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1893
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1894 if (pfx.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1895 offset = 13;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1896 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1897 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1898 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1899 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1900 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1901 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1902 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1903
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1904 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1905 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1906 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1907
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1908 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1909 std::transform (pname.begin (), pname.end (), pname.begin (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1910 tolower);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1911
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1912 plist_map_const_iterator p = find (pfx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1913
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1914 if (p != end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1915 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1916 const pval_map_type& pval_map = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1917
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1918 pval_map_const_iterator q = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1919
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1920 if (q != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1921 retval = q->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1922 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1923 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1924 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1925
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1926 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1927 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1928
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1929 octave_scalar_map
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1930 property_list::as_struct (const std::string& prefix_arg) const
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1931 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1932 octave_scalar_map m;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1933
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1934 for (plist_map_const_iterator p = begin (); p != end (); p++)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1935 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1936 std::string prefix = prefix_arg + p->first;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1937
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1938 const pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1939
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1940 for (pval_map_const_iterator q = pval_map.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1941 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1942 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1943 m.assign (prefix + q->first, q->second);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1944 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1945
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1946 return m;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1947 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
1948
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1949 // Set properties given as a cs-list of name, value pairs.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1950
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1951 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1952 graphics_object::set (const octave_value_list& args)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1953 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1954 int nargin = args.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1955
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1956 if (nargin == 0)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1957 error ("graphics_object::set: Nothing to set");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1958 else if (nargin % 2 == 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1959 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1960 for (int i = 0; i < nargin; i += 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1961 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1962 caseless_str name = args(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1963
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1964 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1965 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1966 octave_value val = args(i+1);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1967
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1968 set_value_or_default (name, val);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1969
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1970 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1971 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1972 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1973 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1974 error ("set: expecting argument %d to be a property name", i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1975 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1976 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1977 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1978 error ("set: invalid number of arguments");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1979 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1980
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1981 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
1982 ## test set with name, value pairs
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1983 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
1984 %! hf = figure ("visible", "off");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
1985 %! h = plot (1:10, 10:-1:1);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
1986 %! set (h, "linewidth", 10, "marker", "x");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
1987 %! lw = get (h, "linewidth");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
1988 %! mk = get (h, "marker");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
1989 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
1990 %! assert (lw, 10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
1991 %! assert (mk, "x");
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1992 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1993
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1994 // Set properties given in two cell arrays containing names and values.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1995 void
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1996 graphics_object::set (const Array<std::string>& names,
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1997 const Cell& values, octave_idx_type row)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1998 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1999 if (names.numel () != values.columns ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2000 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2001 error ("set: number of names must match number of value columns (%d != %d)",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2002 names.numel (), values.columns ());
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2003 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2004
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2005 octave_idx_type k = names.columns ();
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2006
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2007 for (octave_idx_type column = 0; column < k; column++)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2008 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2009 caseless_str name = names(column);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2010 octave_value val = values(row, column);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2011
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2012 set_value_or_default (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2013
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2014 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2015 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2016 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2017 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2018
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2019 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2020 ## test set with cell array arguments
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2021 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2022 %! hf = figure ("visible", "off");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2023 %! h = plot (1:10, 10:-1:1);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2024 %! set (h, {"linewidth", "marker"}, {10, "x"});
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2025 %! lw = get (h, "linewidth");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2026 %! mk = get (h, "marker");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2027 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2028 %! assert (lw, 10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2029 %! assert (mk, "x");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2030
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2031 ## test set with multiple handles and cell array arguments
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2032 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2033 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2034 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2035 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2036 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2037 %! assert (get (h, "linewidth"), {10; 5});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2038 %! assert (get (h, "marker"), {"x"; "o"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2039 %! set (h, {"linewidth", "marker"}, {10, "x"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2040 %! assert (get (h, "linewidth"), {10; 10});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2041 %! assert (get (h, "marker"), {"x"; "x"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2042 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2043 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2044 %! end_unwind_protect;
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2045
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2046 %!error <set: number of graphics handles must match number of value rows>
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2047 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2048 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2049 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2050 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2051 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2052 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2053 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2054
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2055 %!error <set: number of names must match number of value columns>
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2056 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2057 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2058 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2059 %! set (h, {"linewidth"}, {10, "x"; 5, "o"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2060 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2061 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2062 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2063 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2064
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2065 // Set properties given in a struct array
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2066 void
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2067 graphics_object::set (const octave_map& m)
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2068 {
15760
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2069 for (octave_idx_type p = 0; p < m.nfields (); p++)
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2070 {
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2071 caseless_str name = m.keys ()[p];
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2072
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2073 octave_value val = octave_value (m.contents (name).elem (m.numel () - 1));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2074
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2075 set_value_or_default (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2076
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2077 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2078 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2079 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2080 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2081
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2082 /*
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2083 ## test set ticklabels for compatibility
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2084 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2085 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2086 %! set (gca (), "xticklabel", [0, 0.2, 0.4, 0.6, 0.8, 1]);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2087 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2088 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2089 %! assert (class (xticklabel), "char");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2090 %! assert (size (xticklabel), [6, 3]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2091
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2092 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2093 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2094 %! set (gca (), "xticklabel", "0|0.2|0.4|0.6|0.8|1");
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2095 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2096 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2097 %! assert (class (xticklabel), "char");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2098 %! assert (size (xticklabel), [6, 3]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2099
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2100 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2101 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2102 %! set (gca (), "xticklabel", ["0 "; "0.2"; "0.4"; "0.6"; "0.8"; "1 "]);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2103 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2104 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2105 %! assert (class (xticklabel), "char");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2106 %! assert (size (xticklabel), [6, 3]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2107
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
2108 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2109 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2110 %! set (gca (), "xticklabel", {"0", "0.2", "0.4", "0.6", "0.8", "1"});
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2111 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2112 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2113 %! assert (class (xticklabel), "cell");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2114 %! assert (size (xticklabel), [6, 1]);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2115 */
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2116
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2117 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2118 ## test set with struct arguments
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2119 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2120 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2121 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2122 %! h = plot (1:10, 10:-1:1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2123 %! set (h, struct ("linewidth", 10, "marker", "x"));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2124 %! assert (get (h, "linewidth"), 10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2125 %! assert (get (h, "marker"), "x");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2126 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2127 %! set (h, struct ("linewidth", {5, 10}));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2128 %! assert (get (h, "linewidth"), {10; 10});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2129 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2130 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2131 %! end_unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2132
15760
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2133 ## test ordering
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2134 %!test
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2135 %! markchanged = @(h, foobar, name) set (h, "userdata", [get(h,"userdata"); {name}]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2136 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2137 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2138 %! h = line ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2139 %! set (h, "userdata", {});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2140 %! addlistener (h, "color", {markchanged, "color"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2141 %! addlistener (h, "linewidth", {markchanged, "linewidth"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2142 %! ## "linewidth" first
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2143 %! props.linewidth = 2;
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2144 %! props.color = "r";
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2145 %! set (h, props);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2146 %! assert (get (h, "userdata"), fieldnames (props));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2147 %! clear props;
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2148 %! clf ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2149 %! h = line ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2150 %! set (h, "userdata", {});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2151 %! addlistener (h, "color", {markchanged, "color"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2152 %! addlistener (h, "linewidth", {markchanged, "linewidth"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2153 %! ## "color" first
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2154 %! props.color = "r";
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2155 %! props.linewidth = 2;
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2156 %! set (h, props);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2157 %! assert (get (h, "userdata"), fieldnames (props));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2158 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2159 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2160 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2161 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2162
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2163 // Set a property to a value or to its (factory) default value.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2164
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2165 void
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2166 graphics_object::set_value_or_default (const caseless_str& name,
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2167 const octave_value& val)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2168 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2169 if (val.is_string ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2170 {
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2171 std::string tval = val.string_value ();
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2172
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2173 octave_value default_val;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2174
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2175 if (tval.compare ("default") == 0)
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2176 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2177 default_val = get_default (name);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2178
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2179 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2180 return;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2181
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2182 rep->set (name, default_val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2183 }
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2184 else if (tval.compare ("factory") == 0)
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2185 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2186 default_val = get_factory_default (name);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2187
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2188 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2189 return;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2190
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2191 rep->set (name, default_val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2192 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2193 else
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2194 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2195 // Matlab specifically uses "\default" to escape string setting
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2196 if (tval.compare ("\\default") == 0)
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2197 rep->set (name, "default");
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2198 else if (tval.compare ("\\factory") == 0)
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2199 rep->set (name, "factory");
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2200 else
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2201 rep->set (name, val);
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2202 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2203 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2204 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2205 rep->set (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2206 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2207
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2208 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2209 ## test setting of default values
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2210 %!test
17237
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2211 %! old_lw = get (0, "defaultlinelinewidth");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2212 %! unwind_protect
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2213 %! hf = figure ("visible", "off");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2214 %! h = plot (1:10, 10:-1:1);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2215 %! set (0, "defaultlinelinewidth", 20);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2216 %! set (h, "linewidth", "default");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2217 %! assert (get (h, "linewidth"), 20);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2218 %! set (h, "linewidth", "factory");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2219 %! assert (get (h, "linewidth"), 0.5);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2220 %! unwind_protect_cleanup
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2221 %! close (hf);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2222 %! set (0, "defaultlinelinewidth", old_lw);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2223 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2224 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2225
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2226 static double
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2227 make_handle_fraction (void)
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2228 {
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2229 static double maxrand = RAND_MAX + 2.0;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2230
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2231 return (rand () + 1.0) / maxrand;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2232 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2233
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2234 graphics_handle
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2235 gh_manager::do_get_handle (bool integer_figure_handle)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2236 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2237 graphics_handle retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2238
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
2239 if (integer_figure_handle)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2240 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2241 // Figure handles are positive integers corresponding to the
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2242 // figure number.
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2243
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2244 // We always want the lowest unused figure number.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2245
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2246 retval = 1;
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
2247
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2248 while (handle_map.find (retval) != handle_map.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2249 retval++;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2250 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2251 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2252 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2253 // Other graphics handles are negative integers plus some random
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2254 // fractional part. To avoid running out of integers, we
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2255 // recycle the integer part but tack on a new random part each
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2256 // time.
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2257
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2258 free_list_iterator p = handle_free_list.begin ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2259
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2260 if (p != handle_free_list.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2261 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2262 retval = *p;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2263 handle_free_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2264 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2265 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2266 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2267 retval = graphics_handle (next_handle);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2268
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
2269 next_handle = std::ceil (next_handle) - 1.0 - make_handle_fraction ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2270 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2271 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2272
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2273 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2274 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2275
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2276 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2277 gh_manager::do_free (const graphics_handle& h)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2278 {
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2279 if (h.ok ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2280 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2281 if (h.value () != 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2282 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2283 iterator p = handle_map.find (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2284
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2285 if (p != handle_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2286 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2287 base_properties& bp = p->second.get_properties ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2288
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2289 bp.set_beingdeleted (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2290
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2291 bp.delete_children ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2292
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2293 octave_value val = bp.get_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2294
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2295 bp.execute_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2296
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2297 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2298 p->second.finalize ();
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2299
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2300 // Note: this will be valid only for first explicitly
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2301 // deleted object. All its children will then have an
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2302 // unknown graphics toolkit.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2303
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2304 // Graphics handles for non-figure objects are negative
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2305 // integers plus some random fractional part. To avoid
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2306 // running out of integers, we recycle the integer part
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2307 // but tack on a new random part each time.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2308
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2309 handle_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2310
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2311 if (h.value () < 0)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2312 handle_free_list.insert
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2313 (std::ceil (h.value ()) - make_handle_fraction ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2314 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2315 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2316 error ("graphics_handle::free: invalid object %g", h.value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2317 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2318 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2319 error ("graphics_handle::free: can't delete root figure");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2320 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2321 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2322
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2323 void
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2324 gh_manager::do_renumber_figure (const graphics_handle& old_gh,
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2325 const graphics_handle& new_gh)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2326 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2327 iterator p = handle_map.find (old_gh);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2328
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2329 if (p != handle_map.end ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2330 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2331 graphics_object go = p->second;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2332
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2333 handle_map.erase (p);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2334
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2335 handle_map[new_gh] = go;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2336
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2337 if (old_gh.value () < 0)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2338 handle_free_list.insert (std::ceil (old_gh.value ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2339 - make_handle_fraction ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2340 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2341 else
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2342 error ("graphics_handle::free: invalid object %g", old_gh.value ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2343
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2344 for (figure_list_iterator q = figure_list.begin ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2345 q != figure_list.end (); q++)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2346 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2347 if (*q == old_gh)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2348 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2349 *q = new_gh;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2350 break;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2351 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2352 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2353 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2354
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2355 gh_manager *gh_manager::instance = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2356
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2357 static void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2358 xset (const graphics_handle& h, const caseless_str& name,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2359 const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2360 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2361 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2362 obj.set (name, val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2363 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2364
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2365 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2366 xset (const graphics_handle& h, const octave_value_list& args)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2367 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2368 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2369 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2370 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2371 obj.set (args);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2372 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2373 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2374
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2375 static octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2376 xget (const graphics_handle& h, const caseless_str& name)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2377 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2378 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2379 return obj.get (name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2380 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2381
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2382 static graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2383 reparent (const octave_value& ov, const std::string& who,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2384 const std::string& property, const graphics_handle& new_parent,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2385 bool adopt = true)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2386 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2387 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2388
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2389 double val = ov.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2390
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2391 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2392 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2393 h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2394
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2395 if (h.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2396 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2397 graphics_object obj = gh_manager::get_object (h);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2398
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2399 graphics_handle parent_h = obj.get_parent ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2400
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2401 graphics_object parent_obj = gh_manager::get_object (parent_h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2402
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2403 parent_obj.remove_child (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2404
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2405 if (adopt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2406 obj.set ("parent", new_parent.value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2407 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2408 obj.reparent (new_parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2409 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2410 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2411 error ("%s: invalid graphics handle (= %g) for %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2412 who.c_str (), val, property.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2413 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2414 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2415 error ("%s: expecting %s to be a graphics handle",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2416 who.c_str (), property.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2417
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2418 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2419 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2420
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2421 // This function is NOT equivalent to the scripting language function gcf.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2422 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2423 gcf (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2424 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2425 octave_value val = xget (0, "currentfigure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2426
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2427 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2428 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2429
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2430 // This function is NOT equivalent to the scripting language function gca.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2431 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2432 gca (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2433 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2434 octave_value val = xget (gcf (), "currentaxes");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2435
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2436 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2437 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2438
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2439 static void
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2440 delete_graphics_object (const graphics_handle& h)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2441 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2442 if (h.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2443 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2444 graphics_object obj = gh_manager::get_object (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2445
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2446 // Don't do recursive deleting, due to callbacks
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2447 if (! obj.get_properties ().is_beingdeleted ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2448 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2449 graphics_handle parent_h = obj.get_parent ();
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2450
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2451 graphics_object parent_obj =
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2452 gh_manager::get_object (parent_h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2453
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2454 // NOTE: free the handle before removing it from its
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2455 // parent's children, such that the object's
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2456 // state is correct when the deletefcn callback
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2457 // is executed
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2458
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2459 gh_manager::free (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2460
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2461 // A callback function might have already deleted
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2462 // the parent
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2463 if (parent_obj.valid_object ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2464 parent_obj.remove_child (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2465
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2466 Vdrawnow_requested = true;
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2467 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2468 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2469 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2470
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2471 static void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2472 delete_graphics_object (double val)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2473 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2474 delete_graphics_object (gh_manager::lookup (val));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2475 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2476
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2477 static void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2478 delete_graphics_objects (const NDArray vals)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2479 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2480 for (octave_idx_type i = 0; i < vals.numel (); i++)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2481 delete_graphics_object (vals.elem (i));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2482 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2483
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2484 static void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2485 close_figure (const graphics_handle& handle)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2486 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2487 octave_value closerequestfcn = xget (handle, "closerequestfcn");
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2488
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2489 OCTAVE_SAFE_CALL (gh_manager::execute_callback, (handle, closerequestfcn));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2490 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2491
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2492 static void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2493 force_close_figure (const graphics_handle& handle)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2494 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2495 // Remove the deletefcn and closerequestfcn callbacks and delete the
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2496 // object directly.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2497
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2498 xset (handle, "deletefcn", Matrix ());
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2499 xset (handle, "closerequestfcn", Matrix ());
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2500
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2501 delete_graphics_object (handle);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2502 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2503
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2504 void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2505 gh_manager::do_close_all_figures (void)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2506 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2507 // FIXME: should we process or discard pending events?
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2508
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2509 event_queue.clear ();
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2510
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2511 // Don't use figure_list_iterator because we'll be removing elements
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2512 // from the list elsewhere.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2513
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2514 Matrix hlist = do_figure_handle_list (true);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2515
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2516 for (octave_idx_type i = 0; i < hlist.numel (); i++)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2517 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2518 graphics_handle h = gh_manager::lookup (hlist(i));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2519
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2520 if (h.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2521 close_figure (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2522 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2523
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2524 // They should all be closed now. If not, force them to close.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2525
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2526 hlist = do_figure_handle_list (true);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2527
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2528 for (octave_idx_type i = 0; i < hlist.numel (); i++)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2529 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2530 graphics_handle h = gh_manager::lookup (hlist(i));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2531
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2532 if (h.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2533 force_close_figure (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2534 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2535
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2536 // None left now, right?
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2537
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2538 hlist = do_figure_handle_list (true);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2539
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2540 assert (hlist.numel () == 0);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2541
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2542 // Clear all callback objects from our list.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2543
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2544 callback_objects.clear ();
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2545 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2546
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2547 static void
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2548 adopt (const graphics_handle& p, const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2549 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2550 graphics_object parent_obj = gh_manager::get_object (p);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2551 parent_obj.adopt (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2552 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2553
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2554 static bool
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2555 is_handle (const graphics_handle& h)
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2556 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2557 return h.ok ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2558 }
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2559
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2560 static bool
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2561 is_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2562 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2563 graphics_handle h = gh_manager::lookup (val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2564
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2565 return h.ok ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2566 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2567
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2568 static octave_value
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2569 is_handle (const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2570 {
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2571 octave_value retval = false;
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2572
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2573 if (val.is_real_scalar () && is_handle (val.double_value ()))
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2574 retval = true;
12587
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2575 else if (val.is_numeric_type () && val.is_real_type ())
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2576 {
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2577 const NDArray handles = val.array_value ();
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2578
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2579 if (! error_state)
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2580 {
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2581 boolNDArray result (handles.dims ());
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2582
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2583 for (octave_idx_type i = 0; i < handles.numel (); i++)
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2584 result.xelem (i) = is_handle (handles (i));
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2585
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2586 retval = result;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2587 }
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2588 }
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2589
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2590 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2591 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2592
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2593 static bool
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2594 is_figure (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2595 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2596 graphics_object obj = gh_manager::get_object (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2597
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2598 return obj && obj.isa ("figure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2599 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2600
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2601 static void
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2602 xcreatefcn (const graphics_handle& h)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2603 {
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2604 graphics_object obj = gh_manager::get_object (h);
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2605 obj.get_properties ().execute_createfcn ();
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2606 }
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2607
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2608 static void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2609 xinitialize (const graphics_handle& h)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2610 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2611 graphics_object go = gh_manager::get_object (h);
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
2612
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2613 if (go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2614 go.initialize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2615 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2616
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2617 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2618
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2619 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2620 base_graphics_toolkit::update (const graphics_handle& h, int id)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2621 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2622 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2623
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2624 update (go, id);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2625 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2626
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2627 bool
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2628 base_graphics_toolkit::initialize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2629 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2630 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2631
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2632 return initialize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2633 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2634
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2635 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2636 base_graphics_toolkit::finalize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2637 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2638 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2639
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2640 finalize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2641 }
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2642
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2643 // ---------------------------------------------------------------------
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2644
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2645 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2646 base_properties::set_from_list (base_graphics_object& obj,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2647 property_list& defaults)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2648 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2649 std::string go_name = graphics_object_name ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2650
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2651 property_list::plist_map_const_iterator p = defaults.find (go_name);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2652
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2653 if (p != defaults.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2654 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2655 const property_list::pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2656
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2657 for (property_list::pval_map_const_iterator q = pval_map.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2658 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2659 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2660 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2661 std::string pname = q->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2662
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2663 obj.set (pname, q->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2664
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2665 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2666 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2667 error ("error setting default property %s", pname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2668 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2669 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2670 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2671 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2672 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2673
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2674 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2675 base_properties::get_dynamic (const caseless_str& name) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2676 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2677 octave_value retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2678
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2679 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2680 all_props.find (name);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2681
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2682 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2683 retval = it->second.get ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2684 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2685 error ("get: unknown property \"%s\"", name.c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2686
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2687 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2688 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2689
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2690 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2691 base_properties::get_dynamic (bool all) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2692 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2693 octave_scalar_map m;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2694
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2695 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2696 it = all_props.begin (); it != all_props.end (); ++it)
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2697 if (all || ! it->second.is_hidden ())
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2698 m.assign (it->second.get_name (), it->second.get ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2699
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2700 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2701 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2702
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2703 std::set<std::string>
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2704 base_properties::dynamic_property_names (void) const
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2705 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2706 return dynamic_properties;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2707 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2708
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2709 bool
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2710 base_properties::has_dynamic_property (const std::string& pname)
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2711 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2712 const std::set<std::string>& dynprops = dynamic_property_names ();
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2713
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2714 if (dynprops.find (pname) != dynprops.end ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2715 return true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2716 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2717 return all_props.find (pname) != all_props.end ();
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2718 }
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2719
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2720 void
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2721 base_properties::set_dynamic (const caseless_str& pname,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2722 const octave_value& val)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2723 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2724 std::map<caseless_str, property, cmp_caseless_str>::iterator it =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2725 all_props.find (pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2726
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2727 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2728 it->second.set (val);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2729 else
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2730 error ("set: unknown property \"%s\"", pname.c_str ());
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2731
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2732 if (! error_state)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2733 {
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2734 dynamic_properties.insert (pname);
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2735
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2736 mark_modified ();
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2737 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2738 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2739
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2740 property
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2741 base_properties::get_property_dynamic (const caseless_str& name)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2742 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2743 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2744 all_props.find (name);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2745
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2746 if (it == all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2747 {
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2748 error ("get_property: unknown property \"%s\"", name.c_str ());
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2749 return property ();
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2750 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2751 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2752 return it->second;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2753 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2754
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2755 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2756 base_properties::set_parent (const octave_value& val)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2757 {
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2758 double hnp = val.double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2759
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2760 graphics_handle new_parent = octave_NaN;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2761
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2762 if (! error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2763 {
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2764 if (hnp == __myhandle__)
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2765 error ("set: can not set object parent to be object itself");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2766 else
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2767 {
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2768 new_parent = gh_manager::lookup (hnp);
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2769
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2770 if (new_parent.ok ())
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2771 {
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2772 // Remove child from current parent
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2773 graphics_object old_parent_obj;
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2774 old_parent_obj = gh_manager::get_object (get_parent ());
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2775 old_parent_obj.remove_child (__myhandle__);
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2776
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2777 // Check new parent's parent is not this child to avoid recursion
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2778 graphics_object new_parent_obj;
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2779 new_parent_obj = gh_manager::get_object (new_parent);
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2780 if (new_parent_obj.get_parent () == __myhandle__)
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2781 {
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2782 // new parent's parent gets child's original parent
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2783 new_parent_obj.get_properties ().set_parent (get_parent ().as_octave_value ());
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2784 }
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2785
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2786 // Set parent property to new_parent and do adoption
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2787 parent = new_parent.as_octave_value ();
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2788 ::adopt (parent.handle_value (), __myhandle__);
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2789 }
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2790 else
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2791 error ("set: invalid graphics handle (= %g) for parent", hnp);
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2792 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2793 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2794 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2795 error ("set: expecting parent to be a graphics handle");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2796 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
2797
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2798 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2799 base_properties::mark_modified (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2800 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2801 __modified__ = "on";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2802 graphics_object parent_obj = gh_manager::get_object (get_parent ());
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2803 if (parent_obj)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2804 parent_obj.mark_modified ();
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2805 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2806
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2807 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2808 base_properties::override_defaults (base_graphics_object& obj)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2809 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2810 graphics_object parent_obj = gh_manager::get_object (get_parent ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2811
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2812 if (parent_obj)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2813 parent_obj.override_defaults (obj);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2814 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2815
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2816 void
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2817 base_properties::update_axis_limits (const std::string& axis_type) const
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2818 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2819 graphics_object obj = gh_manager::get_object (__myhandle__);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2820
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2821 if (obj)
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2822 obj.update_axis_limits (axis_type);
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2823 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2824
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2825 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2826 base_properties::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2827 const graphics_handle& h) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2828 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2829 graphics_object obj = gh_manager::get_object (__myhandle__);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2830
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2831 if (obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2832 obj.update_axis_limits (axis_type, h);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2833 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2834
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
2835 bool
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
2836 base_properties::is_handle_visible (void) const
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
2837 {
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
2838 return (handlevisibility.is ("on")
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
2839 || (executing_callback && ! handlevisibility.is ("off")));
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
2840 }
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
2841
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2842 graphics_toolkit
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2843 base_properties::get_toolkit (void) const
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2844 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2845 graphics_object go = gh_manager::get_object (get_parent ());
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2846
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2847 if (go)
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2848 return go.get_toolkit ();
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2849 else
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2850 return graphics_toolkit ();
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2851 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2852
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2853 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2854 base_properties::update_boundingbox (void)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2855 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2856 Matrix kids = get_children ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2857
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2858 for (int i = 0; i < kids.numel (); i++)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2859 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2860 graphics_object go = gh_manager::get_object (kids(i));
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2861
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2862 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2863 go.get_properties ().update_boundingbox ();
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2864 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2865 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2866
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2867 void
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2868 base_properties::update_autopos (const std::string& elem_type)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2869 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2870 graphics_object parent_obj = gh_manager::get_object (get_parent ());
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2871
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2872 if (parent_obj.valid_object ())
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2873 parent_obj.get_properties ().update_autopos (elem_type);
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2874 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2875
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2876 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2877 base_properties::add_listener (const caseless_str& nm, const octave_value& v,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2878 listener_mode mode)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2879 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2880 property p = get_property (nm);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2881
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2882 if (! error_state && p.ok ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2883 p.add_listener (v, mode);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2884 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2885
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2886 void
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2887 base_properties::delete_listener (const caseless_str& nm,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2888 const octave_value& v, listener_mode mode)
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2889 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2890 property p = get_property (nm);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2891
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2892 if (! error_state && p.ok ())
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2893 p.delete_listener (v, mode);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2894 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2895
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2896 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2897
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2898 void
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2899 base_graphics_object::update_axis_limits (const std::string& axis_type)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2900 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2901 if (valid_object ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2902 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2903 graphics_object parent_obj = gh_manager::get_object (get_parent ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2904
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2905 if (parent_obj)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2906 parent_obj.update_axis_limits (axis_type);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2907 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2908 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2909 error ("base_graphics_object::update_axis_limits: invalid graphics object");
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2910 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2911
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2912 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2913 base_graphics_object::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2914 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2915 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2916 if (valid_object ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2917 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2918 graphics_object parent_obj = gh_manager::get_object (get_parent ());
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2919
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2920 if (parent_obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2921 parent_obj.update_axis_limits (axis_type, h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2922 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2923 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2924 error ("base_graphics_object::update_axis_limits: invalid graphics object");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2925 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2926
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2927 void
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2928 base_graphics_object::remove_all_listeners (void)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2929 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2930 octave_map m = get (true).map_value ();
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2931
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2932 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2933 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2934 // FIXME: there has to be a better way. I think we want to
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2935 // ask whether it is OK to delete the listener for the given
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2936 // property. How can we know in advance that it will be OK?
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2937
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2938 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2939
13849
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
2940 frame.protect_var (error_state);
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2941 frame.protect_var (discard_error_messages);
13849
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
2942 frame.protect_var (Vdebug_on_error);
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
2943 frame.protect_var (Vdebug_on_warning);
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2944
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2945 discard_error_messages = true;
13849
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
2946 Vdebug_on_error = false;
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
2947 Vdebug_on_warning = false;
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2948
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2949 property p = get_properties ().get_property (pa->first);
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2950
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2951 if (! error_state && p.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2952 p.delete_listener ();
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2953 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2954 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2955
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2956 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2957 base_graphics_object::values_as_string (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2958 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2959 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2960
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2961 if (valid_object ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2962 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2963 octave_map m = get ().map_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2964
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2965 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2966 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2967 if (pa->first != "children")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2968 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2969 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2970
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2971 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2972 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2973 retval += "\n\t" + std::string (pa->first) + ": ";
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2974 if (p.is_radio ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2975 retval += p.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2976 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2977 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2978 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2979 if (retval != "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2980 retval += "\n";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2981 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2982 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2983 error ("base_graphics_object::values_as_string: invalid graphics object");
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2984
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2985 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2986 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2987
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2988 octave_scalar_map
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2989 base_graphics_object::values_as_struct (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2990 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2991 octave_scalar_map retval;
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2992
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2993 if (valid_object ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2994 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2995 octave_scalar_map m = get ().scalar_map_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2996
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2997 for (octave_scalar_map::const_iterator pa = m.begin ();
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2998 pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2999 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3000 if (pa->first != "children")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3001 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3002 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3003
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3004 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3005 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3006 if (p.is_radio ())
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3007 retval.assign (p.get_name (), p.values_as_cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3008 else
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3009 retval.assign (p.get_name (), Cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3010 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3011 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3012 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3013 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3014 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3015 error ("base_graphics_object::values_as_struct: invalid graphics object");
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3016
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3017 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3018 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3019
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3020 graphics_object
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
3021 graphics_object::get_ancestor (const std::string& obj_type) const
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3022 {
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3023 if (valid_object ())
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3024 {
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
3025 if (isa (obj_type))
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3026 return *this;
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3027 else
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
3028 return gh_manager::get_object (get_parent ()).get_ancestor (obj_type);
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3029 }
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3030 else
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3031 return graphics_object ();
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3032 }
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3033
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3034 // ---------------------------------------------------------------------
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3035
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3036 #include "graphics-props.cc"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3037
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3038 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3039
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3040 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3041 root_figure::properties::set_currentfigure (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3042 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
3043 graphics_handle val (v);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3044
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3045 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3046 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3047
7059
8d57f66e35b8 [project @ 2007-10-24 17:16:23 by jwe]
jwe
parents: 7056
diff changeset
3048 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3049 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3050 currentfigure = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3051
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
3052 if (val.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
3053 gh_manager::push_figure (val);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3054 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3055 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3056 gripe_set_invalid ("currentfigure");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3057 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3058
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3059 void
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3060 root_figure::properties::set_callbackobject (const octave_value& v)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3061 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3062 graphics_handle val (v);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3063
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3064 if (error_state)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3065 return;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3066
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3067 if (xisnan (val.value ()))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3068 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3069 if (! cbo_stack.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3070 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3071 val = cbo_stack.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3072
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3073 cbo_stack.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3074 }
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3075
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3076 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3077 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3078 else if (is_handle (val))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3079 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3080 if (get_callbackobject ().ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3081 cbo_stack.push_front (get_callbackobject ());
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3082
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3083 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3084 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3085 else
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3086 gripe_set_invalid ("callbackobject");
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3087 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3088
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3089 void
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3090 figure::properties::set_integerhandle (const octave_value& val)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3091 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3092 if (! error_state)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3093 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3094 if (integerhandle.set (val, true))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3095 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3096 bool int_fig_handle = integerhandle.is_on ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3097
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3098 graphics_object this_go = gh_manager::get_object (__myhandle__);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3099
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3100 graphics_handle old_myhandle = __myhandle__;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3101
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3102 __myhandle__ = gh_manager::get_handle (int_fig_handle);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3103
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3104 gh_manager::renumber_figure (old_myhandle, __myhandle__);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3105
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3106 graphics_object parent_go = gh_manager::get_object (get_parent ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3107
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3108 base_properties& props = parent_go.get_properties ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3109
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3110 props.renumber_child (old_myhandle, __myhandle__);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3111
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3112 Matrix kids = get_children ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3113
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3114 for (octave_idx_type i = 0; i < kids.numel (); i++)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3115 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3116 graphics_object kid = gh_manager::get_object (kids(i));
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3117
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3118 kid.get_properties ().renumber_parent (__myhandle__);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3119 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3120
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3121 graphics_handle cf = gh_manager::current_figure ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3122
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3123 if (__myhandle__ == cf)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3124 xset (0, "currentfigure", __myhandle__.value ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3125
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3126 this_go.update (integerhandle.get_id ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3127
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3128 mark_modified ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3129 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3130 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3131 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3132
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17842
diff changeset
3133 // FIXME: This should update monitorpositions and pointerlocation, but
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3134 // as these properties are yet used, and so it doesn't matter that they
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3135 // aren't set yet.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3136 void
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3137 root_figure::properties::update_units (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3138 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3139 caseless_str xunits = get_units ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3140
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3141 Matrix ss = default_screensize ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3142
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3143 double dpi = get_screenpixelsperinch ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3144
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3145 if (xunits.compare ("inches"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3146 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3147 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3148 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3149 ss(2) /= dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3150 ss(3) /= dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3151 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3152 else if (xunits.compare ("centimeters"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3153 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3154 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3155 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3156 ss(2) *= 2.54 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3157 ss(3) *= 2.54 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3158 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3159 else if (xunits.compare ("normalized"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3160 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3161 ss = Matrix (1, 4, 1.0);
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3162 ss(0) = 0;
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3163 ss(1) = 0;
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3164 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3165 else if (xunits.compare ("points"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3166 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3167 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3168 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3169 ss(2) *= 72 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3170 ss(3) *= 72 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3171 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3172
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3173 set_screensize (ss);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3174 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3175
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3176 Matrix
14604
de72463862c4 Silence warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14498
diff changeset
3177 root_figure::properties::get_boundingbox (bool, const Matrix&) const
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3178 {
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3179 Matrix screen_size = screen_size_pixels ();
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3180 Matrix pos = Matrix (1, 4, 0);
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3181 pos(2) = screen_size(0);
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3182 pos(3) = screen_size(1);
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3183 return pos;
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3184 }
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3185
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3186 /*
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3187 %!test
17237
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3188 %! old_units = get (0, "units");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3189 %! unwind_protect
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3190 %! set (0, "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3191 %! sz = get (0, "screensize") - [1, 1, 0, 0];
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3192 %! dpi = get (0, "screenpixelsperinch");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3193 %! set (0, "units", "inches");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3194 %! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3195 %! set (0, "units", "centimeters");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3196 %! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3197 %! set (0, "units", "points");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3198 %! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3199 %! set (0, "units", "normalized");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3200 %! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3201 %! set (0, "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3202 %! assert (get (0, "screensize"), sz + [1, 1, 0, 0]);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3203 %! unwind_protect_cleanup
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3204 %! set (0, "units", old_units);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3205 %! end_unwind_protect
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3206 */
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3207
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3208 void
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3209 root_figure::properties::remove_child (const graphics_handle& gh)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3210 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3211 gh_manager::pop_figure (gh);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3212
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3213 graphics_handle cf = gh_manager::current_figure ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3214
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3215 xset (0, "currentfigure", cf.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3216
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3217 base_properties::remove_child (gh);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3218 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3219
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3220 property_list
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3221 root_figure::factory_properties = root_figure::init_factory_properties ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3222
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3223 static void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3224 reset_default_properties (property_list& default_properties)
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3225 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3226 property_list new_defaults;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3227
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3228 for (property_list::plist_map_const_iterator p = default_properties.begin ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3229 p != default_properties.end (); p++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3230 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3231 const property_list::pval_map_type pval_map = p->second;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3232 std::string prefix = p->first;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3233
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3234 for (property_list::pval_map_const_iterator q = pval_map.begin ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3235 q != pval_map.end ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3236 q++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3237 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3238 std::string s = q->first;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3239
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3240 if (prefix == "axes" && (s == "position" || s == "units"))
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3241 new_defaults.set (prefix + s, q->second);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3242 else if (prefix == "figure" && (s == "position" || s == "units"
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3243 || s == "windowstyle"
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3244 || s == "paperunits"))
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3245 new_defaults.set (prefix + s, q->second);
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3246 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3247 }
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3248
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3249 default_properties = new_defaults;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3250 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3251
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3252 void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3253 root_figure::reset_default_properties (void)
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3254 {
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3255 ::reset_default_properties (default_properties);
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3256 }
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3257
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3258 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3259
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3260 void
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3261 figure::properties::set_currentaxes (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3262 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
3263 graphics_handle val (v);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3264
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3265 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3266 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3267
7070
7593f8e83a2e [project @ 2007-10-25 20:41:16 by jwe]
jwe
parents: 7059
diff changeset
3268 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3269 currentaxes = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3270 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3271 gripe_set_invalid ("currentaxes");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3272 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3273
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3274 void
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3275 figure::properties::remove_child (const graphics_handle& gh)
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3276 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3277 base_properties::remove_child (gh);
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3278
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3279 if (gh == currentaxes.handle_value ())
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3280 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3281 graphics_handle new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3282
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3283 Matrix kids = get_children ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3284
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3285 for (octave_idx_type i = 0; i < kids.numel (); i++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3286 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3287 graphics_handle kid = kids(i);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3288
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3289 graphics_object go = gh_manager::get_object (kid);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3290
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3291 if (go.isa ("axes"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3292 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3293 new_currentaxes = kid;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3294 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3295 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3296 }
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3297
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3298 currentaxes = new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3299 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3300 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3301
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3302 void
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3303 figure::properties::set_visible (const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3304 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3305 std::string s = val.string_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3306
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3307 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3308 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3309 if (s == "on")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3310 xset (0, "currentfigure", __myhandle__.value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3311
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3312 visible = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3313 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3314 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3315
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3316 Matrix
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3317 figure::properties::get_boundingbox (bool internal, const Matrix&) const
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3318 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3319 Matrix screen_size = screen_size_pixels ();
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3320 Matrix pos = (internal ?
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3321 get_position ().matrix_value () :
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3322 get_outerposition ().matrix_value ());
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3323
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3324 pos = convert_position (pos, get_units (), "pixels", screen_size);
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3325
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3326 pos(0)--;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3327 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3328 pos(1) = screen_size(1) - pos(1) - pos(3);
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3329
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3330 return pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3331 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3332
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3333 void
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3334 figure::properties::set_boundingbox (const Matrix& bb, bool internal,
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3335 bool do_notify_toolkit)
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3336 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3337 Matrix screen_size = screen_size_pixels ();
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3338 Matrix pos = bb;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3339
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3340 pos(1) = screen_size(1) - pos(1) - pos(3);
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3341 pos(1)++;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3342 pos(0)++;
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
3343 pos = convert_position (pos, "pixels", get_units (), screen_size);
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3344
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3345 if (internal)
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3346 set_position (pos, do_notify_toolkit);
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3347 else
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3348 set_outerposition (pos, do_notify_toolkit);
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3349 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3350
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3351 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3352 figure::properties::map_from_boundingbox (double x, double y) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3353 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3354 Matrix bb = get_boundingbox (true);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3355 Matrix pos (1, 2, 0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3356
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3357 pos(0) = x;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3358 pos(1) = y;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3359
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3360 pos(1) = bb(3) - pos(1);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3361 pos(0)++;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3362 pos = convert_position (pos, "pixels", get_units (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3363 bb.extract_n (0, 2, 1, 2));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3364
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3365 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3366 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3367
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3368 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3369 figure::properties::map_to_boundingbox (double x, double y) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3370 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3371 Matrix bb = get_boundingbox (true);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3372 Matrix pos (1, 2, 0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3373
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3374 pos(0) = x;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3375 pos(1) = y;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3376
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3377 pos = convert_position (pos, get_units (), "pixels",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3378 bb.extract_n (0, 2, 1, 2));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3379 pos(0)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3380 pos(1) = bb(3) - pos(1);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3381
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3382 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3383 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3384
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3385 void
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3386 figure::properties::set_position (const octave_value& v,
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3387 bool do_notify_toolkit)
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3388 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3389 if (! error_state)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3390 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3391 Matrix old_bb, new_bb;
14367
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3392 bool modified = false;
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3393
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3394 old_bb = get_boundingbox (true);
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3395 modified = position.set (v, false, do_notify_toolkit);
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3396 new_bb = get_boundingbox (true);
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3397
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3398 if (old_bb != new_bb)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3399 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3400 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3401 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3402 execute_resizefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3403 update_boundingbox ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3404 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3405 }
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3406
14367
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3407 if (modified)
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3408 {
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3409 position.run_listeners (POSTSET);
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3410 mark_modified ();
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3411 }
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3412 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3413 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3414
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3415 void
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3416 figure::properties::set_outerposition (const octave_value& v,
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3417 bool do_notify_toolkit)
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3418 {
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3419 if (! error_state)
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3420 {
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3421 if (outerposition.set (v, true, do_notify_toolkit))
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3422 {
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3423 mark_modified ();
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3424 }
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3425 }
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3426 }
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3427
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3428 void
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3429 figure::properties::set_paperunits (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3430 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3431 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3432 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3433 caseless_str typ = get_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3434 caseless_str punits = v.string_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3435 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3436 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3437 if (punits.compare ("normalized") && typ.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3438 error ("set: can't set the paperunits to normalized when the papertype is custom");
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3439 else
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3440 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3441 caseless_str old_paperunits = get_paperunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3442 if (paperunits.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3443 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3444 update_paperunits (old_paperunits);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3445 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3446 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3447 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3448 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3449 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3450 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3451
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3452 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3453 figure::properties::set_papertype (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3454 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3455 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3456 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3457 caseless_str typ = v.string_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3458 caseless_str punits = get_paperunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3459 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3460 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3461 if (punits.compare ("normalized") && typ.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3462 error ("set: can't set the paperunits to normalized when the papertype is custom");
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3463 else
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3464 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3465 if (papertype.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3466 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3467 update_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3468 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3469 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3470 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3471 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3472 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3473 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3474
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3475 static Matrix
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3476 papersize_from_type (const caseless_str punits, const caseless_str typ)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3477 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3478 Matrix ret (1, 2, 1.0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3479
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3480 if (! punits.compare ("normalized"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3481 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3482 double in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3483 double mm2units;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3484
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3485 if (punits.compare ("inches"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3486 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3487 in2units = 1.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3488 mm2units = 1 / 25.4 ;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3489 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3490 else if (punits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3491 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3492 in2units = 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3493 mm2units = 1 / 10.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3494 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3495 else // points
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3496 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3497 in2units = 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3498 mm2units = 72.0 / 25.4;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3499 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3500
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3501 if (typ.compare ("usletter"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3502 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3503 ret (0) = 8.5 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3504 ret (1) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3505 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3506 else if (typ.compare ("uslegal"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3507 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3508 ret (0) = 8.5 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3509 ret (1) = 14.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3510 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3511 else if (typ.compare ("tabloid"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3512 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3513 ret (0) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3514 ret (1) = 17.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3515 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3516 else if (typ.compare ("a0"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3517 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3518 ret (0) = 841.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3519 ret (1) = 1189.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3520 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3521 else if (typ.compare ("a1"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3522 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3523 ret (0) = 594.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3524 ret (1) = 841.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3525 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3526 else if (typ.compare ("a2"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3527 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3528 ret (0) = 420.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3529 ret (1) = 594.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3530 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3531 else if (typ.compare ("a3"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3532 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3533 ret (0) = 297.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3534 ret (1) = 420.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3535 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3536 else if (typ.compare ("a4"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3537 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3538 ret (0) = 210.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3539 ret (1) = 297.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3540 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3541 else if (typ.compare ("a5"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3542 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3543 ret (0) = 148.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3544 ret (1) = 210.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3545 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3546 else if (typ.compare ("b0"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3547 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3548 ret (0) = 1029.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3549 ret (1) = 1456.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3550 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3551 else if (typ.compare ("b1"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3552 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3553 ret (0) = 728.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3554 ret (1) = 1028.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3555 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3556 else if (typ.compare ("b2"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3557 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3558 ret (0) = 514.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3559 ret (1) = 728.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3560 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3561 else if (typ.compare ("b3"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3562 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3563 ret (0) = 364.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3564 ret (1) = 514.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3565 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3566 else if (typ.compare ("b4"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3567 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3568 ret (0) = 257.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3569 ret (1) = 364.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3570 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3571 else if (typ.compare ("b5"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3572 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3573 ret (0) = 182.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3574 ret (1) = 257.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3575 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3576 else if (typ.compare ("arch-a"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3577 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3578 ret (0) = 9.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3579 ret (1) = 12.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3580 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3581 else if (typ.compare ("arch-b"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3582 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3583 ret (0) = 12.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3584 ret (1) = 18.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3585 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3586 else if (typ.compare ("arch-c"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3587 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3588 ret (0) = 18.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3589 ret (1) = 24.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3590 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3591 else if (typ.compare ("arch-d"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3592 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3593 ret (0) = 24.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3594 ret (1) = 36.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3595 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3596 else if (typ.compare ("arch-e"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3597 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3598 ret (0) = 36.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3599 ret (1) = 48.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3600 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3601 else if (typ.compare ("a"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3602 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3603 ret (0) = 8.5 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3604 ret (1) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3605 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3606 else if (typ.compare ("b"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3607 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3608 ret (0) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3609 ret (1) = 17.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3610 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3611 else if (typ.compare ("c"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3612 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3613 ret (0) = 17.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3614 ret (1) = 22.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3615 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3616 else if (typ.compare ("d"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3617 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3618 ret (0) = 22.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3619 ret (1) = 34.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3620 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3621 else if (typ.compare ("e"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3622 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3623 ret (0) = 34.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3624 ret (1) = 43.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3625 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3626 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3627
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3628 return ret;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3629 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3630
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3631 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3632 figure::properties::update_paperunits (const caseless_str& old_paperunits)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3633 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3634 Matrix pos = get_paperposition ().matrix_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3635 Matrix sz = get_papersize ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3636
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3637 pos(0) /= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3638 pos(1) /= sz(1);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3639 pos(2) /= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3640 pos(3) /= sz(1);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3641
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3642 std::string porient = get_paperorientation ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3643 caseless_str punits = get_paperunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3644 caseless_str typ = get_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3645
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3646 if (typ.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3647 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3648 if (old_paperunits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3649 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3650 sz(0) /= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3651 sz(1) /= 2.54;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3652 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3653 else if (old_paperunits.compare ("points"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3654 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3655 sz(0) /= 72.0;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3656 sz(1) /= 72.0;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3657 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3658
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3659 if (punits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3660 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3661 sz(0) *= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3662 sz(1) *= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3663 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3664 else if (punits.compare ("points"))
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3665 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3666 sz(0) *= 72.0;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3667 sz(1) *= 72.0;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3668 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3669 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3670 else
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3671 {
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3672 sz = papersize_from_type (punits, typ);
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3673 if (porient == "landscape")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3674 std::swap (sz(0), sz(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3675 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3676
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3677 pos(0) *= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3678 pos(1) *= sz(1);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3679 pos(2) *= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3680 pos(3) *= sz(1);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3681
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3682 papersize.set (octave_value (sz));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3683 paperposition.set (octave_value (pos));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3684 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3685
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3686 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3687 figure::properties::update_papertype (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3688 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3689 caseless_str typ = get_papertype ();
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3690 if (! typ.compare ("<custom>"))
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3691 {
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3692 Matrix sz = papersize_from_type (get_paperunits (), typ);
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3693 if (get_paperorientation () == "landscape")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3694 std::swap (sz(0), sz(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3695 // Call papersize.set rather than set_papersize to avoid loops
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3696 // between update_papersize and update_papertype
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3697 papersize.set (octave_value (sz));
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3698 }
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3699 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3700
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3701 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3702 figure::properties::update_papersize (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3703 {
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3704 Matrix sz = get_papersize ().matrix_value ();
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3705 if (sz(0) > sz(1))
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3706 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3707 std::swap (sz(0), sz(1));
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3708 papersize.set (octave_value (sz));
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3709 paperorientation.set (octave_value ("landscape"));
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3710 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3711 else
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3712 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3713 paperorientation.set ("portrait");
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3714 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3715 std::string punits = get_paperunits ();
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3716 if (punits == "centimeters")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3717 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3718 sz(0) /= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3719 sz(1) /= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3720 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3721 else if (punits == "points")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3722 {
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3723 sz(0) /= 72.0;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3724 sz(1) /= 72.0;
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3725 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3726 if (punits == "normalized")
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3727 {
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3728 caseless_str typ = get_papertype ();
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3729 if (get_papertype () == "<custom>")
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3730 error ("set: can't set the papertype to <custom> when the paperunits is normalized");
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3731 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3732 else
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3733 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3734 // TODO - the papersizes info is also in papersize_from_type().
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3735 // Both should be rewritten to avoid the duplication.
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3736 std::string typ = "<custom>";
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3737 const double mm2in = 1.0 / 25.4;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3738 const double tol = 0.01;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3739
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3740 if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3741 typ = "usletter";
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3742 else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3743 typ = "uslegal";
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3744 else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3745 typ = "tabloid";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3746 else if (std::abs (sz(0) - 841.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3747 + std::abs (sz(1) - 1198.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3748 typ = "a0";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3749 else if (std::abs (sz(0) - 594.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3750 + std::abs (sz(1) - 841.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3751 typ = "a1";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3752 else if (std::abs (sz(0) - 420.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3753 + std::abs (sz(1) - 594.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3754 typ = "a2";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3755 else if (std::abs (sz(0) - 297.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3756 + std::abs (sz(1) - 420.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3757 typ = "a3";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3758 else if (std::abs (sz(0) - 210.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3759 + std::abs (sz(1) - 297.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3760 typ = "a4";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3761 else if (std::abs (sz(0) - 148.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3762 + std::abs (sz(1) - 210.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3763 typ = "a5";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3764 else if (std::abs (sz(0) - 1029.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3765 + std::abs (sz(1) - 1456.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3766 typ = "b0";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3767 else if (std::abs (sz(0) - 728.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3768 + std::abs (sz(1) - 1028.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3769 typ = "b1";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3770 else if (std::abs (sz(0) - 514.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3771 + std::abs (sz(1) - 728.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3772 typ = "b2";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3773 else if (std::abs (sz(0) - 364.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3774 + std::abs (sz(1) - 514.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3775 typ = "b3";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3776 else if (std::abs (sz(0) - 257.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3777 + std::abs (sz(1) - 364.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3778 typ = "b4";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3779 else if (std::abs (sz(0) - 182.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3780 + std::abs (sz(1) - 257.0 * mm2in) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3781 typ = "b5";
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18806
diff changeset
3782 else if (std::abs (sz(0) - 9.0)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3783 + std::abs (sz(1) - 12.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3784 typ = "arch-a";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3785 else if (std::abs (sz(0) - 12.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3786 + std::abs (sz(1) - 18.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3787 typ = "arch-b";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3788 else if (std::abs (sz(0) - 18.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3789 + std::abs (sz(1) - 24.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3790 typ = "arch-c";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3791 else if (std::abs (sz(0) - 24.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3792 + std::abs (sz(1) - 36.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3793 typ = "arch-d";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3794 else if (std::abs (sz(0) - 36.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3795 + std::abs (sz(1) - 48.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3796 typ = "arch-e";
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18806
diff changeset
3797 else if (std::abs (sz(0) - 8.5)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3798 + std::abs (sz(1) - 11.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3799 typ = "a";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3800 else if (std::abs (sz(0) - 11.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3801 + std::abs (sz(1) - 17.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3802 typ = "b";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3803 else if (std::abs (sz(0) - 17.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3804 + std::abs (sz(1) - 22.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3805 typ = "c";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3806 else if (std::abs (sz(0) - 22.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3807 + std::abs (sz(1) - 34.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3808 typ = "d";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3809 else if (std::abs (sz(0) - 34.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3810 + std::abs (sz(1) - 43.0) < tol)
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3811 typ = "e";
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3812 // Call papertype.set rather than set_papertype to avoid loops between
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3813 // update_papersize and update_papertype
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3814 papertype.set (typ);
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3815 }
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3816 if (punits == "centimeters")
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3817 {
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3818 sz(0) *= 2.54;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3819 sz(1) *= 2.54;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3820 }
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3821 else if (punits == "points")
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3822 {
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3823 sz(0) *= 72.0;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3824 sz(1) *= 72.0;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3825 }
14457
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
3826 if (get_paperorientation () == "landscape")
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
3827 {
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
3828 std::swap (sz(0), sz(1));
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
3829 papersize.set (octave_value (sz));
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
3830 }
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3831 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3832
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3833 /*
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3834 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3835 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3836 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3837 %! set (hf, "paperunits", "inches");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3838 %! set (hf, "papersize", [5, 4]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3839 %! set (hf, "paperunits", "points");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3840 %! assert (get (hf, "papersize"), [5, 4] * 72, 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3841 %! papersize = get (hf, "papersize");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3842 %! set (hf, "papersize", papersize + 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3843 %! set (hf, "papersize", papersize);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3844 %! assert (get (hf, "papersize"), [5, 4] * 72, 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3845 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3846 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3847 %! end_unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3848
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3849 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3850 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3851 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3852 %! set (hf, "paperunits", "inches");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3853 %! set (hf, "papersize", [5, 4]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3854 %! set (hf, "paperunits", "centimeters");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3855 %! assert (get (hf, "papersize"), [5, 4] * 2.54, 2.54/72);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3856 %! papersize = get (hf, "papersize");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3857 %! set (hf, "papersize", papersize + 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3858 %! set (hf, "papersize", papersize);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3859 %! assert (get (hf, "papersize"), [5, 4] * 2.54, 2.54/72);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3860 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3861 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3862 %! end_unwind_protect
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3863 */
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
3864
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3865 void
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3866 figure::properties::update_paperorientation (void)
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3867 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3868 std::string porient = get_paperorientation ();
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3869 Matrix sz = get_papersize ().matrix_value ();
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3870 Matrix pos = get_paperposition ().matrix_value ();
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3871 if ((sz(0) > sz(1) && porient == "portrait")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3872 || (sz(0) < sz(1) && porient == "landscape"))
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3873 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3874 std::swap (sz(0), sz(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3875 std::swap (pos(0), pos(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3876 std::swap (pos(2), pos(3));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3877 // Call papertype.set rather than set_papertype to avoid loops
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
3878 // between update_papersize and update_papertype
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3879 papersize.set (octave_value (sz));
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3880 paperposition.set (octave_value (pos));
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3881 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3882 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3883
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3884 /*
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3885 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3886 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3887 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3888 %! tol = 100 * eps ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3889 %! ## UPPER case and MiXed case is part of test and should not be changed.
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3890 %! set (hf, "paperorientation", "PORTRAIT");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3891 %! set (hf, "paperunits", "inches");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3892 %! set (hf, "papertype", "USletter");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3893 %! assert (get (hf, "papersize"), [8.5, 11.0], tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3894 %! set (hf, "paperorientation", "Landscape");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3895 %! assert (get (hf, "papersize"), [11.0, 8.5], tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3896 %! set (hf, "paperunits", "centimeters");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3897 %! assert (get (hf, "papersize"), [11.0, 8.5] * 2.54, tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3898 %! set (hf, "papertype", "a4");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3899 %! assert (get (hf, "papersize"), [29.7, 21.0], tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3900 %! set (hf, "paperunits", "inches", "papersize", [8.5, 11.0]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3901 %! assert (get (hf, "papertype"), "usletter");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3902 %! assert (get (hf, "paperorientation"), "portrait");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3903 %! set (hf, "papersize", [11.0, 8.5]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3904 %! assert (get (hf, "papertype"), "usletter");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3905 %! assert (get (hf, "paperorientation"), "landscape");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3906 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3907 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3908 %! end_unwind_protect
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
3909 */
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3910
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3911 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3912 figure::properties::set_units (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3913 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3914 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3915 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3916 caseless_str old_units = get_units ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3917 if (units.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3918 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3919 update_units (old_units);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3920 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3921 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3922 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3923 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3924
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3925 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3926 figure::properties::update_units (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3927 {
14367
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3928 position.set (convert_position (get_position ().matrix_value (), old_units,
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
3929 get_units (), screen_size_pixels ()), false);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3930 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3931
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3932 /*
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3933 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
3934 %! hf = figure ("visible", "off");
17237
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3935 %! old_units = get (0, "units");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3936 %! unwind_protect
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3937 %! set (0, "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3938 %! rsz = get (0, "screensize");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3939 %! set (gcf (), "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3940 %! fsz = get (gcf (), "position");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3941 %! set (gcf (), "units", "normalized");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3942 %! pos = get (gcf (), "position");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3943 %! assert (pos, (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4]));
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3944 %! unwind_protect_cleanup
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3945 %! close (hf);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3946 %! set (0, "units", old_units);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3947 %! end_unwind_protect
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3948 */
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3949
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3950 std::string
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3951 figure::properties::get_title (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3952 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3953 if (is_numbertitle ())
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3954 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3955 std::ostringstream os;
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
3956 std::string nm = get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3957
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3958 os << "Figure " << __myhandle__.value ();
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
3959 if (! nm.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3960 os << ": " << get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3961
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3962 return os.str ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3963 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3964 else
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3965 return get_name ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3966 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3967
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3968 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
3969 figure::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3970 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3971 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3972
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3973 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3974 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3975 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3976 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3977
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3978 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3979 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3980
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3981 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3982 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3983
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3984 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3985 figure::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3986 {
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3987 ::reset_default_properties (default_properties);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3988 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3989
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3990 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3991
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3992 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3993 axes::properties::init (void)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3994 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3995 position.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3996 outerposition.add_constraint (dim_vector (1, 4));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
3997 tightinset.add_constraint (dim_vector (1, 4));
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
3998 looseinset.add_constraint (dim_vector (1, 4));
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3999 colororder.add_constraint (dim_vector (-1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4000 dataaspectratio.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4001 plotboxaspectratio.add_constraint (dim_vector (1, 3));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4002 alim.add_constraint (2);
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4003 clim.add_constraint (2);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4004 xlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4005 ylim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4006 zlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4007 xtick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4008 ytick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4009 ztick.add_constraint (dim_vector (1, -1));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4010 ticklength.add_constraint (dim_vector (1, 2));
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4011 Matrix vw (1, 2, 0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4012 vw(1) = 90;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4013 view = vw;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4014 view.add_constraint (dim_vector (1, 2));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4015 cameraposition.add_constraint (dim_vector (1, 3));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4016 cameratarget.add_constraint (dim_vector (1, 3));
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4017 Matrix upv (1, 3, 0.0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4018 upv(2) = 1.0;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4019 cameraupvector = upv;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4020 cameraupvector.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4021 currentpoint.add_constraint (dim_vector (2, 3));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4022 // No constraints for hidden transform properties
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4023 update_font ();
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4024
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4025 x_zlim.resize (1, 2);
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4026
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4027 sx = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4028 sy = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4029 sz = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4030
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4031 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4032 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4033 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4034
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4035 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4036 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4037 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4038 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4039
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4040 xset (xlabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4041 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4042 xset (ylabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4043 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4044 xset (zlabel.handle_value (), "horizontalalignment", "right");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4045 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4046 xset (title.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4047 xset (title.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4048
16204
92f8bfae9b13 Set default xlabel "verticalalignment" to "top".
Rik <rik@octave.org>
parents: 16201
diff changeset
4049 xset (xlabel.handle_value (), "verticalalignment", "top");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4050 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4051 xset (ylabel.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4052 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4053 xset (title.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4054 xset (title.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4055
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4056 xset (ylabel.handle_value (), "rotation", 90.0);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4057 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4058
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4059 xset (zlabel.handle_value (), "visible", "off");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4060
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4061 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4062 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4063 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4064 xset (title.handle_value (), "clipping", "off");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4065
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4066 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4067 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4068 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4069 xset (title.handle_value (), "autopos_tag", "title");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4070
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4071 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4072 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4073 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4074 adopt (title.handle_value ());
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4075
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4076 Matrix tlooseinset = default_axes_position ();
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4077 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4078 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4079 looseinset = tlooseinset;
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4080 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4081
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4082 Matrix
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4083 axes::properties::calc_tightbox (const Matrix& init_pos)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4084 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4085 Matrix pos = init_pos;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4086 graphics_object obj = gh_manager::get_object (get_parent ());
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4087 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4088 Matrix ext = get_extent (true, true);
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4089 ext(1) = parent_bb(3) - ext(1) - ext(3);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4090 ext(0)++;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4091 ext(1)++;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4092 ext = convert_position (ext, "pixels", get_units (),
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4093 parent_bb.extract_n (0, 2, 1, 2));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4094 if (ext(0) < pos(0))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4095 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4096 pos(2) += pos(0)-ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4097 pos(0) = ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4098 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4099 if (ext(0)+ext(2) > pos(0)+pos(2))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4100 pos(2) = ext(0)+ext(2)-pos(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4101
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4102 if (ext(1) < pos(1))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4103 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4104 pos(3) += pos(1)-ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4105 pos(1) = ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4106 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4107 if (ext(1)+ext(3) > pos(1)+pos(3))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4108 pos(3) = ext(1)+ext(3)-pos(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4109 return pos;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4110 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4111
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4112 void
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4113 axes::properties::sync_positions (void)
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4114 {
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4115 // First part is equivalent to `update_tightinset ()'
17216
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4116 if (activepositionproperty.is ("position"))
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4117 update_position ();
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4118 else
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4119 update_outerposition ();
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4120 caseless_str old_units = get_units ();
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4121 set_units ("normalized");
16832
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4122 Matrix pos = position.get ().matrix_value ();
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4123 Matrix outpos = outerposition.get ().matrix_value ();
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4124 Matrix tightpos = calc_tightbox (pos);
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4125 Matrix tinset (1, 4, 1.0);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4126 tinset(0) = pos(0)-tightpos(0);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4127 tinset(1) = pos(1)-tightpos(1);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4128 tinset(2) = tightpos(0)+tightpos(2)-pos(0)-pos(2);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4129 tinset(3) = tightpos(1)+tightpos(3)-pos(1)-pos(3);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4130 tightinset = tinset;
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4131 set_units (old_units);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4132 update_transform ();
17260
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4133 if (activepositionproperty.is ("position"))
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4134 update_position ();
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4135 else
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4136 update_outerposition ();
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4137 }
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4138
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4139 /*
17286
d5efffe5a789 graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents: 17281
diff changeset
4140 %!testif HAVE_FLTK
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4141 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4142 %! graphics_toolkit (hf, "fltk");
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4143 %! unwind_protect
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4144 %! subplot(2,1,1); plot(rand(10,1)); subplot(2,1,2); plot(rand(10,1));
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4145 %! hax = findall (gcf (), "type", "axes");
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4146 %! positions = cell2mat (get (hax, "position"));
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4147 %! outerpositions = cell2mat (get (hax, "outerposition"));
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4148 %! looseinsets = cell2mat (get (hax, "looseinset"));
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4149 %! tightinsets = cell2mat (get (hax, "tightinset"));
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4150 %! subplot(2,1,1); plot(rand(10,1)); subplot(2,1,2); plot(rand(10,1));
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4151 %! hax = findall (gcf (), "type", "axes");
17216
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4152 %! assert (cell2mat (get (hax, "position")), positions, 1e-4);
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4153 %! assert (cell2mat (get (hax, "outerposition")), outerpositions, 1e-4);
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4154 %! assert (cell2mat (get (hax, "looseinset")), looseinsets, 1e-4);
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4155 %! assert (cell2mat (get (hax, "tightinset")), tightinsets, 1e-4);
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4156 %! unwind_protect_cleanup
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4157 %! close (hf);
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4158 %! end_unwind_protect
17286
d5efffe5a789 graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents: 17281
diff changeset
4159 %!testif HAVE_FLTK
17222
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4160 %! hf = figure ("visible", "off");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4161 %! graphics_toolkit (hf, "fltk");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4162 %! fpos = get (hf, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4163 %! unwind_protect
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4164 %! plot (rand (3))
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4165 %! position = get (gca, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4166 %! outerposition = get (gca, "outerposition");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4167 %! looseinset = get (gca, "looseinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4168 %! tightinset = get (gca, "tightinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4169 %! set (hf, "position", [fpos(1:2), 2*fpos(3:4)])
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4170 %! set (hf, "position", fpos);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4171 %! assert (get (gca, "outerposition"), outerposition, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4172 %! assert (get (gca, "position"), position, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4173 %! assert (get (gca, "looseinset"), looseinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4174 %! assert (get (gca, "tightinset"), tightinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4175 %! unwind_protect_cleanup
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4176 %! close (hf);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4177 %! end_unwind_protect
17286
d5efffe5a789 graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents: 17281
diff changeset
4178 %!testif HAVE_FLTK
17222
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4179 %! hf = figure ("visible", "off");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4180 %! graphics_toolkit (hf, "fltk");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4181 %! fpos = get (hf, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4182 %! set (gca, "activepositionproperty", "position")
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4183 %! unwind_protect
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4184 %! plot (rand (3))
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4185 %! position = get (gca, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4186 %! outerposition = get (gca, "outerposition");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4187 %! looseinset = get (gca, "looseinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4188 %! tightinset = get (gca, "tightinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4189 %! set (hf, "position", [fpos(1:2), 2*fpos(3:4)])
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4190 %! set (hf, "position", fpos);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4191 %! assert (get (gca, "position"), position, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4192 %! assert (get (gca, "outerposition"), outerposition, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4193 %! assert (get (gca, "looseinset"), looseinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4194 %! assert (get (gca, "tightinset"), tightinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4195 %! unwind_protect_cleanup
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4196 %! close (hf);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4197 %! end_unwind_protect
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4198 */
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4199
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4200 void
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4201 axes::properties::set_text_child (handle_property& hp,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4202 const std::string& who,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4203 const octave_value& v)
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
4204 {
10265
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4205 graphics_handle val;
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4206
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4207 if (v.is_string ())
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4208 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4209 val = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4210 false, false);
10265
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4211
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4212 xset (val, "string", v);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4213 }
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4214 else
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4215 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4216 graphics_object go = gh_manager::get_object (gh_manager::lookup (v));
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4217
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4218 if (go.isa ("text"))
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4219 val = ::reparent (v, "set", who, __myhandle__, false);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4220 else
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4221 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4222 std::string cname = v.class_name ();
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4223
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4224 error ("set: expecting text graphics object or character string for %s property, found %s",
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4225 who.c_str (), cname.c_str ());
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4226 }
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4227 }
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
4228
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4229 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4230 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4231 xset (val, "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4232
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4233 gh_manager::free (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4234
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4235 base_properties::remove_child (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4236
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4237 hp = val;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4238
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4239 adopt (hp.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4240 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4241 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4242
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4243 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4244 axes::properties::set_xlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4245 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4246 set_text_child (xlabel, "xlabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4247 xset (xlabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4248 xset (xlabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4249 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4250 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4251 xset (xlabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
4252 xset (xlabel.handle_value (), "color", get_xcolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4253 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4254 update_xlabel_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4255 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4256
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4257 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4258 axes::properties::set_ylabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4259 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4260 set_text_child (ylabel, "ylabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4261 xset (ylabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4262 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4263 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4264 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4265 xset (ylabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
4266 xset (ylabel.handle_value (), "color", get_ycolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4267 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4268 update_ylabel_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4269 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4270
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4271 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4272 axes::properties::set_zlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4273 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4274 set_text_child (zlabel, "zlabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4275 xset (zlabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4276 xset (zlabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4277 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4278 xset (zlabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4279 xset (zlabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
4280 xset (zlabel.handle_value (), "color", get_zcolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4281 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4282 update_zlabel_position ();
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4283 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4284
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4285 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4286 axes::properties::set_title (const octave_value& v)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4287 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4288 set_text_child (title, "title", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4289 xset (title.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4290 xset (title.handle_value (), "horizontalalignment", "center");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4291 xset (title.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4292 xset (title.handle_value (), "verticalalignment", "bottom");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4293 xset (title.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4294 xset (title.handle_value (), "clipping", "off");
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4295 xset (title.handle_value (), "autopos_tag", "title");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4296 update_title_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4297 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4298
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4299 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
4300 axes::properties::set_defaults (base_graphics_object& obj,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4301 const std::string& mode)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4302 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4303 box = "on";
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
4304 colororder = default_colororder ();
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4305 // Note: dataspectratio will be set through update_aspectratios
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4306 dataaspectratiomode = "auto";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4307 layer = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4308
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4309 Matrix tlim (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4310 tlim(1) = 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4311 xlim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4312 ylim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4313 zlim = tlim;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4314
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4315 Matrix cl (1, 2, 0);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4316 cl(1) = 1;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4317 clim = cl;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4318
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4319 alim = tlim;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4320
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4321 xlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4322 ylimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4323 zlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4324 climmode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4325 alimmode = "auto";
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4326
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4327 xgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4328 ygrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4329 zgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4330 xminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4331 yminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4332 zminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4333 xtick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4334 ytick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4335 ztick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4336 xtickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4337 ytickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4338 ztickmode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4339 xminortick = "off";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4340 yminortick = "off";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4341 zminortick = "off";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4342 xticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4343 yticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4344 zticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4345 xticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4346 yticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4347 zticklabelmode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4348
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4349 interpreter = "none";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4350
14798
fce841c941a5 The color property for new plot axes should take on the default value.
Ben Abbott <bpabbott@mac.com>
parents: 14691
diff changeset
4351 color = color_values ("white");
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
4352 xcolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
4353 ycolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
4354 zcolor = color_values ("black");
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4355 xscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4356 yscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4357 zscale = "linear";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4358 xdir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4359 ydir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4360 zdir = "normal";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4361 yaxislocation = "left";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4362 xaxislocation = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4363
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4364 Matrix tview (1, 2, 0.0);
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4365 tview(1) = 90;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4366 view = tview;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4367
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4368 __hold_all__ = "off";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4369 nextplot = "replace";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4370
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4371 ambientlightcolor = Matrix (1, 3, 1.0);
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4372
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4373 // Note: camera properties (not mode) will be set in update_transform
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4374 camerapositionmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4375 cameratargetmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4376 cameraupvectormode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4377 cameraviewanglemode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4378
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4379 drawmode = "normal";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4380
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4381 fontangle = "normal";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4382 fontname = OCTAVE_DEFAULT_FONTNAME;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4383 fontsize = 10;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4384 fontunits = "points";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4385 fontweight = "normal";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4386
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
4387 gridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4388 linestyleorder = "-";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4389 linewidth = 0.5;
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
4390 minorgridlinestyle = ":";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4391
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4392 // Note: plotboxaspectratio will be set through update_aspectratios
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4393 plotboxaspectratiomode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4394 projection = "orthographic";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4395
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4396 tickdir = "in";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4397 tickdirmode = "auto";
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
4398 ticklength = default_axes_ticklength ();
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4399
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4400 tightinset = Matrix (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4401
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4402 sx = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4403 sy = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4404 sz = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4405
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6761
diff changeset
4406 visible = "on";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4407
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4408 // Replace preserves Position and Units properties
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4409 if (mode != "replace")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4410 {
16832
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4411 outerposition = default_axes_outerposition ();
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4412 position = default_axes_position ();
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
4413 activepositionproperty = "outerposition";
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4414 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4415
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
4416 delete_children (true);
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
4417
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4418 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4419 false, false);
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4420
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4421 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4422 false, false);
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4423
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4424 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4425 false, false);
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4426
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4427 title = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4428 false, false);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4429
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4430 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4431 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4432 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4433 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4434
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4435 xset (xlabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4436 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4437 xset (ylabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4438 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4439 xset (zlabel.handle_value (), "horizontalalignment", "right");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4440 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4441 xset (title.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4442 xset (title.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4443
16204
92f8bfae9b13 Set default xlabel "verticalalignment" to "top".
Rik <rik@octave.org>
parents: 16201
diff changeset
4444 xset (xlabel.handle_value (), "verticalalignment", "top");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4445 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4446 xset (ylabel.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4447 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4448 xset (title.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4449 xset (title.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4450
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4451 xset (ylabel.handle_value (), "rotation", 90.0);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4452 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4453
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4454 xset (zlabel.handle_value (), "visible", "off");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4455
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4456 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4457 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4458 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4459 xset (title.handle_value (), "clipping", "off");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4460
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4461 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4462 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4463 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4464 xset (title.handle_value (), "autopos_tag", "title");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4465
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4466 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4467 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4468 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4469 adopt (title.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4470
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4471 update_transform ();
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4472 sync_positions ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4473 override_defaults (obj);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4474 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4475
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4476 void
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4477 axes::properties::delete_text_child (handle_property& hp)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4478 {
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4479 graphics_handle h = hp.handle_value ();
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4480
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4481 if (h.ok ())
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4482 {
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4483 graphics_object go = gh_manager::get_object (h);
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4484
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4485 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4486 gh_manager::free (h);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4487
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4488 base_properties::remove_child (h);
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4489 }
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4490
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4491 // FIXME: is it necessary to check whether the axes object is
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4492 // being deleted now? I think this function is only called when an
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4493 // individual child object is delete and not when the parent axes
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4494 // object is deleted.
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4495
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4496 if (! is_beingdeleted ())
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4497 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4498 hp = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4499 false, false);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4500
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4501 xset (hp.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4502
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4503 adopt (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4504 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4505 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4506
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4507 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
4508 axes::properties::remove_child (const graphics_handle& h)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4509 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4510 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4511 delete_text_child (xlabel);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4512 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4513 delete_text_child (ylabel);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4514 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4515 delete_text_child (zlabel);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4516 else if (title.handle_value ().ok () && h == title.handle_value ())
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4517 delete_text_child (title);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4518 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4519 base_properties::remove_child (h);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4520 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4521
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4522 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4523 xform_matrix (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4524 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4525 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4526 for (int i = 0; i < 4; i++)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4527 m(i,i) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4528 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4529 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4530
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4531 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4532 xform_vector (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4533 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4534 ColumnVector v (4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4535 v(3) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4536 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4537 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4538
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4539 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4540 xform_vector (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4541 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4542 ColumnVector v (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4543 v(0) = x; v(1) = y; v(2) = z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4544 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4545 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4546
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4547 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4548 transform (const Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4549 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4550 return (m * xform_vector (x, y, z));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4551 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4552
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4553 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4554 xform_scale (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4555 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4556 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4557 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4558 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4559 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4560
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4561 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4562 xform_translate (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4563 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4564 Matrix m = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4565 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4566 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4567 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4568
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4569 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4570 scale (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4571 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4572 m = m * xform_scale (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4573 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4574
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4575 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4576 translate (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4577 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4578 m = m * xform_translate (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4579 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4580
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4581 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4582 xform (ColumnVector& v, const Matrix& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4583 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4584 v = m*v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4585 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4586
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4587 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4588 scale (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4589 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4590 v(0) *= x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4591 v(1) *= y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4592 v(2) *= z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4593 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4594
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4595 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4596 translate (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4597 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4598 v(0) += x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4599 v(1) += y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4600 v(2) += z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4601 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4602
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4603 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4604 normalize (ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4605 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4606 double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4607 scale (v, fact, fact, fact);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4608 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4609
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4610 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4611 dot (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4612 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4613 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4614 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4615
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4616 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4617 norm (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4618 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4619 return sqrt (dot (v, v));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4620 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4621
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4622 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4623 cross (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4624 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4625 ColumnVector r = xform_vector ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4626 r(0) = v1(1)*v2(2)-v1(2)*v2(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4627 r(1) = v1(2)*v2(0)-v1(0)*v2(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4628 r(2) = v1(0)*v2(1)-v1(1)*v2(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4629 return r;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4630 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4631
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4632 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4633 unit_cube (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4634 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4635 static double data[32] =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4636 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4637 0,0,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4638 1,0,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4639 0,1,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4640 0,0,1,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4641 1,1,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4642 1,0,1,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4643 0,1,1,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4644 1,1,1,1
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4645 };
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4646 Matrix m (4, 8);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4647 memcpy (m.fortran_vec (), data, sizeof (double)*32);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4648 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4649 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4650
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4651 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4652 cam2xform (const Array<double>& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4653 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4654 ColumnVector retval (4, 1.0);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4655 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof (double)*3);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4656 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4657 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4658
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4659 inline RowVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4660 xform2cam (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4661 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4662 return v.extract_n (0, 3).transpose ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4663 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4664
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4665 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4666 axes::properties::update_camera (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4667 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4668 double xd = (xdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4669 double yd = (ydir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4670 double zd = (zdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4671
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4672 Matrix xlimits = sx.scale (get_xlim ().matrix_value ());
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4673 Matrix ylimits = sy.scale (get_ylim ().matrix_value ());
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4674 Matrix zlimits = sz.scale (get_zlim ().matrix_value ());
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4675
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4676 double xo = xlimits(xd > 0 ? 0 : 1);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4677 double yo = ylimits(yd > 0 ? 0 : 1);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4678 double zo = zlimits(zd > 0 ? 0 : 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4679
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
4680 Matrix pb = get_plotboxaspectratio ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4681
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4682 bool autocam = (camerapositionmode_is ("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4683 && cameratargetmode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4684 && cameraupvectormode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4685 && cameraviewanglemode_is ("auto"));
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4686 bool dowarp = (autocam && dataaspectratiomode_is ("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4687 && plotboxaspectratiomode_is ("auto"));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4688
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4689 ColumnVector c_eye (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4690 ColumnVector c_center (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4691 ColumnVector c_upv (xform_vector ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4692
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4693 if (cameratargetmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4694 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4695 c_center(0) = (xlimits(0)+xlimits(1))/2;
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4696 c_center(1) = (ylimits(0)+ylimits(1))/2;
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4697 c_center(2) = (zlimits(0)+zlimits(1))/2;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4698
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4699 cameratarget = xform2cam (c_center);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4700 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4701 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4702 c_center = cam2xform (get_cameratarget ().matrix_value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4703
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4704 if (camerapositionmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4705 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4706 Matrix tview = get_view ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4707 double az = tview(0), el = tview(1);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4708 double d = 5 * sqrt (pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4709
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4710 if (el == 90 || el == -90)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4711 c_eye(2) = d*signum (el);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4712 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4713 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4714 az *= M_PI/180.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4715 el *= M_PI/180.0;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4716 c_eye(0) = d * cos (el) * sin (az);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4717 c_eye(1) = -d* cos (el) * cos (az);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4718 c_eye(2) = d * sin (el);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4719 }
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4720 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4721 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4722 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4723
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4724 cameraposition = xform2cam (c_eye);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4725 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4726 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4727 c_eye = cam2xform (get_cameraposition ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4728
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4729 if (cameraupvectormode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4730 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4731 Matrix tview = get_view ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4732 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4733
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4734 if (el == 90 || el == -90)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4735 {
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4736 c_upv(0) =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4737 -signum (el) *sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4738 c_upv(1) =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4739 signum (el) * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4740 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4741 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4742 c_upv(2) = 1;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4743
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4744 cameraupvector = xform2cam (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4745 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4746 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4747 c_upv = cam2xform (get_cameraupvector ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4748
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4749 Matrix x_view = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4750 Matrix x_projection = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4751 Matrix x_viewport = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4752 Matrix x_normrender = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4753 Matrix x_pre = xform_matrix ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4754
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4755 x_render = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4756 x_render_inv = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4757
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4758 scale (x_pre, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4759 translate (x_pre, -0.5, -0.5, -0.5);
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4760 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4761 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4762 translate (x_pre, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4763
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4764 xform (c_eye, x_pre);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4765 xform (c_center, x_pre);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4766 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4767 pb(2)/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4768 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4769
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4770 ColumnVector F (c_center), f (F), UP (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4771 normalize (f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4772 normalize (UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4773
7440
4e3b073e910e [project @ 2008-02-02 18:23:50 by jwe]
jwe
parents: 7435
diff changeset
4774 if (std::abs (dot (f, UP)) > 1e-15)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4775 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4776 double fa = 1 / sqrt(1-f(2)*f(2));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4777 scale (UP, fa, fa, fa);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4778 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4779
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4780 ColumnVector s = cross (f, UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4781 ColumnVector u = cross (s, f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4782
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4783 scale (x_view, 1, 1, -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4784 Matrix l = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4785 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4786 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4787 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4788 x_view = x_view * l;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4789 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4790 scale (x_view, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4791 translate (x_view, -0.5, -0.5, -0.5);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4792
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4793 Matrix x_cube = x_view * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4794 ColumnVector cmin = x_cube.row_min (), cmax = x_cube.row_max ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4795 double xM = cmax(0)-cmin(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4796 double yM = cmax(1)-cmin(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4797
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4798 Matrix bb = get_boundingbox (true);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4799
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4800 double v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4801
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4802 if (cameraviewanglemode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4803 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4804 double af;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4805
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4806 // FIXME: was this really needed? When compared to Matlab, it
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4807 // does not seem to be required. Need investigation with concrete
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4808 // graphics toolkit to see results visually.
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4809 if (false && dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4810 af = 1.0 / (xM > yM ? xM : yM);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4811 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4812 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4813 if ((bb(2)/bb(3)) > (xM/yM))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4814 af = 1.0 / yM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4815 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4816 af = 1.0 / xM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4817 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4818 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F)));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4819
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4820 cameraviewangle = v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4821 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4822 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4823 v_angle = get_cameraviewangle ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4824
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4825 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4826 scale (x_projection, pf, pf, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4827
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4828 if (dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4829 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4830 xM *= pf;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4831 yM *= pf;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4832 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4833 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4834 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4835 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4836 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4837 double pix = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4838 if (autocam)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4839 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4840 if ((bb(2)/bb(3)) > (xM/yM))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4841 pix = bb(3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4842 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4843 pix = bb(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4844 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4845 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4846 pix = (bb(2) < bb(3) ? bb(2) : bb(3));
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4847 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4848 scale (x_viewport, pix, -pix, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4849 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4850
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4851 x_normrender = x_viewport * x_projection * x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4852
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4853 x_cube = x_normrender * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4854 cmin = x_cube.row_min ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4855 cmax = x_cube.row_max ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4856 x_zlim.resize (1, 2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4857 x_zlim(0) = cmin(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4858 x_zlim(1) = cmax(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4859
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4860 x_render = x_normrender;
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4861 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4862 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4863 translate (x_render, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4864
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4865 x_viewtransform = x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4866 x_projectiontransform = x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4867 x_viewporttransform = x_viewport;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4868 x_normrendertransform = x_normrender;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4869 x_rendertransform = x_render;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4870
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4871 x_render_inv = x_render.inverse ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4872
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4873 // Note: these matrices are a slight modified version of the regular
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4874 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4875 // => x_gl_mat2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4876 x_gl_mat1 = x_view;
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4877 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4878 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4879 translate (x_gl_mat1, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4880 x_gl_mat2 = x_viewport * x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4881 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4882
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4883 static bool updating_axes_layout = false;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4884
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4885 void
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4886 axes::properties::update_axes_layout (void)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4887 {
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4888 if (updating_axes_layout)
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4889 return;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4890
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4891 graphics_xform xform = get_transform ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4892
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4893 double xd = (xdir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4894 double yd = (ydir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4895 double zd = (zdir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4896
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4897 const Matrix xlims = xform.xscale (get_xlim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4898 const Matrix ylims = xform.yscale (get_ylim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4899 const Matrix zlims = xform.zscale (get_zlim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4900 double x_min = xlims(0), x_max = xlims(1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4901 double y_min = ylims(0), y_max = ylims(1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4902 double z_min = zlims(0), z_max = zlims(1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4903
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4904 ColumnVector p1, p2, dir (3);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4905
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4906 xstate = ystate = zstate = AXE_ANY_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4907
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4908 p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4909 p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4910 dir(0) = xround (p2(0)-p1(0));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4911 dir(1) = xround (p2(1)-p1(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4912 dir(2) = (p2(2)-p1(2));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4913 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4914 xstate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4915 else if (dir(2) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4916 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4917 if (dir(0) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4918 xstate = AXE_VERT_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4919 else if (dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4920 xstate = AXE_HORZ_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4921 }
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4922
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4923 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4924 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4925 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4926 xPlane = (dir(0) > 0 ? x_max : x_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4927 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4928 xPlane = (dir(1) < 0 ? x_max : x_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4929 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4930 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4931 xPlane = (dir(2) < 0 ? x_min : x_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4932
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4933 xPlaneN = (xPlane == x_min ? x_max : x_min);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4934 fx = (x_max-x_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4935
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4936 p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4937 p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4938 dir(0) = xround (p2(0)-p1(0));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4939 dir(1) = xround (p2(1)-p1(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4940 dir(2) = (p2(2)-p1(2));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4941 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4942 ystate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4943 else if (dir(2) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4944 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4945 if (dir(0) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4946 ystate = AXE_VERT_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4947 else if (dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4948 ystate = AXE_HORZ_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4949 }
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4950
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4951 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4952 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4953 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4954 yPlane = (dir(0) > 0 ? y_max : y_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4955 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4956 yPlane = (dir(1) < 0 ? y_max : y_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4957 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4958 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4959 yPlane = (dir(2) < 0 ? y_min : y_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4960
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4961 yPlaneN = (yPlane == y_min ? y_max : y_min);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4962 fy = (y_max-y_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1));
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4963
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4964 p1 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_min, false);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4965 p2 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_max, false);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4966 dir(0) = xround (p2(0)-p1(0));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4967 dir(1) = xround (p2(1)-p1(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4968 dir(2) = (p2(2)-p1(2));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4969 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4970 zstate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4971 else if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4972 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4973 if (dir(0) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4974 zstate = AXE_VERT_DIR;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4975 else if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4976 zstate = AXE_HORZ_DIR;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4977 }
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4978
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4979 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4980 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4981 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4982 zPlane = (dir(0) > 0 ? z_min : z_max);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4983 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4984 zPlane = (dir(1) < 0 ? z_min : z_max);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4985 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4986 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4987 zPlane = (dir(2) < 0 ? z_min : z_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4988
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4989 zPlaneN = (zPlane == z_min ? z_max : z_min);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
4990 fz = (z_max-z_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4991
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4992 unwind_protect frame;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4993 frame.protect_var (updating_axes_layout);
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4994 updating_axes_layout = true;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4995
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4996 xySym = (xd*yd*(xPlane-xPlaneN)*(yPlane-yPlaneN) > 0);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4997 zSign = (zd*(zPlane-zPlaneN) <= 0);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4998 xyzSym = zSign ? xySym : !xySym;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4999 xpTick = (zSign ? xPlaneN : xPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5000 ypTick = (zSign ? yPlaneN : yPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5001 zpTick = (zSign ? zPlane : zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5002 xpTickN = (zSign ? xPlane : xPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5003 ypTickN = (zSign ? yPlane : yPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5004 zpTickN = (zSign ? zPlaneN : zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5005
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5006 /* 2D mode */
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5007 x2Dtop = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5008 y2Dright = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5009 layer2Dtop = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5010 if (xstate == AXE_HORZ_DIR && ystate == AXE_VERT_DIR)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5011 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5012 if (xaxislocation_is ("top"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5013 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5014 double tmp = yPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5015 yPlane = yPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5016 yPlaneN = tmp;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5017 x2Dtop = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5018 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5019 ypTick = yPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5020 ypTickN = yPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5021 if (yaxislocation_is ("right"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5022 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5023 double tmp = xPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5024 xPlane = xPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5025 xPlaneN = tmp;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5026 y2Dright = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5027 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5028 xpTick = xPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5029 xpTickN = xPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5030 if (layer_is ("top"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5031 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5032 zpTick = zPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5033 layer2Dtop = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5034 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5035 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5036 zpTick = zPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5037 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5038
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5039 Matrix viewmat = get_view ().matrix_value ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5040 nearhoriz = std::abs (viewmat(1)) <= 5;
13830
462b5f556346 avoid uninitialized variable warning from valgrind
John W. Eaton <jwe@octave.org>
parents: 13816
diff changeset
5041
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5042 update_ticklength ();
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5043 }
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5044
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5045 void
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5046 axes::properties::update_ticklength (void)
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5047 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5048 bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) +
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5049 (ystate > AXE_DEPTH_DIR ? 1 : 0) +
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5050 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
14395
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5051
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5052 if (tickdirmode_is ("auto"))
14395
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5053 tickdir.set (mode2d ? "in" : "out", true);
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5054
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5055 double ticksign = (tickdir_is ("in") ? -1 : 1);
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5056
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5057 Matrix bbox = get_boundingbox (true);
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5058 Matrix ticklen = get_ticklength ().matrix_value ();
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5059 ticklen(0) = ticklen(0) * std::max (bbox(2), bbox(3));
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5060 ticklen(1) = ticklen(1) * std::max (bbox(2), bbox(3));
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5061
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5062 xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5063 yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5064 zticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5065
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5066 xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5067 ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5068 ztickoffset = (mode2d ? std::max (0., zticklen) : std::abs (zticklen)) + 5;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5069
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5070 update_xlabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5071 update_ylabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5072 update_zlabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5073 update_title_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5074 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5075
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5076 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5077 ## FIXME: A demo can't be called in a C++ file. This should be made a test
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5078 ## or moved to a .m file where it can be called.
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5079 %!demo
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5080 %! clf;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5081 %! subplot (2,1,1);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5082 %! plot (rand (3));
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5083 %! xlabel xlabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5084 %! ylabel ylabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5085 %! title title;
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5086 %! subplot (2,1,2);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5087 %! plot (rand (3));
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5088 %! set (gca, "ticklength", get (gca, "ticklength") * 2, "tickdir", "out");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5089 %! xlabel xlabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5090 %! ylabel ylabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5091 %! title title;
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5092 */
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5093
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5094 static bool updating_xlabel_position = false;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5095
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5096 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5097 axes::properties::update_xlabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5098 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5099 if (updating_xlabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5100 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5101
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5102 text::properties& xlabel_props
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5103 = reinterpret_cast<text::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5104 (gh_manager::get_object (get_xlabel ()).get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5105
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5106 bool is_empty = xlabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5107
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5108 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5109 frame.protect_var (updating_xlabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5110 updating_xlabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5111
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5112 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5113 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5114 if (xlabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5115 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5116 xlabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5117 (xstate > AXE_DEPTH_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5118 ? "center" : (xyzSym ? "left" : "right"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5119
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5120 xlabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5121 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5122
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5123 if (xlabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5124 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5125 xlabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5126 (xstate == AXE_VERT_DIR || x2Dtop ? "bottom" : "top");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5127
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5128 xlabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5129 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5130 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5131
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5132 if (xlabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5133 || xlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5134 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5135 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5136
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5137 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5138 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5139 get_xticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5140 get_xlim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5141
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5142 double wmax = ext(0), hmax = ext(1), angle = 0;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5143 ColumnVector p =
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5144 graphics_xform::xform_vector ((xpTickN+xpTick)/2, ypTick, zpTick);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5145
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5146 bool tick_along_z = nearhoriz || xisinf (fy);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5147 if (tick_along_z)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5148 p(2) += (signum (zpTick-zpTickN)*fz*xtickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5149 else
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5150 p(1) += (signum (ypTick-ypTickN)*fy*xtickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5151
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5152 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5153
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5154 switch (xstate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5155 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5156 case AXE_ANY_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5157 p(0) += (xyzSym ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5158 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5159 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5160
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5161 case AXE_VERT_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5162 p(0) -= wmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5163 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5164 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5165
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5166 case AXE_HORZ_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5167 p(1) += (x2Dtop ? -hmax : hmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5168 break;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5169 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5170
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5171 if (xlabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5172 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5173 p = xform.untransform (p(0), p(1), p(2), true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5174 xlabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5175 xlabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5176 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5177
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5178 if (! is_empty && xlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5179 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5180 xlabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5181 xlabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5182 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5183 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5184 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5185
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5186 static bool updating_ylabel_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5187
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5188 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5189 axes::properties::update_ylabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5190 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5191 if (updating_ylabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5192 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5193
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5194 text::properties& ylabel_props
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5195 = reinterpret_cast<text::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5196 (gh_manager::get_object (get_ylabel ()).get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5197
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5198 bool is_empty = ylabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5199
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5200 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5201 frame.protect_var (updating_ylabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5202 updating_ylabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5203
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5204 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5205 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5206 if (ylabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5207 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5208 ylabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5209 (ystate > AXE_DEPTH_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5210 ? "center" : (!xyzSym ? "left" : "right"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5211
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5212 ylabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5213 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5214
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5215 if (ylabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5216 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5217 ylabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5218 (ystate == AXE_VERT_DIR && !y2Dright ? "bottom" : "top");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5219
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5220 ylabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5221 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5222 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5223
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5224 if (ylabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5225 || ylabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5226 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5227 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5228
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5229 Matrix ext (1, 2, 0.0);
16201
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5230
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5231 // The underlying get_extents() from FreeType produces mismatched values.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5232 // x-extent accurately measures the width of the glyphs.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5233 // y-extent instead measures from baseline-to-baseline.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5234 // Pad x-extent (+4) so that it approximately matches y-extent.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5235 // This keeps ylabels about the same distance from y-axis as
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5236 // xlabels are from x-axis.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5237 // ALWAYS use an even number for padding or horizontal alignment
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5238 // will be off.
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5239 ext = get_ticklabel_extents (get_ytick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5240 get_yticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5241 get_ylim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5242
16201
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5243 double wmax = ext(0)+4, hmax = ext(1), angle = 0;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5244 ColumnVector p =
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5245 graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5246
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5247 bool tick_along_z = nearhoriz || xisinf (fx);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5248 if (tick_along_z)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5249 p(2) += (signum (zpTick-zpTickN)*fz*ytickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5250 else
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5251 p(0) += (signum (xpTick-xpTickN)*fx*ytickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5252
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5253 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5254
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5255 switch (ystate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5256 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5257 case AXE_ANY_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5258 p(0) += (!xyzSym ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5259 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5260 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5261
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5262 case AXE_VERT_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5263 p(0) += (y2Dright ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5264 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5265 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5266
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5267 case AXE_HORZ_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5268 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5269 break;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5270 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5271
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5272 if (ylabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5273 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5274 p = xform.untransform (p(0), p(1), p(2), true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5275 ylabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5276 ylabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5277 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5278
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5279 if (! is_empty && ylabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5280 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5281 ylabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5282 ylabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5283 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5284 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5285 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5286
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5287 static bool updating_zlabel_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5288
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5289 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5290 axes::properties::update_zlabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5291 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5292 if (updating_zlabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5293 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5294
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5295 text::properties& zlabel_props
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5296 = reinterpret_cast<text::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5297 (gh_manager::get_object (get_zlabel ()).get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5298
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5299 bool camAuto = cameraupvectormode_is ("auto");
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5300 bool is_empty = zlabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5301
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5302 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5303 frame.protect_var (updating_zlabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5304 updating_zlabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5305
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5306 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5307 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5308 if (zlabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5309 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5310 zlabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5311 ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5312
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5313 zlabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5314 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5315
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5316 if (zlabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5317 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5318 zlabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5319 (zstate == AXE_VERT_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5320 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5321
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5322 zlabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5323 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5324 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5325
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5326 if (zlabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5327 || zlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5328 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5329 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5330
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5331 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5332 ext = get_ticklabel_extents (get_ztick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5333 get_zticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5334 get_zlim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5335
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5336 double wmax = ext(0), hmax = ext(1), angle = 0;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5337 ColumnVector p;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5338
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5339 if (xySym)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5340 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5341 p = graphics_xform::xform_vector (xPlaneN, yPlane,
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5342 (zpTickN+zpTick)/2);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5343 if (xisinf (fy))
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5344 p(0) += (signum (xPlaneN-xPlane)*fx*ztickoffset);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5345 else
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5346 p(1) += (signum (yPlane-yPlaneN)*fy*ztickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5347 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5348 else
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5349 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5350 p = graphics_xform::xform_vector (xPlane, yPlaneN,
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5351 (zpTickN+zpTick)/2);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5352 if (xisinf (fx))
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5353 p(1) += (signum (yPlaneN-yPlane)*fy*ztickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5354 else
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5355 p(0) += (signum (xPlane-xPlaneN)*fx*ztickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5356 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5357
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5358 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5359
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5360 switch (zstate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5361 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5362 case AXE_ANY_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5363 if (camAuto)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5364 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5365 p(0) -= wmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5366 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5367 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5368
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5369 // FIXME: what's the correct offset?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5370 //
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5371 // p[0] += (!xySym ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5372 // p[1] += (zSign ? hmax : -hmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5373
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5374 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5375
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5376 case AXE_VERT_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5377 p(0) -= wmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5378 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5379 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5380
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5381 case AXE_HORZ_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5382 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5383 break;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5384 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5385
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5386 if (zlabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5387 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5388 p = xform.untransform (p(0), p(1), p(2), true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5389 zlabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5390 zlabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5391 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5392
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5393 if (! is_empty && zlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5394 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5395 zlabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5396 zlabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5397 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5398 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5399 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5400
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5401 static bool updating_title_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5402
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5403 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5404 axes::properties::update_title_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5405 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5406 if (updating_title_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5407 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5408
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5409 text::properties& title_props
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5410 = reinterpret_cast<text::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5411 (gh_manager::get_object (get_title ()).get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5412
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5413 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5414 frame.protect_var (updating_title_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5415 updating_title_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5416
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5417 if (title_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5418 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5419 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5420
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5421 // FIXME: bbox should be stored in axes::properties
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5422 Matrix bbox = get_extent (false);
13910
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5423
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5424 ColumnVector p =
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5425 graphics_xform::xform_vector (bbox(0)+bbox(2)/2,
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5426 bbox(1)-10,
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5427 (x_zlim(0)+x_zlim(1))/2);
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5428
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5429 if (x2Dtop)
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5430 {
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5431 Matrix ext (1, 2, 0.0);
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5432 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5433 get_xticklabel ().all_strings (),
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5434 get_xlim ().matrix_value ());
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5435 p(1) -= ext(1);
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5436 }
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5437
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5438 p = xform.untransform (p(0), p(1), p(2), true);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5439
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5440 title_props.set_position (p.extract_n (0, 3).transpose ());
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5441 title_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5442 }
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5443 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5444
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5445 void
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5446 axes::properties::update_autopos (const std::string& elem_type)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5447 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5448 if (elem_type == "xlabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5449 update_xlabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5450 else if (elem_type == "ylabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5451 update_ylabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5452 else if (elem_type == "zlabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5453 update_zlabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5454 else if (elem_type == "title")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5455 update_title_position ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5456 else if (elem_type == "sync")
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5457 sync_positions ();
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5458 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5459
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5460 static void
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5461 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors,
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5462 double xlength, double ylength, double zlength)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5463 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5464 double xval = xlength/scalefactors(0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5465 double yval = ylength/scalefactors(1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5466 double zval = zlength/scalefactors(2);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5467
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5468 double minval = xmin (xmin (xval, yval), zval);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5469
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5470 aspectratios(0) = xval/minval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5471 aspectratios(1) = yval/minval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5472 aspectratios(2) = zval/minval;
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5473 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5474
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5475 static void
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5476 max_axes_scale (double& s, Matrix& limits, const Matrix& kids,
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5477 double pbfactor, double dafactor, char limit_type, bool tight)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5478 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5479 if (tight)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5480 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5481 double minval = octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5482 double maxval = -octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5483 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5484 double max_neg = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5485 get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
5486 if (xfinite (minval) && xfinite (maxval))
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5487 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5488 limits(0) = minval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5489 limits(1) = maxval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5490 s = xmax(s, (maxval - minval) / (pbfactor * dafactor));
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5491 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5492 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5493 else
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5494 s = xmax(s, (limits(1) - limits(0)) / (pbfactor * dafactor));
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5495 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5496
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5497 static bool updating_aspectratios = false;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5498
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5499 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5500 axes::properties::update_aspectratios (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5501 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5502 if (updating_aspectratios)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5503 return;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5504
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5505 Matrix xlimits = get_xlim ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5506 Matrix ylimits = get_ylim ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5507 Matrix zlimits = get_zlim ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5508
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5509 double dx = (xlimits(1)-xlimits(0));
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5510 double dy = (ylimits(1)-ylimits(0));
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5511 double dz = (zlimits(1)-zlimits(0));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5512
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5513 Matrix da = get_dataaspectratio ().matrix_value ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5514 Matrix pba = get_plotboxaspectratio ().matrix_value ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5515
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5516 if (dataaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5517 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5518 if (plotboxaspectratiomode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5519 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5520 pba = Matrix (1, 3, 1.0);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5521 plotboxaspectratio.set (pba, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5522 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5523
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5524 normalized_aspectratios (da, pba, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5525 dataaspectratio.set (da, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5526 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5527 else if (plotboxaspectratiomode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5528 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5529 normalized_aspectratios (pba, da, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5530 plotboxaspectratio.set (pba, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5531 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5532 else
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5533 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5534 double s = -octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5535 bool modified_limits = false;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5536 Matrix kids;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5537
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5538 if (xlimmode_is ("auto") && ylimmode_is ("auto") && zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5539 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5540 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5541 kids = get_children ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5542 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5543 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5544 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5545 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5546 else if (xlimmode_is ("auto") && ylimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5547 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5548 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5549 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5550 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5551 else if (ylimmode_is ("auto") && zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5552 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5553 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5554 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5555 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5556 else if (zlimmode_is ("auto") && xlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5557 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5558 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5559 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5560 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5561
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5562 if (modified_limits)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5563 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5564
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5565 unwind_protect frame;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5566 frame.protect_var (updating_aspectratios);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5567
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5568 updating_aspectratios = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5569
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5570 dx = pba(0) *da(0);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5571 dy = pba(1) *da(1);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5572 dz = pba(2) *da(2);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5573 if (xisinf (s))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5574 s = 1 / xmin (xmin (dx, dy), dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5575
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5576 if (xlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5577 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5578 dx = s * dx;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5579 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5580 xlimits(1) = xlimits(0) + dx;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5581 set_xlim (xlimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5582 set_xlimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5583 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5584
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5585 if (ylimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5586 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5587 dy = s * dy;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5588 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5589 ylimits(1) = ylimits(0) + dy;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5590 set_ylim (ylimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5591 set_ylimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5592 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5593
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5594 if (zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5595 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5596 dz = s * dz;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5597 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5598 zlimits(1) = zlimits(0) + dz;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5599 set_zlim (zlimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5600 set_zlimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5601 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5602 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5603 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5604 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5605 normalized_aspectratios (pba, da, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5606 plotboxaspectratio.set (pba, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5607 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5608 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5609 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5610
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5611 void
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5612 axes::properties::update_font (void)
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5613 {
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5614 #ifdef HAVE_FREETYPE
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5615 #ifdef HAVE_FONTCONFIG
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5616 text_renderer.set_font (get ("fontname").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5617 get ("fontweight").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5618 get ("fontangle").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5619 get ("fontsize").double_value ());
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5620 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5621 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5622 }
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5623
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
5624 // The INTERNAL flag defines whether position or outerposition is used.
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
5625
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5626 Matrix
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5627 axes::properties::get_boundingbox (bool internal,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5628 const Matrix& parent_pix_size) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5629 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5630 Matrix pos = internal ? get_position ().matrix_value ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5631 : get_outerposition ().matrix_value ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5632 Matrix parent_size (parent_pix_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5633
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5634 if (parent_size.numel () == 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5635 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5636 graphics_object obj = gh_manager::get_object (get_parent ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5637
17607
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
5638 if (obj.valid_object ())
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
5639 parent_size =
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
5640 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
5641 else
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
5642 parent_size = default_figure_position ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5643 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5644
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5645 pos = convert_position (pos, get_units (), "pixels", parent_size);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
5646
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5647 pos(0)--;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5648 pos(1)--;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5649 pos(1) = parent_size(1) - pos(1) - pos(3);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5650
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5651 return pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5652 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5653
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5654 Matrix
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5655 axes::properties::get_extent (bool with_text, bool only_text_height) const
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5656 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5657 graphics_xform xform = get_transform ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5658
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5659 Matrix ext (1, 4, 0.0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5660 ext(0) = octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5661 ext(1) = octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5662 ext(2) = -octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5663 ext(3) = -octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5664 for (int i = 0; i <= 1; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5665 for (int j = 0; j <= 1; j++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5666 for (int k = 0; k <= 1; k++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5667 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5668 ColumnVector p = xform.transform (i ? xPlaneN : xPlane,
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5669 j ? yPlaneN : yPlane,
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5670 k ? zPlaneN : zPlane, false);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5671 ext(0) = std::min (ext(0), p(0));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5672 ext(1) = std::min (ext(1), p(1));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5673 ext(2) = std::max (ext(2), p(0));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5674 ext(3) = std::max (ext(3), p(1));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5675 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5676
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5677 if (with_text)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5678 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5679 for (int i = 0; i < 4; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5680 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5681 graphics_handle text_handle;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5682 if (i == 0)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5683 text_handle = get_title ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5684 else if (i == 1)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5685 text_handle = get_xlabel ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5686 else if (i == 2)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5687 text_handle = get_ylabel ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5688 else if (i == 3)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5689 text_handle = get_zlabel ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5690
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5691 text::properties& text_props
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5692 = reinterpret_cast<text::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5693 (gh_manager::get_object (text_handle).get_properties ());
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5694
14483
6a736395ff7d fix wrong axes extents for text elements with custom units (bug #35856)
Konstantinos Poulios <logari81@googlemail.com>
parents: 14457
diff changeset
5695 Matrix text_pos = text_props.get_data_position ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5696 text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2));
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5697 if (text_props.get_string ().is_empty ())
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5698 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5699 ext(0) = std::min (ext(0), text_pos(0));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5700 ext(1) = std::min (ext(1), text_pos(1));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5701 ext(2) = std::max (ext(2), text_pos(0));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5702 ext(3) = std::max (ext(3), text_pos(1));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5703 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5704 else
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5705 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5706 Matrix text_ext = text_props.get_extent_matrix ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5707
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5708 bool ignore_horizontal = false;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5709 bool ignore_vertical = false;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5710 if (only_text_height)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5711 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
5712 double text_rotation = text_props.get_rotation ();
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5713 if (text_rotation == 0. || text_rotation == 180.)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5714 ignore_horizontal = true;
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5715 else if (text_rotation == 90. || text_rotation == 270.)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5716 ignore_vertical = true;
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5717 }
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5718
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5719 if (! ignore_horizontal)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5720 {
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5721 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5722 ext(2) = std::max (ext(2),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5723 text_pos(0)+text_ext(0)+text_ext(2));
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5724 }
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5725
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5726 if (! ignore_vertical)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5727 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5728 ext(1) = std::min (ext(1),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5729 text_pos(1)-text_ext(1)-text_ext(3));
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5730 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1));
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
5731 }
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5732 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5733 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5734 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5735
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5736 ext(2) = ext(2)-ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5737 ext(3) = ext(3)-ext(1);
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13132
diff changeset
5738
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5739 return ext;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5740 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
5741
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5742 static octave_value
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5743 convert_ticklabel_string (const octave_value& val)
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5744 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5745 octave_value retval = val;
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5746
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5747 if (val.is_cellstr ())
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5748 {
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5749 // Always return a column vector for Matlab Compatibility
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5750 if (val.columns () > 1)
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5751 retval = val.reshape (dim_vector (val.numel (), 1));
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5752 }
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5753 else
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5754 {
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5755 string_vector sv;
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5756 if (val.is_numeric_type ())
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5757 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5758 NDArray data = val.array_value ();
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5759 std::ostringstream oss;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5760 oss.precision (5);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5761 for (octave_idx_type i = 0; i < val.numel (); i++)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5762 {
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5763 oss.str ("");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5764 oss << data(i);
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5765 sv.append (oss.str ());
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5766 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5767 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5768 else if (val.is_string () && val.rows () == 1)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5769 {
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5770 std::string valstr = val.string_value ();
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5771 std::istringstream iss (valstr);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5772 std::string tmpstr;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5773
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5774 // Split string with delimiter '|'
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5775 while (std::getline (iss, tmpstr, '|'))
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5776 sv.append (tmpstr);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5777
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5778 // If string ends with '|' Matlab appends a null string
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5779 if (*valstr.rbegin () == '|')
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5780 sv.append (std::string (""));
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5781 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5782 else
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5783 return retval;
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5784
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5785 charMatrix chmat (sv, ' ');
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5786
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
5787 retval = octave_value (chmat);
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5788 }
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
5789
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5790 return retval;
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5791 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5792
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5793 void
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5794 axes::properties::set_xticklabel (const octave_value& v)
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5795 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5796 if (!error_state)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5797 {
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5798 if (xticklabel.set (convert_ticklabel_string (v), false))
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5799 {
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5800 set_xticklabelmode ("manual");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5801 xticklabel.run_listeners (POSTSET);
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5802 mark_modified ();
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5803 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5804 else
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5805 set_xticklabelmode ("manual");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5806 }
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5807 }
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5808
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5809 void
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5810 axes::properties::set_yticklabel (const octave_value& v)
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5811 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5812 if (!error_state)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5813 {
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5814 if (yticklabel.set (convert_ticklabel_string (v), false))
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5815 {
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5816 set_yticklabelmode ("manual");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5817 yticklabel.run_listeners (POSTSET);
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5818 mark_modified ();
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5819 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5820 else
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5821 set_yticklabelmode ("manual");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5822 }
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5823 }
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5824
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5825 void
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5826 axes::properties::set_zticklabel (const octave_value& v)
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5827 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5828 if (!error_state)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5829 {
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5830 if (zticklabel.set (convert_ticklabel_string (v), false))
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5831 {
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5832 set_zticklabelmode ("manual");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5833 zticklabel.run_listeners (POSTSET);
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5834 mark_modified ();
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5835 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5836 else
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5837 set_zticklabelmode ("manual");
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5838 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5839 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
5840
17382
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5841 // Almost identical to convert_ticklabel_string but it only accepts
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5842 // cellstr or string, not numeric input.
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5843 static octave_value
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5844 convert_linestyleorder_string (const octave_value& val)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5845 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5846 octave_value retval = val;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5847
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5848 if (val.is_cellstr ())
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5849 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5850 // Always return a column vector for Matlab Compatibility
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5851 if (val.columns () > 1)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5852 retval = val.reshape (dim_vector (val.numel (), 1));
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5853 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5854 else
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5855 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5856 string_vector sv;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5857 if (val.is_string () && val.rows () == 1)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5858 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5859 std::string valstr = val.string_value ();
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5860 std::istringstream iss (valstr);
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5861 std::string tmpstr;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5862
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5863 // Split string with delimiter '|'
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5864 while (std::getline (iss, tmpstr, '|'))
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5865 sv.append (tmpstr);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5866
17382
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5867 // If string ends with '|' Matlab appends a null string
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5868 if (*valstr.rbegin () == '|')
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5869 sv.append (std::string (""));
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5870 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5871 else
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5872 return retval;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5873
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5874 charMatrix chmat (sv, ' ');
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5875
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5876 retval = octave_value (chmat);
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5877 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5878
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5879 return retval;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5880 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5881
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5882 void
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5883 axes::properties::set_linestyleorder (const octave_value& v)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5884 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5885 if (!error_state)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5886 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5887 linestyleorder.set (convert_linestyleorder_string (v), false);
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5888 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5889 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
5890
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5891 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5892 axes::properties::set_units (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5893 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5894 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5895 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5896 caseless_str old_units = get_units ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5897 if (units.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5898 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5899 update_units (old_units);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5900 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5901 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5902 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5903 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5904
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5905 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5906 axes::properties::update_units (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5907 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5908 graphics_object obj = gh_manager::get_object (get_parent ());
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5909 Matrix parent_bb
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5910 = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5911 caseless_str new_units = get_units ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5912 position.set (octave_value (convert_position (get_position ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5913 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5914 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5915 false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5916 outerposition.set (octave_value (convert_position (get_outerposition ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5917 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5918 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5919 false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5920 tightinset.set (octave_value (convert_position (get_tightinset ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5921 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5922 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5923 false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5924 looseinset.set (octave_value (convert_position (get_looseinset ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5925 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5926 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5927 false);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5928 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5929
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5930 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5931 axes::properties::set_fontunits (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5932 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5933 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5934 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5935 caseless_str old_fontunits = get_fontunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5936 if (fontunits.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5937 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5938 update_fontunits (old_fontunits);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5939 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5940 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5941 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5942 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5943
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5944 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5945 axes::properties::update_fontunits (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5946 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5947 caseless_str new_units = get_fontunits ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5948 double parent_height = get_boundingbox (true).elem (3);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5949 double fsz = get_fontsize ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5950
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5951 fsz = convert_font_size (fsz, old_units, new_units, parent_height);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5952
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5953 set_fontsize (octave_value (fsz));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5954 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5955
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5956 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5957 axes::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5958 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5959 double fs = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5960 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5961
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5962 if (fontunits_is ("normalized") && parent_height <= 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5963 parent_height = get_boundingbox (true).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5964
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5965 return convert_font_size (fs, get_fontunits (), "points", parent_height);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5966 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
5967
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5968 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5969 graphics_xform::xform_vector (double x, double y, double z)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5970 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5971 return ::xform_vector (x, y, z);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5972 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5973
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5974 Matrix
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5975 graphics_xform::xform_eye (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5976 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5977 return ::xform_matrix ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5978 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5979
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5980 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5981 graphics_xform::transform (double x, double y, double z,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5982 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5983 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5984 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5985 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5986 x = sx.scale (x);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5987 y = sy.scale (y);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5988 z = sz.scale (z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5989 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5990
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5991 return ::transform (xform, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5992 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5993
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5994 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5995 graphics_xform::untransform (double x, double y, double z,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5996 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5997 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5998 ColumnVector v = ::transform (xform_inv, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5999
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6000 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6001 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6002 v(0) = sx.unscale (v(0));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6003 v(1) = sy.unscale (v(1));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6004 v(2) = sz.unscale (v(2));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6005 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6006
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6007 return v;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6008 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6009
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6010 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
6011 axes::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6012 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6013 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6014
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6015 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6016 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6017 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6018 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6019
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6020 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6021 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6022
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6023 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6024 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6025
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6026 // FIXME: remove.
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6027 // FIXME: maybe this should go into array_property class?
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6028 /*
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6029 static void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6030 check_limit_vals (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6031 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6032 const array_property& data)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6033 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6034 double val = data.min_val ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6035 if (xfinite (val) && val < min_val)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6036 min_val = val;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6037 val = data.max_val ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6038 if (xfinite (val) && val > max_val)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6039 max_val = val;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6040 val = data.min_pos ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6041 if (xfinite (val) && val > 0 && val < min_pos)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6042 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6043 val = data.max_neg ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6044 if (xfinite (val) && val < 0 && val > max_neg)
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6045 max_neg = val;
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6046 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6047 */
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6048
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6049 static void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6050 check_limit_vals (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6051 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6052 const octave_value& data)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6053 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6054 if (data.is_matrix_type ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6055 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6056 Matrix m = data.matrix_value ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6057
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6058 if (! error_state && m.numel () == 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6059 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6060 double val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6061
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6062 val = m(0);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6063 if (xfinite (val) && val < min_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6064 min_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6065
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6066 val = m(1);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6067 if (xfinite (val) && val > max_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6068 max_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6069
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6070 val = m(2);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6071 if (xfinite (val) && val > 0 && val < min_pos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6072 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6073
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6074 val = m(3);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6075 if (xfinite (val) && val < 0 && val > max_neg)
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6076 max_neg = val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6077 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6078 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6079 }
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6080
12508
919cadf334f8 Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents: 12506
diff changeset
6081 // magform(x) Returns (a, b), where x = a * 10^b, abs (a) >= 1., and b is
919cadf334f8 Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents: 12506
diff changeset
6082 // integer.
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6083
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6084 static void
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6085 magform (double x, double& a, int& b)
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6086 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6087 if (x == 0)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6088 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6089 a = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6090 b = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6091 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6092 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6093 {
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13132
diff changeset
6094 b = static_cast<int> (gnulib::floor (std::log10 (std::abs (x))));
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13132
diff changeset
6095 a = x / std::pow (10.0, b);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6096 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6097 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6098
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6099 // A translation from Tom Holoryd's python code at
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6100 // http://kurage.nimh.nih.gov/tomh/tics.py
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6101 // FIXME: add log ticks
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6102
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6103 double
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6104 axes::properties::calc_tick_sep (double lo, double hi)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6105 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6106 int ticint = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6107
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6108 // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6109 // SCALE3 for Determination of Scales on Computer Generated
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6110 // Plots", Communications of the ACM, 10 (1973), 639-640.
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6111 // Also cited as ACM Algorithm 463.
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6112
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6113 double a;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6114 int b, x;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6115
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6116 magform ((hi-lo)/ticint, a, b);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6117
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6118 static const double sqrt_2 = sqrt (2.0);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6119 static const double sqrt_10 = sqrt (10.0);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6120 static const double sqrt_50 = sqrt (50.0);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6121
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6122 if (a < sqrt_2)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6123 x = 1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6124 else if (a < sqrt_10)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6125 x = 2;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6126 else if (a < sqrt_50)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6127 x = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6128 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6129 x = 10;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6130
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6131 return x * std::pow (10., b);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6132
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6133 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6134
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6135 // Attempt to make "nice" limits from the actual max and min of the
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6136 // data. For log plots, we will also use the smallest strictly positive
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6137 // value.
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6138
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6139 Matrix
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6140 axes::properties::get_axis_limits (double xmin, double xmax,
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6141 double min_pos, double max_neg,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6142 bool logscale)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6143 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6144 Matrix retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6145
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6146 double min_val = xmin;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6147 double max_val = xmax;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6148
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6149 if (xisinf (min_val) && min_val > 0 && xisinf (max_val) && max_val < 0)
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6150 {
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6151 retval = default_lim (logscale);
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6152 return retval;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6153 }
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6154 else if (! (xisinf (min_val) || xisinf (max_val)))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6155 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6156 if (logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6157 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6158 if (xisinf (min_pos) && xisinf (max_neg))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6159 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6160 // TODO -- max_neg is needed for "loglog ([0 -Inf])"
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6161 // This is the only place where max_neg is needed.
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6162 // Is there another way?
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6163 retval = default_lim ();
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6164 retval(0) = pow (10., retval(0));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6165 retval(1) = pow (10., retval(1));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6166 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6167 }
13756
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13736
diff changeset
6168 if ((min_val <= 0 && max_val > 0))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6169 {
14062
5b49cafe0599 Use non-negative, non-positive with hyphens in error messages.
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
6170 warning ("axis: omitting non-positive data in log plot");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6171 min_val = min_pos;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6172 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6173 // FIXME: maybe this test should also be relative?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6174 if (std::abs (min_val - max_val)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6175 < sqrt (std::numeric_limits<double>::epsilon ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6176 {
14691
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6177 // Widen range when too small
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6178 if (min_val >= 0)
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6179 {
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6180 min_val *= 0.9;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6181 max_val *= 1.1;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6182 }
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6183 else
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6184 {
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6185 min_val *= 1.1;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6186 max_val *= 0.9;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6187 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6188 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6189 if (min_val > 0)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6190 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6191 // Log plots with all positive data
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6192 min_val = pow (10, gnulib::floor (log10 (min_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6193 max_val = pow (10, std::ceil (log10 (max_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6194 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6195 else
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6196 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6197 // Log plots with all negative data
13756
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13736
diff changeset
6198 min_val = -pow (10, std::ceil (log10 (-min_val)));
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13736
diff changeset
6199 max_val = -pow (10, gnulib::floor (log10 (-max_val)));
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6200 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6201 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6202 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6203 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6204 if (min_val == 0 && max_val == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6205 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6206 min_val = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6207 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6208 }
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17842
diff changeset
6209 // FIXME: maybe this test should also be relative?
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6210 else if (std::abs (min_val - max_val)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6211 < sqrt (std::numeric_limits<double>::epsilon ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6212 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6213 min_val -= 0.1 * std::abs (min_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6214 max_val += 0.1 * std::abs (max_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6215 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6216
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6217 double tick_sep = calc_tick_sep (min_val , max_val);
12549
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6218 double min_tick = gnulib::floor (min_val / tick_sep);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6219 double max_tick = std::ceil (max_val / tick_sep);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6220 // Prevent round-off from cropping ticks
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6221 min_val = std::min (min_val, tick_sep * min_tick);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6222 max_val = std::max (max_val, tick_sep * max_tick);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6223 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6224 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6225
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6226 retval.resize (1, 2);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6227
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
6228 retval(1) = max_val;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6229 retval(0) = min_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6230
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6231 return retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6232 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6233
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6234 void
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6235 axes::properties::calc_ticks_and_lims (array_property& lims,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6236 array_property& ticks,
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6237 array_property& mticks,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6238 bool limmode_is_auto, bool is_logscale)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6239 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6240 // FIXME: add log ticks and lims
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6241
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6242 if (lims.get ().is_empty ())
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6243 return;
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6244
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6245 double lo = (lims.get ().matrix_value ()) (0);
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6246 double hi = (lims.get ().matrix_value ()) (1);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6247 bool is_negative = lo < 0 && hi < 0;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6248 double tmp;
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17842
diff changeset
6249 // FIXME: should this be checked for somewhere else? (i.e. set{x,y,z}lim)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6250 if (hi < lo)
7843
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
6251 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6252 tmp = hi;
7843
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
6253 hi = lo;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
6254 lo = tmp;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
6255 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6256
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6257 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6258 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6259 if (is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6260 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6261 tmp = hi;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6262 hi = std::log10 (-lo);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6263 lo = std::log10 (-tmp);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6264 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6265 else
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6266 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6267 hi = std::log10 (hi);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6268 lo = std::log10 (lo);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6269 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6270 }
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6271
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6272 double tick_sep = calc_tick_sep (lo , hi);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6273
13106
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
6274 if (is_logscale && ! (xisinf (hi) || xisinf (lo)))
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
6275 {
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17842
diff changeset
6276 // FIXME: what if (hi-lo) < tick_sep?
13106
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
6277 // ex: loglog ([1 1.1])
13109
8e61aa0fac77 src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents: 13106
diff changeset
6278 tick_sep = std::max (tick_sep, 1.);
8e61aa0fac77 src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents: 13106
diff changeset
6279 tick_sep = std::ceil (tick_sep);
13106
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
6280 }
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
6281
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
6282 int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6283 int i2 = static_cast<int> (std::ceil (hi / tick_sep));
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6284
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6285 if (limmode_is_auto)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6286 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6287 // adjust limits to include min and max tics
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6288 Matrix tmp_lims (1,2);
12549
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6289 tmp_lims(0) = std::min (tick_sep * i1, lo);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6290 tmp_lims(1) = std::max (tick_sep * i2, hi);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6291
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6292 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6293 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6294 tmp_lims(0) = std::pow (10.,tmp_lims(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6295 tmp_lims(1) = std::pow (10.,tmp_lims(1));
10941
97294dd3ccd4 graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents: 10923
diff changeset
6296 if (tmp_lims(0) <= 0)
97294dd3ccd4 graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents: 10923
diff changeset
6297 tmp_lims(0) = std::pow (10., lo);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6298 if (is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6299 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6300 tmp = tmp_lims(0);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6301 tmp_lims(0) = -tmp_lims(1);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6302 tmp_lims(1) = -tmp;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6303 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6304 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6305 lims = tmp_lims;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6306 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6307
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6308 Matrix tmp_ticks (1, i2-i1+1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6309 for (int i = 0; i <= i2-i1; i++)
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6310 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6311 tmp_ticks (i) = tick_sep * (i+i1);
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6312 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6313 tmp_ticks (i) = std::pow (10., tmp_ticks (i));
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6314 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6315 if (is_logscale && is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6316 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6317 Matrix rev_ticks (1, i2-i1+1);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6318 rev_ticks = -tmp_ticks;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6319 for (int i = 0; i <= i2-i1; i++)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6320 tmp_ticks (i) = rev_ticks (i2-i1-i);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6321 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6322
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6323 ticks = tmp_ticks;
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6324
14321
a9a42d630bd5 use 8 minor tick marks per decade for log scale plots, not 9.
John W. Eaton <jwe@octave.org>
parents: 14312
diff changeset
6325 int n = is_logscale ? 8 : 4;
12157
0b9c1a7e350a fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents: 12126
diff changeset
6326 Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1));
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6327
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6328 for (int i = 0; i < tmp_ticks.numel ()-1; i++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6329 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6330 double d = (tmp_ticks (i+1) - tmp_ticks (i)) / (n+1);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6331 for (int j = 0; j < n; j++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6332 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6333 tmp_mticks (n*i+j) = tmp_ticks (i) + d * (j+1);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6334 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6335 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6336 mticks = tmp_mticks;
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6337 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6338
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6339 void
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6340 axes::properties::calc_ticklabels (const array_property& ticks,
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6341 any_property& labels, bool logscale)
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6342 {
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6343 Matrix values = ticks.get ().matrix_value ();
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6344 Cell c (values.dims ());
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6345 std::ostringstream os;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6346
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6347 if (logscale)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6348 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6349 double significand;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6350 double exponent;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6351 double exp_max = 0.;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6352 double exp_min = 0.;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6353
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6354 for (int i = 0; i < values.numel (); i++)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6355 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6356 exp_max = std::max (exp_max, std::log10 (values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6357 exp_min = std::max (exp_min, std::log10 (values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6358 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6359
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6360 for (int i = 0; i < values.numel (); i++)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6361 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6362 if (values(i) < 0.)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6363 exponent = gnulib::floor (std::log10 (-values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6364 else
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6365 exponent = gnulib::floor (std::log10 (values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6366 significand = values(i) * std::pow (10., -exponent);
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6367 os.str (std::string ());
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6368 os << significand;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6369 if (exponent < 0.)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6370 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6371 os << "e-";
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6372 exponent = -exponent;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6373 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6374 else
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6375 os << "e+";
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6376 if (exponent < 10. && (exp_max > 9 || exp_min < -9))
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6377 os << "0";
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6378 os << exponent;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6379 c(i) = os.str ();
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6380 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6381 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6382 else
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6383 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6384 for (int i = 0; i < values.numel (); i++)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6385 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6386 os.str (std::string ());
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6387 os << values(i);
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6388 c(i) = os.str ();
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6389 }
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6390 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6391
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6392 labels = c;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6393 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6394
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6395 Matrix
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6396 axes::properties::get_ticklabel_extents (const Matrix& ticks,
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6397 const string_vector& ticklabels,
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6398 const Matrix& limits)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6399 {
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6400 #ifndef HAVE_FREETYPE
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6401 double fontsize = get ("fontsize").double_value ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6402 #endif
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6403
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6404 Matrix ext (1, 2, 0.0);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6405 double wmax = 0., hmax = 0.;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6406 int n = std::min (ticklabels.numel (), ticks.numel ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6407 for (int i = 0; i < n; i++)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6408 {
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6409 double val = ticks(i);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6410 if (limits(0) <= val && val <= limits(1))
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6411 {
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6412 std::string label (ticklabels(i));
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6413 label.erase (0, label.find_first_not_of (" "));
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6414 label = label.substr (0, label.find_last_not_of (" ")+1);
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6415 #ifdef HAVE_FREETYPE
17269
5b088598df1d Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17260
diff changeset
6416 ext = text_renderer.get_extent (label, 0.0, "none");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6417 wmax = std::max (wmax, ext(0));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6418 hmax = std::max (hmax, ext(1));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6419 #else
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6420 // FIXME: find a better approximation
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6421 int len = label.length ();
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6422 wmax = std::max (wmax, 0.5*fontsize*len);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6423 hmax = fontsize;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6424 #endif
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6425 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6426 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6427
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6428 ext(0) = wmax;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6429 ext(1) = hmax;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6430 return ext;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6431 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6432
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6433 void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6434 get_children_limits (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6435 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6436 const Matrix& kids, char limit_type)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6437 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6438 octave_idx_type n = kids.numel ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6439
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6440 switch (limit_type)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6441 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6442 case 'x':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6443 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6444 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6445 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6446
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6447 if (obj.is_xliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6448 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6449 octave_value lim = obj.get_xlim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6450
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6451 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6452 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6453 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6454 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6455
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6456 case 'y':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6457 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6458 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6459 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6460
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6461 if (obj.is_yliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6462 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6463 octave_value lim = obj.get_ylim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6464
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6465 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6466 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6467 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6468 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6469
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6470 case 'z':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6471 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6472 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6473 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6474
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6475 if (obj.is_zliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6476 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6477 octave_value lim = obj.get_zlim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6478
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6479 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6480 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6481 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6482 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6483
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6484 case 'c':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6485 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6486 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6487 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6488
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6489 if (obj.is_climinclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6490 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6491 octave_value lim = obj.get_clim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6492
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6493 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6494 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6495 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6496 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6497
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6498 case 'a':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6499 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6500 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6501 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6502
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6503 if (obj.is_aliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6504 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6505 octave_value lim = obj.get_alim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6506
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6507 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6508 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6509 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6510 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6511
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6512 default:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6513 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6514 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6515 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6516
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6517 static bool updating_axis_limits = false;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6518
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
6519 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6520 axes::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6521 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6522 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6523 if (updating_axis_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6524 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6525
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6526 Matrix kids = Matrix (1, 1, h.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6527
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6528 double min_val = octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6529 double max_val = -octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6530 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6531 double max_neg = -octave_Inf;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6532
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6533 char update_type = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6534
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6535 Matrix limits;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6536 double val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6537
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6538 #define FIX_LIMITS \
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
6539 if (limits.numel () == 4) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6540 { \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6541 val = limits(0); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6542 if (xfinite (val)) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6543 min_val = val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6544 val = limits(1); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6545 if (xfinite (val)) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6546 max_val = val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6547 val = limits(2); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6548 if (xfinite (val)) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6549 min_pos = val; \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6550 val = limits(3); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6551 if (xfinite (val)) \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6552 max_neg = val; \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6553 } \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6554 else \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6555 { \
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
6556 limits.resize (4, 1); \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6557 limits(0) = min_val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6558 limits(1) = max_val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6559 limits(2) = min_pos; \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6560 limits(3) = max_neg; \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6561 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6562
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6563 if (axis_type == "xdata" || axis_type == "xscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6564 || axis_type == "xlimmode" || axis_type == "xliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6565 || axis_type == "xlim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6566 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6567 if (xproperties.xlimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6568 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6569 limits = xproperties.get_xlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6570 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6571
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6572 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6573
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6574 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6575 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6576 xproperties.xscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6577
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6578 update_type = 'x';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6579 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6580 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6581 else if (axis_type == "ydata" || axis_type == "yscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6582 || axis_type == "ylimmode" || axis_type == "yliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6583 || axis_type == "ylim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6584 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6585 if (xproperties.ylimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6586 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6587 limits = xproperties.get_ylim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6588 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6589
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6590 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6591
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6592 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6593 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6594 xproperties.yscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6595
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6596 update_type = 'y';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6597 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6598 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6599 else if (axis_type == "zdata" || axis_type == "zscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6600 || axis_type == "zlimmode" || axis_type == "zliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6601 || axis_type == "zlim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6602 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6603 if (xproperties.zlimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6604 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6605 limits = xproperties.get_zlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6606 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6607
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6608 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6609
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6610 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6611 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6612 xproperties.zscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6613
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6614 update_type = 'z';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6615 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6616 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6617 else if (axis_type == "cdata" || axis_type == "climmode"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6618 || axis_type == "cdatamapping" || axis_type == "climinclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6619 || axis_type == "clim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6620 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6621 if (xproperties.climmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6622 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6623 limits = xproperties.get_clim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6624 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6625
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6626 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6627
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6628 if (min_val > max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6629 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6630 min_val = min_pos = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6631 max_val = 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6632 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6633 else if (min_val == max_val)
13247
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6634 {
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6635 max_val = min_val + 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6636 min_val -= 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6637 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6638
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6639 limits.resize (1, 2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6640
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6641 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6642 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6643
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6644 update_type = 'c';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6645 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6646
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6647 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6648 else if (axis_type == "alphadata" || axis_type == "alimmode"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6649 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6650 || axis_type == "alim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6651 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6652 if (xproperties.alimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6653 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6654 limits = xproperties.get_alim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6655 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6656
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6657 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6658
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6659 if (min_val > max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6660 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6661 min_val = min_pos = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6662 max_val = 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6663 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6664 else if (min_val == max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6665 max_val = min_val + 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6666
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6667 limits.resize (1, 2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6668
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6669 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6670 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6671
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6672 update_type = 'a';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6673 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6674
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6675 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6676
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6677 #undef FIX_LIMITS
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6678
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6679 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6680 frame.protect_var (updating_axis_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6681
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6682 updating_axis_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6683
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6684 switch (update_type)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6685 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6686 case 'x':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6687 xproperties.set_xlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6688 xproperties.set_xlimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6689 xproperties.update_xlim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6690 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6691
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6692 case 'y':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6693 xproperties.set_ylim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6694 xproperties.set_ylimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6695 xproperties.update_ylim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6696 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6697
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6698 case 'z':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6699 xproperties.set_zlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6700 xproperties.set_zlimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6701 xproperties.update_zlim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6702 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6703
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6704 case 'c':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6705 xproperties.set_clim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6706 xproperties.set_climmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6707 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6708
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6709 case 'a':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6710 xproperties.set_alim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6711 xproperties.set_alimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6712 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6713
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6714 default:
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6715 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6716 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6717
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6718 xproperties.update_transform ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6719
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6720 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6721
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6722 void
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6723 axes::update_axis_limits (const std::string& axis_type)
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
6724 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6725 if (updating_axis_limits || updating_aspectratios)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6726 return;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6727
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6728 Matrix kids = xproperties.get_children ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6729
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6730 double min_val = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6731 double max_val = -octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6732 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6733 double max_neg = -octave_Inf;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6734
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6735 char update_type = 0;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6736
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6737 Matrix limits;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6738
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6739 if (axis_type == "xdata" || axis_type == "xscale"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6740 || axis_type == "xlimmode" || axis_type == "xliminclude"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6741 || axis_type == "xlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6742 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
6743 if (xproperties.xlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6744 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6745 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6746
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6747 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6748 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6749 xproperties.xscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6750
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6751 update_type = 'x';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6752 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6753 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6754 else if (axis_type == "ydata" || axis_type == "yscale"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6755 || axis_type == "ylimmode" || axis_type == "yliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6756 || axis_type == "ylim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6757 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
6758 if (xproperties.ylimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6759 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6760 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6761
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6762 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6763 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6764 xproperties.yscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6765
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6766 update_type = 'y';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6767 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6768 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6769 else if (axis_type == "zdata" || axis_type == "zscale"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6770 || axis_type == "zlimmode" || axis_type == "zliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6771 || axis_type == "zlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6772 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
6773 if (xproperties.zlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6774 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6775 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6776
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6777 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6778 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6779 xproperties.zscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6780
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6781 update_type = 'z';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6782 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6783 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6784 else if (axis_type == "cdata" || axis_type == "climmode"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6785 || axis_type == "cdatamapping" || axis_type == "climinclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6786 || axis_type == "clim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6787 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
6788 if (xproperties.climmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6789 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6790 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6791
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6792 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6793 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6794 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6795 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6796 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6797 else if (min_val == max_val)
13247
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6798 {
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6799 max_val = min_val + 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6800 min_val -= 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
6801 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6802
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6803 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6804
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6805 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6806 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6807
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6808 update_type = 'c';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6809 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6810
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6811 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6812 else if (axis_type == "alphadata" || axis_type == "alimmode"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6813 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6814 || axis_type == "alim")
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6815 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6816 if (xproperties.alimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6817 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6818 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6819
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6820 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6821 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6822 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6823 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6824 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6825 else if (min_val == max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6826 max_val = min_val + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6827
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6828 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6829
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6830 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6831 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6832
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6833 update_type = 'a';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6834 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6835
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6836 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6837
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6838 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6839 frame.protect_var (updating_axis_limits);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6840
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6841 updating_axis_limits = true;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6842
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6843 switch (update_type)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6844 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6845 case 'x':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6846 xproperties.set_xlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6847 xproperties.set_xlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6848 xproperties.update_xlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6849 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6850
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6851 case 'y':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6852 xproperties.set_ylim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6853 xproperties.set_ylimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6854 xproperties.update_ylim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6855 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6856
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6857 case 'z':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6858 xproperties.set_zlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6859 xproperties.set_zlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6860 xproperties.update_zlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6861 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6862
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6863 case 'c':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6864 xproperties.set_clim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6865 xproperties.set_climmode ("auto");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6866 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6867
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6868 case 'a':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6869 xproperties.set_alim (limits);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6870 xproperties.set_alimmode ("auto");
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6871 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6872
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6873 default:
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6874 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6875 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6876
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6877 xproperties.update_transform ();
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
6878 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
6879
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6880 inline
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6881 double force_in_range (const double x, const double lower, const double upper)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6882 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6883 if (x < lower)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6884 { return lower; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6885 else if (x > upper)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6886 { return upper; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6887 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6888 { return x; }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6889 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6890
14311
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6891 static Matrix
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6892 do_zoom (double val, double factor, const Matrix& lims, bool is_logscale)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6893 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6894 Matrix new_lims = lims;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6895
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6896 double lo = lims(0);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6897 double hi = lims(1);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6898
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6899 bool is_negative = lo < 0 && hi < 0;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6900
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6901 if (is_logscale)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6902 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6903 if (is_negative)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6904 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6905 double tmp = hi;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6906 hi = std::log10 (-lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6907 lo = std::log10 (-tmp);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6908 val = std::log10 (-val);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6909 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6910 else
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6911 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6912 hi = std::log10 (hi);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6913 lo = std::log10 (lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6914 val = std::log10 (val);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6915 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6916 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6917
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6918 // Perform the zooming
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6919 lo = val + factor * (lo - val);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6920 hi = val + factor * (hi - val);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6921
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6922 if (is_logscale)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6923 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6924 if (is_negative)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6925 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6926 double tmp = -std::pow (10.0, hi);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6927 hi = -std::pow (10.0, lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6928 lo = tmp;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6929 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6930 else
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6931 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6932 lo = std::pow (10.0, lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6933 hi = std::pow (10.0, hi);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6934 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6935 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6936
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6937 new_lims(0) = lo;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6938 new_lims(1) = hi;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6939
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6940 return new_lims;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6941 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
6942
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6943 void
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6944 axes::properties::zoom_about_point (double x, double y, double factor,
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6945 bool push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6946 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6947 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6948 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6949 Matrix ylims = get_ylim ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6950
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6951 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6952 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6953 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6954 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6955 double min_pos_x = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6956 double max_neg_x = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6957 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x');
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6958
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6959 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6960 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6961 double min_pos_y = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6962 double max_neg_y = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6963 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6964
14324
5a2b012b10c7 allow zooming for logscale plots
John W. Eaton <jwe@octave.org>
parents: 14323
diff changeset
6965 xlims = do_zoom (x, factor, xlims, xscale_is ("log"));
5a2b012b10c7 allow zooming for logscale plots
John W. Eaton <jwe@octave.org>
parents: 14323
diff changeset
6966 ylims = do_zoom (y, factor, ylims, yscale_is ("log"));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6967
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6968 zoom (xlims, ylims, push_to_zoom_stack);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6969 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6970
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6971 void
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6972 axes::properties::zoom (const Matrix& xl, const Matrix& yl,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6973 bool push_to_zoom_stack)
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6974 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6975 if (push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6976 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6977 zoom_stack.push_front (xlimmode.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6978 zoom_stack.push_front (xlim.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6979 zoom_stack.push_front (ylimmode.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6980 zoom_stack.push_front (ylim.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
6981 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6982
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6983 xlim = xl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6984 xlimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6985 ylim = yl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6986 ylimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6987
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6988 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6989 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6990 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6991 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6992
14314
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6993 static Matrix
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6994 do_translate (double x0, double x1, const Matrix& lims, bool is_logscale)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6995 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6996 Matrix new_lims = lims;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6997
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6998 double lo = lims(0);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
6999 double hi = lims(1);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7000
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7001 bool is_negative = lo < 0 && hi < 0;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7002
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7003 double delta;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7004
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7005 if (is_logscale)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7006 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7007 if (is_negative)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7008 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7009 double tmp = hi;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7010 hi = std::log10 (-lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7011 lo = std::log10 (-tmp);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7012 x0 = -x0;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7013 x1 = -x1;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7014 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7015 else
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7016 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7017 hi = std::log10 (hi);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7018 lo = std::log10 (lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7019 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7020
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7021 delta = std::log10 (x0) - std::log10 (x1);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7022 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7023 else
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7024 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7025 delta = x0 - x1;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7026 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7027
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7028 // Perform the translation
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7029 lo += delta;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7030 hi += delta;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7031
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7032 if (is_logscale)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7033 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7034 if (is_negative)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7035 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7036 double tmp = -std::pow (10.0, hi);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7037 hi = -std::pow (10.0, lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7038 lo = tmp;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7039 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7040 else
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7041 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7042 lo = std::pow (10.0, lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7043 hi = std::pow (10.0, hi);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7044 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7045 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7046
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7047 new_lims(0) = lo;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7048 new_lims(1) = hi;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7049
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7050 return new_lims;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7051 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7052
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7053 void
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7054 axes::properties::translate_view (double x0, double x1, double y0, double y1)
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7055 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7056 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7057 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7058 Matrix ylims = get_ylim ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7059
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7060 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7061 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7062 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7063 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7064 double min_pos_x = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7065 double max_neg_x = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7066 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7067
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7068 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7069 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7070 double min_pos_y = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7071 double max_neg_y = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7072 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7073
14314
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7074 xlims = do_translate (x0, x1, xlims, xscale_is ("log"));
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7075 ylims = do_translate (y0, y1, ylims, yscale_is ("log"));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7076
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7077 zoom (xlims, ylims, false);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7078 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7079
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7080 void
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7081 axes::properties::rotate_view (double delta_el, double delta_az)
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7082 {
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7083 Matrix v = get_view ().matrix_value ();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7084
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7085 v(1) += delta_el;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7086
15017
dd4ad69e4ab9 maint: Fix a few Octave coding convention violations.
Rik <rik@octave.org>
parents: 14861
diff changeset
7087 if (v(1) > 90)
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7088 v(1) = 90;
15017
dd4ad69e4ab9 maint: Fix a few Octave coding convention violations.
Rik <rik@octave.org>
parents: 14861
diff changeset
7089 if (v(1) < -90)
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7090 v(1) = -90;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7091
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7092 v(0) = fmod (v(0) - delta_az + 720,360);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7093
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7094 set_view (v);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7095 update_transform ();
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7096 }
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7097
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7098 void
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7099 axes::properties::unzoom (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7100 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7101 if (zoom_stack.size () >= 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7102 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7103 ylim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7104 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7105 ylimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7106 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7107 xlim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7108 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7109 xlimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7110 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7111
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7112 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7113 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7114 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7115 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7116 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7117
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7118 void
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7119 axes::properties::clear_zoom_stack (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7120 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7121 while (zoom_stack.size () > 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7122 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7123
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7124 unzoom ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7125 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7126
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7127 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7128 axes::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7129 {
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
7130 ::reset_default_properties (default_properties);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7131 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7132
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7133 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7134 axes::initialize (const graphics_object& go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7135 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7136 base_graphics_object::initialize (go);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7137
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7138 xinitialize (xproperties.get_title ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7139 xinitialize (xproperties.get_xlabel ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7140 xinitialize (xproperties.get_ylabel ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7141 xinitialize (xproperties.get_zlabel ());
17098
786bcce466e9 Initialize the tightinset during initialization of axes.
Ben Abbott <bpabbott@mac.com>
parents: 17081
diff changeset
7142
786bcce466e9 Initialize the tightinset during initialization of axes.
Ben Abbott <bpabbott@mac.com>
parents: 17081
diff changeset
7143 xproperties.sync_positions ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7144 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7145
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7146 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7147
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7148 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7149 line::properties::compute_xlim (void) const
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7150 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7151 Matrix m (1, 4);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7152
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7153 m(0) = xdata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7154 m(1) = xdata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7155 m(2) = xdata.min_pos ();
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7156 m(3) = xdata.max_neg ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7157
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7158 return m;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7159 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7160
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7161 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7162 line::properties::compute_ylim (void) const
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7163 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7164 Matrix m (1, 4);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7165
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7166 m(0) = ydata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7167 m(1) = ydata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7168 m(2) = ydata.min_pos ();
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7169 m(3) = ydata.max_neg ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7170
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7171 return m;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7172 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7173
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7174 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7175
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7176 Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7177 text::properties::get_data_position (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7178 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7179 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7180
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7181 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7182 pos = convert_text_position (pos, *this, get_units (), "data");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7183
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7184 return pos;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7185 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7186
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7187 Matrix
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7188 text::properties::get_extent_matrix (void) const
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7189 {
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7190 // FIXME: Should this function also add the (x,y) base position?
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7191 return extent.get ().matrix_value ();
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7192 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7193
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7194 octave_value
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7195 text::properties::get_extent (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7196 {
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7197 // FIXME: This doesn't work right for 3D plots.
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7198 // (It doesn't in Matlab either, at least not in version 6.5.)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7199 Matrix m = extent.get ().matrix_value ();
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7200 Matrix pos = get_position ().matrix_value ();
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7201 Matrix p = convert_text_position (pos, *this, get_units (), "pixels");
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7202
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7203 m(0) += p(0);
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7204 m(1) += p(1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7205
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7206 return convert_text_position (m, *this, "pixels", get_units ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7207 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7208
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7209 void
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7210 text::properties::update_font (void)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7211 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7212 #ifdef HAVE_FREETYPE
10526
660c244d3206 Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents: 10402
diff changeset
7213 #ifdef HAVE_FONTCONFIG
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7214 renderer.set_font (get ("fontname").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7215 get ("fontweight").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7216 get ("fontangle").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7217 get ("fontsize").double_value ());
10526
660c244d3206 Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents: 10402
diff changeset
7218 #endif
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7219 renderer.set_color (get_color_rgb ());
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7220 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7221 }
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7222
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7223 void
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7224 text::properties::update_text_extent (void)
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7225 {
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7226 #ifdef HAVE_FREETYPE
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7227
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7228 int halign = 0, valign = 0;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7229
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7230 if (horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7231 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7232 else if (horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7233 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7234
16206
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7235 if (verticalalignment_is ("middle"))
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7236 valign = 1;
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7237 else if (verticalalignment_is ("top"))
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7238 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7239 else if (verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7240 valign = 3;
16206
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7241 else if (verticalalignment_is ("cap"))
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7242 valign = 4;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7243
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7244 Matrix bbox;
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7245
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7246 // FIXME: string should be parsed only when modified, for efficiency
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7247
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7248 octave_value string_prop = get_string ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7249
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7250 string_vector sv = string_prop.all_strings ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7251
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7252 renderer.text_to_pixels (sv.join ("\n"), pixels, bbox,
17319
27fc61cfbc6e Use interpreter property when rendering text objects (bug #39830).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17286
diff changeset
7253 halign, valign, get_rotation (),
27fc61cfbc6e Use interpreter property when rendering text objects (bug #39830).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17286
diff changeset
7254 get_interpreter ());
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7255 /* The bbox is relative to the text's position.
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7256 We'll leave it that way, because get_position () does not return
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7257 valid results when the text is first constructed.
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7258 Conversion to proper coordinates is performed in get_extent. */
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7259 set_extent (bbox);
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7260
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7261 #endif
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
7262
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
7263 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") ||
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
7264 autopos_tag_is ("zlabel") || autopos_tag_is ("title"))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
7265 update_autopos ("sync");
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7266 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7267
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7268 void
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7269 text::properties::request_autopos (void)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7270 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7271 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") ||
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7272 autopos_tag_is ("zlabel") || autopos_tag_is ("title"))
12422
a3be83af8cfa simplifications in position updating functions for axes labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12389
diff changeset
7273 update_autopos (get_autopos_tag ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7274 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7275
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
7276 void
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7277 text::properties::update_units (void)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7278 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7279 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7280 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7281 set_xliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7282 set_yliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7283 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7284 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7285
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7286 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7287
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7288 pos = convert_text_position (pos, *this, cached_units, get_units ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7289 // FIXME: if the current axes view is 2D, then one should
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7290 // probably drop the z-component of "pos" and leave "zliminclude"
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7291 // to "off".
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7292 set_position (pos);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7293
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7294 if (units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7295 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7296 set_xliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7297 set_yliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7298 // FIXME: see above
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7299 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7300 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7301
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7302 cached_units = get_units ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7303 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7304
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7305 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7306 text::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7307 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7308 double fs = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7309 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7310
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7311 if (fontunits_is ("normalized") && parent_height <= 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7312 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7313 graphics_object go (gh_manager::get_object (get___myhandle__ ()));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7314 graphics_object ax (go.get_ancestor ("axes"));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7315
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7316 parent_height = ax.get_properties ().get_boundingbox (true).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7317 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7318
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7319 return convert_font_size (fs, get_fontunits (), "points", parent_height);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7320 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7321
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7322 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7323
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
7324 octave_value
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
7325 image::properties::get_color_data (void) const
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
7326 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
7327 return convert_cdata (*this, get_cdata (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7328 cdatamapping_is ("scaled"), 3);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
7329 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7330
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7331 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7332
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
7333 octave_value
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
7334 patch::properties::get_color_data (void) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
7335 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7336 octave_value fvc = get_facevertexcdata ();
11168
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
7337 if (fvc.is_undefined () || fvc.is_empty ())
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
7338 return Matrix ();
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
7339 else
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
7340 return convert_cdata (*this, fvc,cdatamapping_is ("scaled"), 2);
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
7341 }
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7342
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7343 // ---------------------------------------------------------------------
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7344
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7345 octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7346 surface::properties::get_color_data (void) const
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7347 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7348 return convert_cdata (*this, get_cdata (), cdatamapping_is ("scaled"), 3);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7349 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7350
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7351 inline void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7352 cross_product (double x1, double y1, double z1,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7353 double x2, double y2, double z2,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7354 double& x, double& y, double& z)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7355 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7356 x += (y1 * z2 - z1 * y2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7357 y += (z1 * x2 - x1 * z2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7358 z += (x1 * y2 - y1 * x2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7359 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7360
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7361 void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7362 surface::properties::update_normals (void)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7363 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7364 if (normalmode_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7365 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7366 Matrix x = get_xdata ().matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7367 Matrix y = get_ydata ().matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7368 Matrix z = get_zdata ().matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7369
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7370
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7371 int p = z.columns (), q = z.rows ();
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7372 int i1 = 0, i2 = 0, i3 = 0;
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7373 int j1 = 0, j2 = 0, j3 = 0;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7374
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7375 bool x_mat = (x.rows () == q);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7376 bool y_mat = (y.columns () == p);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7377
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7378 NDArray n (dim_vector (q, p, 3), 0.0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7379
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7380 for (int i = 0; i < p; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7381 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7382 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7383 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7384 i1 = i - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7385 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7386 i3 = i + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7387 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7388
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7389 for (int j = 0; j < q; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7390 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7391 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7392 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7393 j1 = j - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7394 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7395 j3 = j + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7396 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7397
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7398 double& nx = n(j, i, 0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7399 double& ny = n(j, i, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7400 double& nz = n(j, i, 2);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7401
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7402 if ((j > 0) && (i > 0))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7403 // upper left quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7404 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7405 (x(j1,i-1)-x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7406 x(j2,i-1)-x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7407 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7408
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7409 if ((j > 0) && (i < (p -1)))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7410 // upper right quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7411 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7412 (x(j1,i+1)-x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7413 x(j1,i)-x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7414 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7415
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7416 if ((j < (q - 1)) && (i > 0))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7417 // lower left quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7418 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7419 (x(j2,i-1)-x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7420 x(j3,i-1)-x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7421 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7422
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7423 if ((j < (q - 1)) && (i < (p -1)))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7424 // lower right quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7425 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7426 (x(j3,i)-x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7427 x(j3,i+1)-x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7428 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
7429
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
7430 double d = -std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7431
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7432 nx /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7433 ny /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7434 nz /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7435 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7436 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7437 vertexnormals = n;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7438 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
7439 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7440
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7441 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7442
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7443 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7444 hggroup::properties::update_limits (void) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7445 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7446 graphics_object obj = gh_manager::get_object (__myhandle__);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7447
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7448 if (obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7449 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7450 obj.update_axis_limits ("xlim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7451 obj.update_axis_limits ("ylim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7452 obj.update_axis_limits ("zlim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7453 obj.update_axis_limits ("clim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7454 obj.update_axis_limits ("alim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7455 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7456 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7457
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7458 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7459 hggroup::properties::update_limits (const graphics_handle& h) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7460 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7461 graphics_object obj = gh_manager::get_object (__myhandle__);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7462
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7463 if (obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7464 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7465 obj.update_axis_limits ("xlim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7466 obj.update_axis_limits ("ylim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7467 obj.update_axis_limits ("zlim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7468 obj.update_axis_limits ("clim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7469 obj.update_axis_limits ("alim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7470 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7471 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7472
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7473 static bool updating_hggroup_limits = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7474
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7475 void
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7476 hggroup::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7477 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7478 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7479 if (updating_hggroup_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7480 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7481
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7482 Matrix kids = Matrix (1, 1, h.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7483
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7484 double min_val = octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7485 double max_val = -octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7486 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7487 double max_neg = -octave_Inf;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7488
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7489 Matrix limits;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7490 double val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7491
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7492 char update_type = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7493
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7494 if (axis_type == "xlim" || axis_type == "xliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7495 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7496 limits = xproperties.get_xlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7497 update_type = 'x';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7498 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7499 else if (axis_type == "ylim" || axis_type == "yliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7500 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7501 limits = xproperties.get_ylim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7502 update_type = 'y';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7503 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7504 else if (axis_type == "zlim" || axis_type == "zliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7505 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7506 limits = xproperties.get_zlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7507 update_type = 'z';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7508 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7509 else if (axis_type == "clim" || axis_type == "climinclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7510 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7511 limits = xproperties.get_clim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7512 update_type = 'c';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7513 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7514 else if (axis_type == "alim" || axis_type == "aliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7515 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7516 limits = xproperties.get_alim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7517 update_type = 'a';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7518 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7519
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7520 if (limits.numel () == 4)
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7521 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7522 val = limits(0);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7523 if (xfinite (val))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7524 min_val = val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7525 val = limits(1);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7526 if (xfinite (val))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7527 max_val = val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7528 val = limits(2);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7529 if (xfinite (val))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7530 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7531 val = limits(3);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7532 if (xfinite (val))
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7533 max_neg = val;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7534 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7535 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7536 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7537 limits.resize (4,1);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7538 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7539 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7540 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7541 limits(3) = max_neg;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7542 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7543
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7544 get_children_limits (min_val, max_val, min_pos, max_neg, kids, update_type);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7545
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7546 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7547 frame.protect_var (updating_hggroup_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7548
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7549 updating_hggroup_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7550
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7551 if (limits(0) != min_val || limits(1) != max_val
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7552 || limits(2) != min_pos || limits(3) != max_neg)
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7553 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7554 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7555 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7556 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7557 limits(3) = max_neg;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7558
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7559 switch (update_type)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7560 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7561 case 'x':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7562 xproperties.set_xlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7563 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7564
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7565 case 'y':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7566 xproperties.set_ylim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7567 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7568
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7569 case 'z':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7570 xproperties.set_zlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7571 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7572
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7573 case 'c':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7574 xproperties.set_clim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7575 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7576
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7577 case 'a':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7578 xproperties.set_alim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7579 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7580
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7581 default:
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7582 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7583 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7584
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7585 base_graphics_object::update_axis_limits (axis_type, h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7586 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7587 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7588
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7589 void
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7590 hggroup::update_axis_limits (const std::string& axis_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7591 {
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7592 if (updating_hggroup_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7593 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7594
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7595 Matrix kids = xproperties.get_children ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7596
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7597 double min_val = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7598 double max_val = -octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7599 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7600 double max_neg = -octave_Inf;
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7601
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7602 char update_type = 0;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7603
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
7604 if (axis_type == "xlim" || axis_type == "xliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7605 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7606 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7607
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7608 update_type = 'x';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7609 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
7610 else if (axis_type == "ylim" || axis_type == "yliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7611 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7612 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7613
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7614 update_type = 'y';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7615 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
7616 else if (axis_type == "zlim" || axis_type == "zliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7617 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7618 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7619
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7620 update_type = 'z';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7621 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
7622 else if (axis_type == "clim" || axis_type == "climinclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7623 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7624 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7625
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7626 update_type = 'c';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7627 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
7628 else if (axis_type == "alim" || axis_type == "aliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7629 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7630 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7631
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7632 update_type = 'a';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7633 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7634
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7635 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7636 frame.protect_var (updating_hggroup_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7637
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7638 updating_hggroup_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7639
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7640 Matrix limits (1, 4, 0.0);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7641
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7642 limits(0) = min_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7643 limits(1) = max_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7644 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7645 limits(3) = max_neg;
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7646
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7647 switch (update_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7648 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7649 case 'x':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7650 xproperties.set_xlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7651 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7652
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7653 case 'y':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7654 xproperties.set_ylim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7655 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7656
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7657 case 'z':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7658 xproperties.set_zlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7659 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7660
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7661 case 'c':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7662 xproperties.set_clim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7663 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7664
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7665 case 'a':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7666 xproperties.set_alim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7667 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7668
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7669 default:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7670 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7671 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7672
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7673 base_graphics_object::update_axis_limits (axis_type);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7674 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7675
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7676 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7677
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7678 octave_value
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7679 uicontrol::properties::get_extent (void) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7680 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7681 Matrix m = extent.get ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7682
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
7683 graphics_object parent_obj =
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
7684 gh_manager::get_object (get_parent ());
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7685 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7686 parent_size = parent_bbox.extract_n (0, 2, 1, 2);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7687
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7688 return convert_position (m, "pixels", get_units (), parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7689 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7690
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7691 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7692 uicontrol::properties::update_text_extent (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7693 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7694 #ifdef HAVE_FREETYPE
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7695
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7696 text_element *elt;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7697 ft_render text_renderer;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7698 Matrix box;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7699
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7700 // FIXME: parsed content should be cached for efficiency
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7701 // FIXME: support multiline text
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
7702
17269
5b088598df1d Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17260
diff changeset
7703 elt = text_parser::parse (get_string_string (), "none");
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7704 #ifdef HAVE_FONTCONFIG
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7705 text_renderer.set_font (get_fontname (),
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7706 get_fontweight (),
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7707 get_fontangle (),
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7708 get_fontsize ());
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7709 #endif
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7710 box = text_renderer.get_extent (elt, 0);
17192
755ec7bce733 corefcn/graphics.cc: Fix memory leak in uicontrol::properties::update_text_extent.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17150
diff changeset
7711 delete elt;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7712
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7713 Matrix ext (1, 4, 0.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7714
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7715 // FIXME: also handle left and bottom components
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7716
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7717 ext(0) = ext(1) = 1;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7718 ext(2) = box(0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7719 ext(3) = box(1);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7720
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7721 set_extent (ext);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7722
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7723 #endif
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7724 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7725
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7726 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7727 uicontrol::properties::update_units (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7728 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7729 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7730
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
7731 graphics_object parent_obj = gh_manager::get_object (get_parent ());
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7732 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7733 parent_size = parent_bbox.extract_n (0, 2, 1, 2);
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
7734
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7735 pos = convert_position (pos, cached_units, get_units (), parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7736 set_position (pos);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7737
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7738 cached_units = get_units ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7739 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7740
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7741 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7742 uicontrol::properties::set_style (const octave_value& st)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7743 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7744 if (get___object__ ().is_empty ())
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7745 style = st;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7746 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7747 error ("set: cannot change the style of a uicontrol object after creation.");
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7748 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7749
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7750 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7751 uicontrol::properties::get_boundingbox (bool,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7752 const Matrix& parent_pix_size) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7753 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7754 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7755 Matrix parent_size (parent_pix_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7756
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7757 if (parent_size.numel () == 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7758 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7759 graphics_object obj = gh_manager::get_object (get_parent ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7760
17608
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
7761 if (obj.valid_object ())
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
7762 parent_size =
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
7763 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
7764 else
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
7765 parent_size = default_figure_position ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7766 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7767
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7768 pos = convert_position (pos, get_units (), "pixels", parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7769
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7770 pos(0)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7771 pos(1)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7772 pos(1) = parent_size(1) - pos(1) - pos(3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7773
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7774 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7775 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7776
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7777 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7778 uicontrol::properties::set_fontunits (const octave_value& v)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7779 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7780 if (! error_state)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7781 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7782 caseless_str old_fontunits = get_fontunits ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7783 if (fontunits.set (v, true))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7784 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7785 update_fontunits (old_fontunits);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7786 mark_modified ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7787 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7788 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7789 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7790
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7791 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7792 uicontrol::properties::update_fontunits (const caseless_str& old_units)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7793 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7794 caseless_str new_units = get_fontunits ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7795 double parent_height = get_boundingbox (false).elem (3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7796 double fsz = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7797
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7798 fsz = convert_font_size (fsz, old_units, new_units, parent_height);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7799
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7800 fontsize.set (octave_value (fsz), true);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7801 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7802
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7803 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7804 uicontrol::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7805 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7806 double fs = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7807 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7808
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7809 if (fontunits_is ("normalized") && parent_height <= 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7810 parent_height = get_boundingbox (false).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7811
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7812 return convert_font_size (fs, get_fontunits (), "points", parent_height);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7813 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7814
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7815 // ---------------------------------------------------------------------
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7816
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7817 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7818 uipanel::properties::get_boundingbox (bool internal,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7819 const Matrix& parent_pix_size) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7820 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7821 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7822 Matrix parent_size (parent_pix_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7823
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7824 if (parent_size.numel () == 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7825 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7826 graphics_object obj = gh_manager::get_object (get_parent ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7827
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7828 parent_size =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7829 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7830 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7831
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7832 pos = convert_position (pos, get_units (), "pixels", parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7833
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7834 pos(0)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7835 pos(1)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7836 pos(1) = parent_size(1) - pos(1) - pos(3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7837
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7838 if (internal)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7839 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7840 double outer_height = pos(3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7841
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7842 pos(0) = pos(1) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7843
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7844 if (! bordertype_is ("none"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7845 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7846 double bw = get_borderwidth ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7847 double mul = 1.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7848
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7849 if (bordertype_is ("etchedin") || bordertype_is ("etchedout"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7850 mul = 2.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7851
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7852 pos(0) += mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7853 pos(1) += mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7854 pos(2) -= 2 * mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7855 pos(3) -= 2 * mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7856 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7857
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7858 if (! get_title ().empty ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7859 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7860 double fs = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7861
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7862 if (! fontunits_is ("pixels"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7863 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7864 double res = xget (0, "screenpixelsperinch").double_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7865
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7866 if (fontunits_is ("points"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7867 fs *= (res / 72.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7868 else if (fontunits_is ("inches"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7869 fs *= res;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7870 else if (fontunits_is ("centimeters"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7871 fs *= (res / 2.54);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7872 else if (fontunits_is ("normalized"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7873 fs *= outer_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7874 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7875
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7876 if (titleposition_is ("lefttop") || titleposition_is ("centertop")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7877 || titleposition_is ("righttop"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7878 pos(1) += (fs / 2);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7879 pos(3) -= (fs / 2);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7880 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7881 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7882
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7883 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7884 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7885
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7886 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7887 uipanel::properties::set_units (const octave_value& v)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7888 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7889 if (! error_state)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7890 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7891 caseless_str old_units = get_units ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7892 if (units.set (v, true))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7893 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7894 update_units (old_units);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7895 mark_modified ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7896 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7897 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7898 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7899
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7900 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7901 uipanel::properties::update_units (const caseless_str& old_units)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7902 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7903 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7904
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
7905 graphics_object parent_obj = gh_manager::get_object (get_parent ());
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7906 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7907 parent_size = parent_bbox.extract_n (0, 2, 1, 2);
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
7908
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7909 pos = convert_position (pos, old_units, get_units (), parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7910 set_position (pos);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7911 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7912
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7913 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7914 uipanel::properties::set_fontunits (const octave_value& v)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7915 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7916 if (! error_state)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7917 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7918 caseless_str old_fontunits = get_fontunits ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7919 if (fontunits.set (v, true))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7920 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7921 update_fontunits (old_fontunits);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7922 mark_modified ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7923 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7924 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7925 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7926
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7927 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7928 uipanel::properties::update_fontunits (const caseless_str& old_units)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7929 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7930 caseless_str new_units = get_fontunits ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7931 double parent_height = get_boundingbox (false).elem (3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7932 double fsz = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7933
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7934 fsz = convert_font_size (fsz, old_units, new_units, parent_height);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7935
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7936 set_fontsize (octave_value (fsz));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7937 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7938
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7939 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7940 uipanel::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7941 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7942 double fs = get_fontsize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7943 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7944
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7945 if (fontunits_is ("normalized") && parent_height <= 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7946 parent_height = get_boundingbox (false).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7947
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7948 return convert_font_size (fs, get_fontunits (), "points", parent_height);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7949 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7950
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7951 // ---------------------------------------------------------------------
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7952
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7953 octave_value
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7954 uitoolbar::get_default (const caseless_str& name) const
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7955 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7956 octave_value retval = default_properties.lookup (name);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7957
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7958 if (retval.is_undefined ())
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7959 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7960 graphics_handle parent = get_parent ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7961 graphics_object parent_obj = gh_manager::get_object (parent);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7962
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7963 retval = parent_obj.get_default (name);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7964 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7965
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7966 return retval;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7967 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7968
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7969 void
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7970 uitoolbar::reset_default_properties (void)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7971 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7972 ::reset_default_properties (default_properties);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7973 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7974
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7975 // ---------------------------------------------------------------------
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7976
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
7977 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
7978 base_graphics_object::get_default (const caseless_str& name) const
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7979 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7980 graphics_handle parent = get_parent ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7981 graphics_object parent_obj = gh_manager::get_object (parent);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7982
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7983 return parent_obj.get_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7984 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7985
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7986 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
7987 base_graphics_object::get_factory_default (const caseless_str& name) const
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7988 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7989 graphics_object parent_obj = gh_manager::get_object (0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7990
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7991 return parent_obj.get_factory_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7992 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7993
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
7994 // We use a random value for the handle to avoid issues with plots and
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
7995 // scalar values for the first argument.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7996 gh_manager::gh_manager (void)
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
7997 : handle_map (), handle_free_list (),
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
7998 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)),
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7999 figure_list (), graphics_lock (), event_queue (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8000 callback_objects (), event_processing (0)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8001 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8002 handle_map[0] = graphics_object (new root_figure ());
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
8003
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
8004 // Make sure the default graphics toolkit is registered.
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
8005 gtk_manager::default_toolkit ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8006 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8007
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8008 void
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8009 gh_manager::create_instance (void)
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8010 {
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8011 instance = new gh_manager ();
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8012
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
8013 if (instance)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
8014 singleton_cleanup_list::add (cleanup_instance);
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8015 }
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
8016
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8017 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8018 gh_manager::do_make_graphics_handle (const std::string& go_name,
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
8019 const graphics_handle& p,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
8020 bool integer_figure_handle,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
8021 bool do_createfcn,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8022 bool do_notify_toolkit)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8023 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
8024 graphics_handle h = get_handle (integer_figure_handle);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8025
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8026 base_graphics_object *go = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8027
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8028 go = make_graphics_object_from_type (go_name, h, p);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8029
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8030 if (go)
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
8031 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
8032 graphics_object obj (go);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
8033
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
8034 handle_map[h] = obj;
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
8035 if (do_createfcn)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
8036 go->get_properties ().execute_createfcn ();
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
8037
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
8038 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8039 if (do_notify_toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8040 obj.initialize ();
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
8041 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8042 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
8043 error ("gh_manager::do_make_graphics_handle: invalid object type '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8044 go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8045
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8046 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8047 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8048
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8049 graphics_handle
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8050 gh_manager::do_make_figure_handle (double val, bool do_notify_toolkit)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8051 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8052 graphics_handle h = val;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8053
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
8054 base_graphics_object* go = new figure (h, 0);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
8055 graphics_object obj (go);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
8056
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
8057 handle_map[h] = obj;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
8058
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
8059 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8060 if (do_notify_toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8061 obj.initialize ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8062
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8063 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8064 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8065
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8066 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8067 gh_manager::do_push_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8068 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8069 do_pop_figure (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8070
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8071 figure_list.push_front (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8072 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8073
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8074 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8075 gh_manager::do_pop_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8076 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8077 for (figure_list_iterator p = figure_list.begin ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8078 p != figure_list.end ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8079 p++)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8080 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8081 if (*p == h)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8082 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8083 figure_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8084 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8085 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8086 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8087 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8088
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8089 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8090 callback_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8091 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8092 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8093 callback_event (const graphics_handle& h, const std::string& name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8094 const octave_value& data = Matrix ())
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8095 : base_graphics_event (), handle (h), callback_name (name),
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8096 callback (), callback_data (data) { }
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
8097
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8098 callback_event (const graphics_handle& h, const octave_value& cb,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8099 const octave_value& data = Matrix ())
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8100 : base_graphics_event (), handle (h), callback_name (),
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8101 callback (cb), callback_data (data) { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8102
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8103 void execute (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8104 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8105 if (callback.is_defined ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8106 gh_manager::execute_callback (handle, callback, callback_data);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8107 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8108 gh_manager::execute_callback (handle, callback_name, callback_data);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8109 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8110
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8111 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8112 callback_event (void)
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8113 : base_graphics_event (), handle (), callback_name (), callback_data ()
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8114 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8115
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8116 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8117 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8118 std::string callback_name;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8119 octave_value callback;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8120 octave_value callback_data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8121 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8122
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8123 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8124 function_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8125 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8126 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8127 function_event (graphics_event::event_fcn fcn, void* data = 0)
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8128 : base_graphics_event (), function (fcn), function_data (data)
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8129 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8130
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8131 void execute (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8132 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8133 function (function_data);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8134 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8135
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8136 private:
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
8137
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8138 graphics_event::event_fcn function;
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8139
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8140 void* function_data;
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8141
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8142 // function_event objects must be created with at least a function.
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8143 function_event (void);
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8144
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8145 // No copying!
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8146
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8147 function_event (const function_event &);
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8148
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8149 function_event & operator = (const function_event &);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8150 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8151
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8152 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8153 set_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8154 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8155 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8156 set_event (const graphics_handle& h, const std::string& name,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8157 const octave_value& value, bool do_notify_toolkit = true)
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8158 : base_graphics_event (), handle (h), property_name (name),
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
8159 property_value (value), notify_toolkit (do_notify_toolkit) { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8160
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8161 void execute (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8162 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8163 gh_manager::auto_lock guard;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8164
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8165 graphics_object go = gh_manager::get_object (handle);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8166
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8167 if (go)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8168 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8169 property p = go.get_properties ().get_property (property_name);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8170
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8171 if (p.ok ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8172 p.set (property_value, true, notify_toolkit);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8173 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8174 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8175
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8176 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8177 set_event (void)
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
8178 : base_graphics_event (), handle (), property_name (), property_value ()
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8179 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8180
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8181 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8182 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8183 std::string property_name;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8184 octave_value property_value;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8185 bool notify_toolkit;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8186 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8187
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8188 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8189 graphics_event::create_callback_event (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8190 const std::string& name,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8191 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8192 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8193 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8194
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8195 e.rep = new callback_event (h, name, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8196
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8197 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8198 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8199
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8200 graphics_event
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8201 graphics_event::create_callback_event (const graphics_handle& h,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8202 const octave_value& cb,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8203 const octave_value& data)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8204 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8205 graphics_event e;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8206
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8207 e.rep = new callback_event (h, cb, data);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8208
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8209 return e;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8210 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8211
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8212 graphics_event
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8213 graphics_event::create_function_event (graphics_event::event_fcn fcn,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8214 void *data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8215 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8216 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8217
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8218 e.rep = new function_event (fcn, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8219
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8220 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8221 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8222
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8223 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8224 graphics_event::create_set_event (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8225 const std::string& name,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8226 const octave_value& data,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8227 bool notify_toolkit)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8228 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8229 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8230
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8231 e.rep = new set_event (h, name, data, notify_toolkit);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8232
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8233 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8234 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8235
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8236 static void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8237 xset_gcbo (const graphics_handle& h)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8238 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8239 graphics_object go = gh_manager::get_object (0);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8240 root_figure::properties& props =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8241 dynamic_cast<root_figure::properties&> (go.get_properties ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8242
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8243 props.set_callbackobject (h.as_octave_value ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8244 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8245
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8246 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8247 gh_manager::do_restore_gcbo (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8248 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8249 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8250
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8251 callback_objects.pop_front ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8252
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8253 xset_gcbo (callback_objects.empty ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8254 ? graphics_handle ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8255 : callback_objects.front ().get_handle ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8256 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8257
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8258 void
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8259 gh_manager::do_execute_listener (const graphics_handle& h,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8260 const octave_value& l)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8261 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8262 if (octave_thread::is_octave_thread ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8263 gh_manager::execute_callback (h, l, octave_value ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8264 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8265 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8266 gh_manager::auto_lock guard;
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
8267
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8268 do_post_event (graphics_event::create_callback_event (h, l));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8269 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8270 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8271
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8272 void
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8273 gh_manager::do_execute_callback (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8274 const octave_value& cb_arg,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8275 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8276 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8277 if (cb_arg.is_defined () && ! cb_arg.is_empty ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8278 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8279 octave_value_list args;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8280 octave_function *fcn = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8282 args(0) = h.as_octave_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8283 if (data.is_defined ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8284 args(1) = data;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8285 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8286 args(1) = Matrix ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8287
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8288 unwind_protect_safe frame;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8289 frame.add_fcn (gh_manager::restore_gcbo);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8290
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8291 if (true)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8292 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8293 gh_manager::auto_lock guard;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8294
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8295 callback_objects.push_front (get_object (h));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8296 xset_gcbo (h);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8297 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8298
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8299 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8300
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8301 // Copy CB because "function_value" method is non-const.
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8302
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8303 octave_value cb = cb_arg;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8304
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
8305 if (cb.is_function () || cb.is_function_handle ())
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8306 fcn = cb.function_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8307 else if (cb.is_string ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8308 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8309 int status;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8310 std::string s = cb.string_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8311
13940
bf209050014f Use nargout = 0 in graphics callbacks specified as string.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13935
diff changeset
8312 eval_string (s, false, status, 0);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8313 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8314 else if (cb.is_cell () && cb.length () > 0
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8315 && (cb.rows () == 1 || cb.columns () == 1)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
8316 && (cb.cell_value ()(0).is_function ()
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
8317 || cb.cell_value ()(0).is_function_handle ()))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8318 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8319 Cell c = cb.cell_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8320
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8321 fcn = c(0).function_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8322 if (! error_state)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8323 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8324 for (int i = 1; i < c.length () ; i++)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8325 args(1+i) = c(i);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8326 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8327 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8328 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8329 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8330 std::string nm = cb.class_name ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8331 error ("trying to execute non-executable object (class = %s)",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8332 nm.c_str ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8333 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8334
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8335 if (fcn && ! error_state)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8336 feval (fcn, args);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8337
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8338 END_INTERRUPT_WITH_EXCEPTIONS;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8339 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8340 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8341
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8342 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8343 gh_manager::do_post_event (const graphics_event& e)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8344 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8345 event_queue.push_back (e);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8346
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8347 command_editor::add_event_hook (gh_manager::process_events);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8348 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8349
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8350 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8351 gh_manager::do_post_callback (const graphics_handle& h, const std::string name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8352 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8353 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8354 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8355
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8356 graphics_object go = get_object (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8357
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8358 if (go.valid_object ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8359 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8360 if (callback_objects.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8361 do_post_event (graphics_event::create_callback_event (h, name, data));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8362 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8363 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8364 const graphics_object& current = callback_objects.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8365
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8366 if (current.get_properties ().is_interruptible ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8367 do_post_event (graphics_event::create_callback_event (h, name,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8368 data));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8369 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8370 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8371 caseless_str busy_action (go.get_properties ().get_busyaction ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8372
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8373 if (busy_action.compare ("queue"))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8374 do_post_event (graphics_event::create_callback_event (h, name,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8375 data));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8376 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8377 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8378 caseless_str cname (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8379
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8380 if (cname.compare ("deletefcn") || cname.compare ("createfcn")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8381 || (go.isa ("figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8382 && (cname.compare ("closerequestfcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8383 || cname.compare ("resizefcn"))))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8384 do_post_event (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8385 graphics_event::create_callback_event (h, name, data));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8386 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8387 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8388 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8389 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8390 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8391
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8392 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8393 gh_manager::do_post_function (graphics_event::event_fcn fcn, void* fcn_data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8394 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8395 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8396
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8397 do_post_event (graphics_event::create_function_event (fcn, fcn_data));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8398 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8399
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8400 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8401 gh_manager::do_post_set (const graphics_handle& h, const std::string name,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8402 const octave_value& value, bool notify_toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8403 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8404 gh_manager::auto_lock guard;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8405
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8406 do_post_event (graphics_event::create_set_event (h, name, value,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8407 notify_toolkit));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8408 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8409
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8410 int
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8411 gh_manager::do_process_events (bool force)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8412 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
8413 graphics_event e;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8414 bool old_Vdrawnow_requested = Vdrawnow_requested;
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8415 bool events_executed = false;
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8416
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8417 do
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8418 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8419 e = graphics_event ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8420
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8421 gh_manager::lock ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8422
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8423 if (! event_queue.empty ())
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8424 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8425 if (callback_objects.empty () || force)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8426 {
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8427 e = event_queue.front ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8428
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8429 event_queue.pop_front ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8430 }
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8431 else
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8432 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8433 const graphics_object& go = callback_objects.front ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8434
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8435 if (go.get_properties ().is_interruptible ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8436 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8437 e = event_queue.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8438
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8439 event_queue.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8440 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8441 }
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8442 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8443
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8444 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8445
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8446 if (e.ok ())
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8447 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8448 e.execute ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8449 events_executed = true;
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8450 }
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8451 }
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8452 while (e.ok ());
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8453
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8454 gh_manager::lock ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8455
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8456 if (event_queue.empty () && event_processing == 0)
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8457 command_editor::remove_event_hook (gh_manager::process_events);
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8458
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8459 gh_manager::unlock ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8460
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8461 if (events_executed)
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8462 flush_octave_stdout ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8463
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8464 if (Vdrawnow_requested && ! old_Vdrawnow_requested)
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8465 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
8466 Fdrawnow ();
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8467
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
8468 Vdrawnow_requested = false;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8469 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8470
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8471 return 0;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8472 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8473
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
8474 void
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8475 gh_manager::do_enable_event_processing (bool enable)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8476 {
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
8477 gh_manager::auto_lock guard;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8478
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8479 if (enable)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8480 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8481 event_processing++;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8482
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8483 command_editor::add_event_hook (gh_manager::process_events);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8484 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8485 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8486 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8487 event_processing--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8488
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8489 if (event_queue.empty () && event_processing == 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8490 command_editor::remove_event_hook (gh_manager::process_events);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8491 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8492 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8493
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8494 property_list::plist_map_type
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8495 root_figure::init_factory_properties (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8496 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8497 property_list::plist_map_type plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8498
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8499 plist_map["figure"] = figure::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8500 plist_map["axes"] = axes::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8501 plist_map["line"] = line::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8502 plist_map["text"] = text::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8503 plist_map["image"] = image::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8504 plist_map["patch"] = patch::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
8505 plist_map["surface"] = surface::properties::factory_defaults ();
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8506 plist_map["hggroup"] = hggroup::properties::factory_defaults ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
8507 plist_map["uimenu"] = uimenu::properties::factory_defaults ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8508 plist_map["uicontrol"] = uicontrol::properties::factory_defaults ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8509 plist_map["uipanel"] = uipanel::properties::factory_defaults ();
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8510 plist_map["uicontextmenu"] = uicontextmenu::properties::factory_defaults ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8511 plist_map["uitoolbar"] = uitoolbar::properties::factory_defaults ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8512 plist_map["uipushtool"] = uipushtool::properties::factory_defaults ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8513 plist_map["uitoggletool"] = uitoggletool::properties::factory_defaults ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8514
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8515 return plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8516 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8517
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8518 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8519
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8520 DEFUN (ishandle, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8521 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
8522 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8523 Return true if @var{h} is a graphics handle and false otherwise.\n\
17123
bcada0a4f8a7 isaxes.m: New function to determine if object is axes handle.
Rik <rik@octave.org>
parents: 17098
diff changeset
8524 \n\
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
8525 @var{h} may also be a matrix of handles in which case a logical\n\
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
8526 array is returned that is true where the elements of @var{h} are\n\
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
8527 graphics handles and false where they are not.\n\
17123
bcada0a4f8a7 isaxes.m: New function to determine if object is axes handle.
Rik <rik@octave.org>
parents: 17098
diff changeset
8528 @seealso{isaxes, isfigure}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8529 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8530 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8531 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8532
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8533 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8534
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8535 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8536 retval = is_handle (args(0));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8537 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8538 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8539
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8540 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8541 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8542
13327
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8543 static bool
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8544 is_handle_visible (const graphics_handle& h)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8545 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8546 return h.ok () && gh_manager::is_handle_visible (h);
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8547 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8548
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8549 static bool
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8550 is_handle_visible (double val)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8551 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8552 return is_handle_visible (gh_manager::lookup (val));
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8553 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8554
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8555 static octave_value
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8556 is_handle_visible (const octave_value& val)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8557 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8558 octave_value retval = false;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8559
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8560 if (val.is_real_scalar () && is_handle_visible (val.double_value ()))
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8561 retval = true;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8562 else if (val.is_numeric_type () && val.is_real_type ())
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8563 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8564 const NDArray handles = val.array_value ();
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8565
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8566 if (! error_state)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8567 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8568 boolNDArray result (handles.dims ());
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8569
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8570 for (octave_idx_type i = 0; i < handles.numel (); i++)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8571 result.xelem (i) = is_handle_visible (handles (i));
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8572
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8573 retval = result;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8574 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8575 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8576
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8577 return retval;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8578 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8579
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8580 DEFUN (__is_handle_visible__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8581 "-*- texinfo -*-\n\
13327
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8582 @deftypefn {Built-in Function} __is_handle_visible__ (@var{h})\n\
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8583 Undocumented internal function.\n\
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8584 @end deftypefn")
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8585 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8586 octave_value retval;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8587
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8588 if (args.length () == 1)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8589 retval = is_handle_visible (args(0));
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8590 else
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8591 print_usage ();
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8592
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8593 return retval;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8594 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
8595
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8596 DEFUN (reset, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8597 "-*- texinfo -*-\n\
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8598 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
8599 Remove any defaults set for the handle @var{h}. The default figure\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17269
diff changeset
8600 properties of @qcode{\"position\"}, @qcode{\"units\"},\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17269
diff changeset
8601 @qcode{\"windowstyle\"} and @qcode{\"paperunits\"} and the default axes\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17269
diff changeset
8602 properties of @qcode{\"position\"} and @qcode{\"units\"} are not reset.\n\
17443
0aa77acf22f5 doc: Add seealso references between cla, clf, reset functions.
Rik <rik@octave.org>
parents: 17382
diff changeset
8603 @seealso{cla, clf}\n\
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8604 @end deftypefn")
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8605 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8606 int nargin = args.length ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8607
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8608 if (nargin != 1)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8609 print_usage ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8610 else
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8611 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8612 // get vector of graphics handles
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8613 ColumnVector hcv (args(0).vector_value ());
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8614
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8615 if (! error_state)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8616 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8617 // loop over graphics objects
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8618 for (octave_idx_type n = 0; n < hcv.length (); n++)
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8619 gh_manager::get_object (hcv(n)).reset_default_properties ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8620 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8621 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8622
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8623 return octave_value ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8624 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
8625
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8626 DEFUN (set, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8627 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8628 @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8629 @deftypefnx {Built-in Function} {} set (@var{h}, @var{properties}, @var{values})\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8630 @deftypefnx {Built-in Function} {} set (@var{h}, @var{pv})\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8631 Set named property values for the graphics handle (or vector of graphics\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8632 handles) @var{h}.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8633 There are three ways how to give the property names and values:\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8634 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8635 @itemize\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8636 @item as a comma separated list of @var{property}, @var{value} pairs\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8637 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8638 Here, each @var{property} is a string containing the property name, each\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8639 @var{value} is a value of the appropriate type for the property.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8640 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8641 @item as a cell array of strings @var{properties} containing property names\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8642 and a cell array @var{values} containing property values.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8643 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8644 In this case, the number of columns of @var{values} must match the number of\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
8645 elements in @var{properties}. The first column of @var{values} contains\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
8646 values for the first entry in @var{properties}, etc. The number of rows of\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
8647 @var{values} must be 1 or match the number of elements of @var{h}. In the\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
8648 first case, each handle in @var{h} will be assigned the same values. In the\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
8649 latter case, the first handle in @var{h} will be assigned the values from\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
8650 the first row of @var{values} and so on.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8651 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8652 @item as a structure array @var{pv}\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8653 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8654 Here, the field names of @var{pv} represent the property names, and the field\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8655 values give the property values. In contrast to the previous case, all\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8656 elements of @var{pv} will be set in all handles in @var{h} independent of\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8657 the dimensions of @var{pv}.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8658 @end itemize\n\
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8659 @seealso{get}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8660 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8661 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8662 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8663
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8664 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8665
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8666 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8667
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8668 if (nargin > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8669 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8670 // get vector of graphics handles
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8671 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8672
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8673 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8674 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8675 bool request_drawnow = false;
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
8676
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8677 // loop over graphics objects
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8678 for (octave_idx_type n = 0; n < hcv.length (); n++)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8679 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8680 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8681
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8682 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8683 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8684 if (nargin == 3 && args(1).is_cellstr ()
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8685 && args(2).is_cell ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8686 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8687 if (args(2).cell_value ().rows () == 1)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8688 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8689 obj.set (args(1).cellstr_value (),
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8690 args(2).cell_value (), 0);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8691 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8692 else if (hcv.length () == args(2).cell_value ().rows ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8693 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8694 obj.set (args(1).cellstr_value (),
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8695 args(2).cell_value (), n);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8696 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8697 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8698 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
8699 error ("set: number of graphics handles must match number of value rows (%d != %d)",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8700 hcv.length (), args(2).cell_value ().rows ());
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8701 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8702
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8703 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8704 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8705 else if (nargin == 2 && args(1).is_map ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8706 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8707 obj.set (args(1).map_value ());
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8708 }
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8709 else if (nargin == 1)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8710 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8711 if (nargout != 0)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8712 retval = obj.values_as_struct ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8713 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8714 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8715 std::string s = obj.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8716 if (! error_state)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8717 octave_stdout << s;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8718 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
8719 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8720 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8721 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8722 obj.set (args.splice (0, 1));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8723 request_drawnow = true;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8724 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8725 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8726 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8727 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8728 error ("set: invalid handle (= %g)", hcv(n));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8729 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8730 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8731
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8732 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8733 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8734
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
8735 request_drawnow = true;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8736 }
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
8737
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8738 if (! error_state && request_drawnow)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8739 Vdrawnow_requested = true;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8740 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8741 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8742 error ("set: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8743 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8744 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8745 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8746
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8747 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8748 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8749
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8750 static std::string
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8751 get_graphics_object_type (const double val)
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8752 {
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8753 std::string retval;
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8754
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8755 graphics_object obj = gh_manager::get_object (val);
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8756
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8757 if (obj)
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8758 retval = obj.type ();
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8759 else
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8760 error ("get: invalid handle (= %g)", val);
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8761
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8762 return retval;
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8763 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8764
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8765 DEFUN (get, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8766 "-*- texinfo -*-\n\
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8767 @deftypefn {Built-in Function} {@var{val} =} get (@var{h})\n\
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8768 @deftypefnx {Built-in Function} {@var{val} =} get (@var{h}, @var{p})\n\
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8769 Return the value of the named property @var{p} from the graphics handle\n\
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8770 @var{h}. If @var{p} is omitted, return the complete property list for\n\
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8771 @var{h}. If @var{h} is a vector, return a cell array including the property\n\
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8772 values or lists respectively.\n\
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
8773 @seealso{set}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8774 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8775 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8776 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8777
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8778 octave_value retval;
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8779
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8780 Cell vals;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8781
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8782 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8783
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8784 bool use_cell_format = false;
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8785
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8786 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8787 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
8788 if (args(0).is_empty ())
12678
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
8789 {
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
8790 retval = Matrix ();
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
8791 return retval;
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
8792 }
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
8793
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8794 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8795
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8796 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8797 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8798 octave_idx_type len = hcv.length ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8799
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8800 if (nargin == 1 && len > 1)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8801 {
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8802 std::string t0 = get_graphics_object_type (hcv(0));
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8803
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8804 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8805 {
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8806 for (octave_idx_type n = 1; n < len; n++)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8807 {
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8808 std::string t = get_graphics_object_type (hcv(n));
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8809
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8810 if (error_state)
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8811 break;
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8812
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8813 if (t != t0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8814 {
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8815 error ("get: vector of handles must all have same type");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8816 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8817 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8818 }
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8819
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8820 }
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8821 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8822
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8823 if (! error_state)
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8824 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8825 if (nargin > 1 && args(1).is_cellstr ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8826 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8827 Array<std::string> plist = args(1).cellstr_value ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8828
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8829 if (! error_state)
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8830 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8831 octave_idx_type plen = plist.numel ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8832
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8833 use_cell_format = true;
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8834
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8835 vals.resize (dim_vector (len, plen));
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8836
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8837 for (octave_idx_type n = 0; ! error_state && n < len; n++)
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8838 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8839 graphics_object obj = gh_manager::get_object (hcv(n));
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8840
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8841 if (obj)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8842 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8843 for (octave_idx_type m = 0;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8844 ! error_state && m < plen;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8845 m++)
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8846 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8847 caseless_str property = plist(m);
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8848
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8849 vals(n, m) = obj.get (property);
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8850 }
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8851 }
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8852 else
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8853 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8854 error ("get: invalid handle (= %g)", hcv(n));
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8855 break;
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8856 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8857 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8858 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8859 else
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8860 error ("get: expecting property name or cell array of property names as second argument");
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8861 }
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8862 else
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8863 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8864 caseless_str property;
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8865
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8866 if (nargin > 1)
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8867 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8868 property = args(1).string_value ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8869
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8870 if (error_state)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8871 error ("get: expecting property name or cell array of property names as second argument");
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8872 }
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8873
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8874 vals.resize (dim_vector (len, 1));
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8875
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8876 if (! error_state)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8877 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8878 for (octave_idx_type n = 0; ! error_state && n < len; n++)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8879 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8880 graphics_object obj = gh_manager::get_object (hcv(n));
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8881
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8882 if (obj)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8883 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8884 if (nargin == 1)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8885 vals(n) = obj.get ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8886 else
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8887 vals(n) = obj.get (property);
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8888 }
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8889 else
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8890 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8891 error ("get: invalid handle (= %g)", hcv(n));
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8892 break;
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8893 }
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8894 }
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
8895 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8896 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8897 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8898 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8899 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8900 error ("get: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8901 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8902 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8903 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8904
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
8905 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8906 {
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8907 if (use_cell_format)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8908 retval = vals;
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
8909 else
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8910 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8911 octave_idx_type len = vals.numel ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8912
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8913 if (len == 0)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8914 retval = Matrix ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8915 else if (len == 1)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8916 retval = vals(0);
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8917 else if (len > 1 && nargin == 1)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8918 {
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8919 OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len);
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8920
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8921 for (octave_idx_type n = 0; n < len; n++)
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8922 tmp[n] = vals(n).scalar_map_value ();
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8923
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8924 retval = octave_map::cat (0, len, tmp);
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8925 }
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8926 else
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8927 retval = vals;
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
8928 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8929 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
8930
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8931 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8932 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8933
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
8934 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
8935 %!assert (get (findobj (0, "Tag", "nonexistenttag"), "nonexistentproperty"), [])
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
8936 */
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
8937
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
8938 // Return all properties from the graphics handle @var{h}.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
8939 // If @var{h} is a vector, return a cell array including the
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
8940 // property values or lists respectively.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
8941
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8942 DEFUN (__get__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8943 "-*- texinfo -*-\n\
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8944 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
8945 Undocumented internal function.\n\
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8946 @end deftypefn")
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8947 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8948 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8949
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8950 octave_value retval;
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8951
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8952 Cell vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8953
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8954 int nargin = args.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8955
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8956 if (nargin == 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8957 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8958 ColumnVector hcv (args(0).vector_value ());
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8959
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8960 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8961 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8962 octave_idx_type len = hcv.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8963
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8964 vals.resize (dim_vector (len, 1));
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8965
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8966 for (octave_idx_type n = 0; n < len; n++)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8967 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8968 graphics_object obj = gh_manager::get_object (hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8969
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8970 if (obj)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8971 vals(n) = obj.get (true);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8972 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8973 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8974 error ("get: invalid handle (= %g)", hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8975 break;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8976 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8977 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8978 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8979 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8980 error ("get: expecting graphics handle as first argument");
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8981 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8982 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8983 print_usage ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8984
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8985 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8986 {
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8987 octave_idx_type len = vals.numel ();
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8988
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8989 if (len > 1)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8990 retval = vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8991 else if (len == 1)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
8992 retval = vals(0);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8993 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8994
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8995 return retval;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8996 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
8997
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8998 static octave_value
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8999 make_graphics_object (const std::string& go_name,
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9000 bool integer_figure_handle,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9001 const octave_value_list& args)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9002 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9003 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9004
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9005 double val = octave_NaN;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9006
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9007 octave_value_list xargs = args.splice (0, 1);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9008
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9009 caseless_str p ("parent");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9010
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9011 for (int i = 0; i < xargs.length (); i++)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9012 if (xargs(i).is_string ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9013 && p.compare (xargs(i).string_value ()))
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9014 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9015 if (i < (xargs.length () - 1))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9016 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9017 val = xargs(i+1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9018
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9019 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9020 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9021 xargs = xargs.splice (i, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9022 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9023 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9024 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9025 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9026 error ("__go_%s__: missing value for parent property",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9027 go_name.c_str ());
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9028 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9029
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9030 if (! error_state && xisnan (val))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9031 val = args(0).double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9032
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9033 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9034 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9035 graphics_handle parent = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9036
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
9037 if (parent.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9038 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9039 graphics_handle h
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9040 = gh_manager::make_graphics_handle (go_name, parent,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9041 integer_figure_handle,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9042 false, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9043
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9044 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9045 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9046 adopt (parent, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9047
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9048 xset (h, xargs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9049 xcreatefcn (h);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9050 xinitialize (h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9051
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9052 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9053
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9054 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9055 Vdrawnow_requested = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9056 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9057 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9058 error ("__go%s__: unable to create graphics handle",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9059 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9060 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9061 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9062 error ("__go_%s__: invalid parent", go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9063 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9064 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9065 error ("__go_%s__: invalid parent", go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9066
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9067 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9068 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9069
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9070 DEFUN (__go_figure__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9071 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9072 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9073 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9074 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9075 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9076 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9077
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9078 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9079
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9080 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9081 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9082 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9083
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9084 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9085 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9086 if (is_figure (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9087 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9088 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9089
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9090 xset (h, args.splice (0, 1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9091
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9092 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9093 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9094 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9095 {
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9096 bool int_fig_handle = true;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9097
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9098 octave_value_list xargs = args.splice (0, 1);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9099
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9100 graphics_handle h = octave_NaN;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9101
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9102 if (xisnan (val))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9103 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9104 caseless_str p ("integerhandle");
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9105
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9106 for (int i = 0; i < xargs.length (); i++)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9107 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9108 if (xargs(i).is_string ()
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9109 && p.compare (xargs(i).string_value ()))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9110 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9111 if (i < (xargs.length () - 1))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9112 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9113 std::string pval = xargs(i+1).string_value ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9114
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9115 if (! error_state)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9116 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9117 caseless_str on ("on");
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9118 int_fig_handle = on.compare (pval);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9119 xargs = xargs.splice (i, 2);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9120 break;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9121 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9122 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9123 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9124 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9125
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9126 h = gh_manager::make_graphics_handle ("figure", 0,
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9127 int_fig_handle,
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9128 false, false);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9129
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9130 if (! int_fig_handle)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9131 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9132 // We need to intiailize the integerhandle
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9133 // property without calling the set_integerhandle
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9134 // method, because doing that will generate a new
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9135 // handle value...
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9136
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9137 graphics_object go = gh_manager::get_object (h);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9138 go.get_properties ().init_integerhandle ("off");
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9139 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9140 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9141 else if (val > 0 && D_NINT (val) == val)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9142 h = gh_manager::make_figure_handle (val, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9143
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9144 if (! error_state && h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9145 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9146 adopt (0, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9147
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9148 gh_manager::push_figure (h);
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9149
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
9150 xset (h, xargs);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9151 xcreatefcn (h);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9152 xinitialize (h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9153
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9154 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9155 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9156 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9157 error ("__go_figure__: failed to create figure handle");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9158 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9159 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9160 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9161 error ("__go_figure__: expecting figure number to be double value");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9162 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9163 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9164 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9165
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9166 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9167 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9168
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9169 #define GO_BODY(TYPE) \
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9170 gh_manager::auto_lock guard; \
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9171 \
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9172 octave_value retval; \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9173 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9174 if (args.length () > 0) \
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9175 retval = make_graphics_object (#TYPE, false, args); \
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9176 else \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9177 print_usage (); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9178 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9179 return retval
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9180
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9181 int
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9182 calc_dimensions (const graphics_object& go)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9183 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9184
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9185 int nd = 2;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9186
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9187 if (go.isa ("surface"))
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9188 nd = 3;
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9189 else if ((go.isa ("line") || go.isa ("patch"))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9190 && ! go.get ("zdata").is_empty ())
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9191 nd = 3;
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9192 else
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9193 {
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9194 Matrix kids = go.get_properties ().get_children ();
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9195
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9196 for (octave_idx_type i = 0; i < kids.length (); i++)
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9197 {
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9198 graphics_handle hnd = gh_manager::lookup (kids(i));
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9199
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9200 if (hnd.ok ())
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9201 {
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9202 const graphics_object& kid = gh_manager::get_object (hnd);
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9203
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9204 if (kid.valid_object ())
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9205 nd = calc_dimensions (kid);
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9206
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9207 if (nd == 3)
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9208 break;
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9209 }
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9210 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9211 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9212
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9213 return nd;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9214 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9215
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9216 DEFUN (__calc_dimensions__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9217 "-*- texinfo -*-\n\
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9218 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
9219 Internal function. Determine the number of dimensions in a graphics\n\
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9220 object, whether 2 or 3.\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9221 @end deftypefn")
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9222 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9223 gh_manager::auto_lock guard;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9224
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9225 octave_value retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9226
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9227 int nargin = args.length ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9228
18806
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9229 if (nargin == 1)
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9230 {
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9231 double h = args(0).double_value ();
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9232 if (! error_state)
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9233 retval = calc_dimensions (gh_manager::get_object (h));
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9234 else
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9235 error ("__calc_dimensions__: expecting graphics handle as only argument");
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9236 }
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
9237 else
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9238 print_usage ();
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
9239
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9240 return retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9241 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
9242
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9243 DEFUN (__go_axes__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9244 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9245 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9246 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9247 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9248 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9249 GO_BODY (axes);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9250 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9251
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9252 DEFUN (__go_line__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9253 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9254 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9255 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9256 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9257 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9258 GO_BODY (line);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9259 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9260
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9261 DEFUN (__go_text__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9262 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9263 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9264 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9265 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9266 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9267 GO_BODY (text);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9268 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9269
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9270 DEFUN (__go_image__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9271 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9272 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9273 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9274 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9275 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9276 GO_BODY (image);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9277 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9278
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9279 DEFUN (__go_surface__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9280 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9281 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9282 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9283 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9284 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9285 GO_BODY (surface);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9286 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9287
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9288 DEFUN (__go_patch__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9289 "-*- texinfo -*-\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9290 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9291 Undocumented internal function.\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9292 @end deftypefn")
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9293 {
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9294 GO_BODY (patch);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9295 }
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
9296
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9297 DEFUN (__go_hggroup__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9298 "-*- texinfo -*-\n\
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9299 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9300 Undocumented internal function.\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9301 @end deftypefn")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9302 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9303 GO_BODY (hggroup);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9304 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9305
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9306 DEFUN (__go_uimenu__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9307 "-*- texinfo -*-\n\
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9308 @deftypefn {Built-in Function} {} __go_uimenu__ (@var{parent})\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9309 Undocumented internal function.\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9310 @end deftypefn")
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9311 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9312 GO_BODY (uimenu);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9313 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9314
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9315 DEFUN (__go_uicontrol__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9316 "-*- texinfo -*-\n\
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9317 @deftypefn {Built-in Function} {} __go_uicontrol__ (@var{parent})\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9318 Undocumented internal function.\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9319 @end deftypefn")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9320 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9321 GO_BODY (uicontrol);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9322 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9323
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9324 DEFUN (__go_uipanel__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9325 "-*- texinfo -*-\n\
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9326 @deftypefn {Built-in Function} {} __go_uipanel__ (@var{parent})\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9327 Undocumented internal function.\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9328 @end deftypefn")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9329 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9330 GO_BODY (uipanel);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9331 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9332
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9333 DEFUN (__go_uicontextmenu__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9334 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9335 @deftypefn {Built-in Function} {} __go_uicontextmenu__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9336 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9337 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9338 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9339 GO_BODY (uicontextmenu);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9340 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9341
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9342 DEFUN (__go_uitoolbar__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9343 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9344 @deftypefn {Built-in Function} {} __go_uitoolbar__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9345 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9346 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9347 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9348 GO_BODY (uitoolbar);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9349 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9350
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9351 DEFUN (__go_uipushtool__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9352 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9353 @deftypefn {Built-in Function} {} __go_uipushtool__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9354 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9355 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9356 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9357 GO_BODY (uipushtool);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9358 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9359
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9360 DEFUN (__go_uitoggletool__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9361 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9362 @deftypefn {Built-in Function} {} __go_uitoggletool__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9363 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9364 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9365 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9366 GO_BODY (uitoggletool);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9367 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9368
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9369 DEFUN (__go_delete__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9370 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9371 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9372 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9373 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9374 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9375 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9376
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9377 octave_value_list retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9378
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9379 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9380 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9381 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9382
8196
32e9e8103390 Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents: 8183
diff changeset
9383 const NDArray vals = args (0).array_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9384
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9385 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9386 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9387 // Check is all the handles to delete are valid first
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9388 // as callbacks might delete one of the handles we
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9389 // later want to delete
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9390 for (octave_idx_type i = 0; i < vals.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9391 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9392 h = gh_manager::lookup (vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9393
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9394 if (! h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9395 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
9396 error ("delete: invalid graphics object (= %g)",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9397 vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9398 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9399 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9400 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9401
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9402 if (! error_state)
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
9403 delete_graphics_objects (vals);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9404 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9405 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9406 error ("delete: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9407 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9408 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9409 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9410
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9411 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9412 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9413
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9414 DEFUN (__go_axes_init__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9415 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9416 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9417 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9418 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9419 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9420 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9421
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9422 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9423
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9424 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9425
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9426 std::string mode = "";
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9427
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9428 if (nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9429 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9430 mode = args(1).string_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9431
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9432 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9433 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9434 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9435
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9436 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9437 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9438 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9439
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9440 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9441
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9442 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9443 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9444 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9445
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9446 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9447 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9448 graphics_object obj = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9449
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9450 obj.set_defaults (mode);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9451
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9452 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9453 if (! h.ok ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9454 error ("__go_axes_init__: axis deleted during initialization (= %g)",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9455 val);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9456 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9457 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9458 error ("__go_axes_init__: invalid graphics object (= %g)", val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9459 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9460 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9461 error ("__go_axes_init__: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9462 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9463 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9464 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9465
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9466 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9467 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9468
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9469 DEFUN (__go_handles__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9470 "-*- texinfo -*-\n\
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9471 @deftypefn {Built-in Function} {} __go_handles__ (@var{show_hidden})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9472 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9473 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9474 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9475 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9476
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9477 bool show_hidden = false;
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9478
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9479 if (args.length () > 0)
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9480 show_hidden = args(0).bool_value ();
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9481
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9482 return octave_value (gh_manager::handle_list (show_hidden));
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9483 }
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9484
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9485 DEFUN (__go_figure_handles__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9486 "-*- texinfo -*-\n\
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9487 @deftypefn {Built-in Function} {} __go_figure_handles__ (@var{show_hidden})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
9488 Undocumented internal function.\n\
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
9489 @end deftypefn")
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
9490 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9491 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9492
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9493 bool show_hidden = false;
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9494
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9495 if (args.length () > 0)
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9496 show_hidden = args(0).bool_value ();
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9497
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9498 return octave_value (gh_manager::figure_handle_list (show_hidden));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9499 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9500
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9501 DEFUN (__go_execute_callback__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9502 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
9503 @deftypefn {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name})\n\
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9504 @deftypefnx {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name}, @var{param})\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9505 Undocumented internal function.\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9506 @end deftypefn")
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9507 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9508 octave_value retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9509
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9510 int nargin = args.length ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9511
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9512 if (nargin == 2 || nargin == 3)
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9513 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9514 double val = args(0).double_value ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9515
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9516 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9517 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9518 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9519
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9520 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9521 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9522 std::string name = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9523
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9524 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9525 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9526 if (nargin == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9527 gh_manager::execute_callback (h, name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9528 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9529 gh_manager::execute_callback (h, name, args(2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9530 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9531 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9532 error ("__go_execute_callback__: invalid callback name");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9533 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9534 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9535 error ("__go_execute_callback__: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9536 val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9537 }
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9538 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9539 error ("__go_execute_callback__: invalid graphics object");
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9540 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9541 else
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9542 print_usage ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9543
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9544 return retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9545 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
9546
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9547 DEFUN (__image_pixel_size__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9548 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
9549 @deftypefn {Built-in Function} {@var{px}, @var{py}} __image_pixel_size__ (@var{h})\n\
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9550 Internal function: returns the pixel size of the image in normalized units.\n\
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9551 @end deftypefn")
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9552 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9553 octave_value retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9554
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9555 int nargin = args.length ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9556
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9557 if (nargin == 1)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9558 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9559 double h = args(0).double_value ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9560
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9561 if (! error_state)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9562 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9563 graphics_object fobj = gh_manager::get_object (h);
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9564 if (fobj && fobj.isa ("image"))
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9565 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9566 image::properties& ip =
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9567 dynamic_cast<image::properties&> (fobj.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
9568
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9569 Matrix dp = Matrix (1, 2, 0);
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9570 dp(0, 0) = ip.pixel_xsize ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9571 dp(0, 1) = ip.pixel_ysize ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9572 retval = dp;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9573 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9574 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9575 error ("__image_pixel_size__: object is not an image");
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9576 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9577 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9578 error ("__image_pixel_size__: argument is not a handle");
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9579 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9580 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9581 print_usage ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9582
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9583 return retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9584 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
9585
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9586 gtk_manager *gtk_manager::instance = 0;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9587
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9588 void
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9589 gtk_manager::create_instance (void)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9590 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9591 instance = new gtk_manager ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9592
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9593 if (instance)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9594 singleton_cleanup_list::add (cleanup_instance);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9595 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9596
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9597 graphics_toolkit
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9598 gtk_manager::do_get_toolkit (void) const
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9599 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9600 graphics_toolkit retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9601
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9602 const_loaded_toolkits_iterator pl = loaded_toolkits.find (dtk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9603
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9604 if (pl == loaded_toolkits.end ())
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9605 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9606 const_available_toolkits_iterator pa = available_toolkits.find (dtk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9607
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9608 if (pa != available_toolkits.end ())
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9609 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9610 octave_value_list args;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9611 args(0) = dtk;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9612 feval ("graphics_toolkit", args);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9613
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9614 if (! error_state)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9615 pl = loaded_toolkits.find (dtk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9616
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9617 if (error_state || pl == loaded_toolkits.end ())
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9618 error ("failed to load %s graphics toolkit", dtk.c_str ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9619 else
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9620 retval = pl->second;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9621 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9622 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
9623 error ("default graphics toolkit '%s' is not available!",
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9624 dtk.c_str ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9625 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9626 else
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9627 retval = pl->second;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9628
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9629 return retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9630 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9631
19629
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19628
diff changeset
9632 void
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9633 gtk_manager::do_register_toolkit (const std::string& name)
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9634 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9635 if (dtk.empty () || name == "qt"
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9636 || (name == "fltk"
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9637 && available_toolkits.find ("qt") == available_toolkits.end ()))
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9638 dtk = name;
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9639
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9640 available_toolkits.insert (name);
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9641 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9642
19629
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19628
diff changeset
9643 void
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9644 gtk_manager::do_unregister_toolkit (const std::string& name)
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9645 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9646 available_toolkits.erase (name);
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9647
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9648 if (dtk == name)
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9649 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9650 if (available_toolkits.empty ())
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9651 dtk.clear ();
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9652 else
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9653 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9654 const_available_toolkits_iterator pa = available_toolkits.begin ();
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9655
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9656 dtk = *pa++;
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9657
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9658 while (pa != available_toolkits.end ())
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9659 {
19408
27f5d1607b84 avoid shadowed variable warning
John W. Eaton <jwe@octave.org>
parents: 18814
diff changeset
9660 std::string toolkit = *pa++;
27f5d1607b84 avoid shadowed variable warning
John W. Eaton <jwe@octave.org>
parents: 18814
diff changeset
9661
27f5d1607b84 avoid shadowed variable warning
John W. Eaton <jwe@octave.org>
parents: 18814
diff changeset
9662 if (toolkit == "qt"
27f5d1607b84 avoid shadowed variable warning
John W. Eaton <jwe@octave.org>
parents: 18814
diff changeset
9663 || (toolkit == "fltk"
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9664 && available_toolkits.find ("qt") == available_toolkits.end ()))
19408
27f5d1607b84 avoid shadowed variable warning
John W. Eaton <jwe@octave.org>
parents: 18814
diff changeset
9665 dtk = toolkit;
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9666 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9667 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9668 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9669 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9670
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
9671 DEFUN (available_graphics_toolkits, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9672 "-*- texinfo -*-\n\
12215
4ae2a74ed04c Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12189
diff changeset
9673 @deftypefn {Built-in Function} {} available_graphics_toolkits ()\n\
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
9674 Return a cell array of registered graphics toolkits.\n\
14134
84f38aeb9f0e doc: Add register_graphics_toolkit() and loaded_graphics_toolkits() to documentation
Rik <octave@nomad.inbox5.com>
parents: 14062
diff changeset
9675 @seealso{graphics_toolkit, register_graphics_toolkit}\n\
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
9676 @end deftypefn")
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
9677 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9678 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9679
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9680 return octave_value (gtk_manager::available_toolkits_list ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9681 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9682
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9683 DEFUN (register_graphics_toolkit, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9684 "-*- texinfo -*-\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9685 @deftypefn {Built-in Function} {} register_graphics_toolkit (@var{toolkit})\n\
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9686 List @var{toolkit} as an available graphics toolkit.\n\
14134
84f38aeb9f0e doc: Add register_graphics_toolkit() and loaded_graphics_toolkits() to documentation
Rik <octave@nomad.inbox5.com>
parents: 14062
diff changeset
9687 @seealso{available_graphics_toolkits}\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9688 @end deftypefn")
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9689 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9690 octave_value retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9691
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9692 gh_manager::auto_lock guard;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9693
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9694 if (args.length () == 1)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9695 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9696 std::string name = args(0).string_value ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9697
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9698 if (! error_state)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9699 gtk_manager::register_toolkit (name);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9700 else
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9701 error ("register_graphics_toolkit: expecting character string");
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9702 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9703 else
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9704 print_usage ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9705
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9706 return retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9707 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9708
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9709 DEFUN (loaded_graphics_toolkits, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9710 "-*- texinfo -*-\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9711 @deftypefn {Built-in Function} {} loaded_graphics_toolkits ()\n\
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9712 Return a cell array of the currently loaded graphics toolkits.\n\
14134
84f38aeb9f0e doc: Add register_graphics_toolkit() and loaded_graphics_toolkits() to documentation
Rik <octave@nomad.inbox5.com>
parents: 14062
diff changeset
9713 @seealso{available_graphics_toolkits}\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9714 @end deftypefn")
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9715 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9716 gh_manager::auto_lock guard;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9717
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9718 return octave_value (gtk_manager::loaded_toolkits_list ());
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
9719 }
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
9720
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9721 DEFUN (drawnow, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9722 "-*- texinfo -*-\n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9723 @deftypefn {Built-in Function} {} drawnow ()\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9724 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9725 @deftypefnx {Built-in Function} {} drawnow (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9726 Update figure windows and their children. The event queue is flushed and\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9727 any callbacks generated are executed. With the optional argument\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17269
diff changeset
9728 @qcode{\"expose\"}, only graphic objects are updated and no other events or\n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9729 callbacks are processed.\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9730 The third calling form of @code{drawnow} is for debugging and is\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
9731 undocumented.\n\
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9732 @end deftypefn")
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9733 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9734 static int drawnow_executing = 0;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9735
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9736 octave_value retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9737
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9738 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9739
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
9740 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
9741 frame.protect_var (Vdrawnow_requested, false);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
9742
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
9743 frame.protect_var (drawnow_executing);
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
9744
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
9745 if (++drawnow_executing <= 1)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9746 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9747 if (args.length () == 0 || args.length () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9748 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9749 Matrix hlist = gh_manager::figure_handle_list (true);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9750
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9751 for (int i = 0; ! error_state && i < hlist.length (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9752 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9753 graphics_handle h = gh_manager::lookup (hlist(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9754
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9755 if (h.ok () && h != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9756 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9757 graphics_object go = gh_manager::get_object (h);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9758 figure::properties& fprops
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9759 = dynamic_cast <figure::properties&> (go.get_properties ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9760
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9761 if (fprops.is_modified ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9762 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9763 if (fprops.is_visible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9764 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9765 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9766
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
9767 fprops.get_toolkit ().redraw_figure (go);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9768
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9769 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9770 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9771
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9772 fprops.set_modified (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9773 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9774 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9775 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9776
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9777 bool do_events = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9778
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9779 if (args.length () == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9780 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9781 caseless_str val (args(0).string_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9782
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9783 if (! error_state && val.compare ("expose"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9784 do_events = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9785 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9786 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
9787 error ("drawnow: invalid argument, expected 'expose' as argument");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9788 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9789 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9790 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9791
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9792 if (do_events)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9793 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9794 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9795
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9796 gh_manager::process_events ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9797
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9798 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9799 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9800 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
9801 else if (args.length () >= 2 && args.length () <= 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9802 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9803 std::string term, file, debug_file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9804 bool mono;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9805
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9806 term = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9807
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9808 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9809 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9810 file = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9811
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9812 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9813 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9814 size_t pos = file.find_first_not_of ("|");
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9815 if (pos > 0)
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9816 file = file.substr (pos);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9817 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9818 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9819 pos = file.find_last_of (file_ops::dir_sep_chars ());
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9820
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9821 if (pos != std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9822 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9823 std::string dirname = file.substr (0, pos+1);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9824
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9825 file_stat fs (dirname);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9826
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9827 if (! (fs && fs.is_dir ()))
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9828 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
9829 error ("drawnow: nonexistent directory '%s'",
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9830 dirname.c_str ());
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9831
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9832 return retval;
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
9833 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9834 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9835 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9836
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9837 mono = (args.length () >= 3 ? args(2).bool_value () : false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9838
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9839 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9840 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9841 debug_file = (args.length () > 3 ? args(3).string_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9842 : "");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9843
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9844 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9845 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9846 graphics_handle h = gcf ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9847
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9848 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9849 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9850 graphics_object go = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9851
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9852 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9853
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9854 go.get_toolkit ().print_figure (go, term, file,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9855 mono, debug_file);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9856
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9857 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9858 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9859 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9860 error ("drawnow: nothing to draw");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9861 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9862 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
9863 error ("drawnow: invalid DEBUG_FILE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9864 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9865 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
9866 error ("drawnow: invalid colormode MONO, expected a boolean value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9867 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9868 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
9869 error ("drawnow: invalid FILE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9870 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9871 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
9872 error ("drawnow: invalid terminal TERM, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9873 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9874 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9875 print_usage ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9876 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
9877
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9878 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9879
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9880 return retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9881 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
9882
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
9883 DEFUN (addlistener, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9884 "-*- texinfo -*-\n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
9885 @deftypefn {Built-in Function} {} addlistener (@var{h}, @var{prop}, @var{fcn})\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9886 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9887 object @var{h}. Property listeners are executed (in order of registration)\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9888 when the property is set. The new value is already available when the\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9889 listeners are executed.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9890 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9891 @var{prop} must be a string naming a valid property in @var{h}.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9892 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9893 @var{fcn} can be a function handle, a string or a cell array whose first\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9894 element is a function handle. If @var{fcn} is a function handle, the\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9895 corresponding function should accept at least 2 arguments, that will be\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9896 set to the object handle and the empty matrix respectively. If @var{fcn}\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9897 is a string, it must be any valid octave expression. If @var{fcn} is a cell\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9898 array, the first element must be a function handle with the same signature\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9899 as described above. The next elements of the cell array are passed\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9900 as additional arguments to the function.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9901 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
9902 Example:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
9903 \n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9904 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
9905 @group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9906 function my_listener (h, dummy, p1)\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9907 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9908 endfunction\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9909 \n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
9910 addlistener (gcf, \"position\", @{@@my_listener, \"my string\"@})\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
9911 @end group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9912 @end example\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9913 \n\
17486
b4343603f7ab doc: Add seealso links between hggroup, addproperty, addlistener.
Rik <rik@octave.org>
parents: 17483
diff changeset
9914 @seealso{addproperty, hggroup}\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9915 @end deftypefn")
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9916 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9917 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9918
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9919 octave_value retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9920
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9921 if (args.length () >= 3 && args.length () <= 4)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9922 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9923 double h = args(0).double_value ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9924
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9925 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9926 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9927 std::string pname = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9928
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9929 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9930 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9931 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9932
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9933 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9934 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9935 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9936
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9937 go.add_property_listener (pname, args(2), POSTSET);
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9938
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9939 if (args.length () == 4)
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9940 {
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9941 caseless_str persistent = args(3).string_value ();
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9942 if (persistent.compare ("persistent"))
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9943 go.add_property_listener (pname, args(2), PERSISTENT);
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
9944 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9945 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9946 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9947 error ("addlistener: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9948 h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9949 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9950 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9951 error ("addlistener: invalid property name, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9952 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9953 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9954 error ("addlistener: invalid handle");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9955 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9956 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9957 print_usage ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9958
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9959 return retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9960 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
9961
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9962 DEFUN (dellistener, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9963 "-*- texinfo -*-\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9964 @deftypefn {Built-in Function} {} dellistener (@var{h}, @var{prop}, @var{fcn})\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9965 Remove the registration of @var{fcn} as a listener for the property\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
9966 @var{prop} of the graphics object @var{h}. The function @var{fcn} must\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9967 be the same variable (not just the same value), as was passed to the\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9968 original call to @code{addlistener}.\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9969 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9970 If @var{fcn} is not defined then all listener functions of @var{prop}\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9971 are removed.\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9972 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9973 Example:\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9974 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9975 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
9976 @group\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9977 function my_listener (h, dummy, p1)\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9978 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9979 endfunction\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9980 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9981 c = @{@@my_listener, \"my string\"@};\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9982 addlistener (gcf, \"position\", c);\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9983 dellistener (gcf, \"position\", c);\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
9984 @end group\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9985 @end example\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9986 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9987 @end deftypefn")
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9988 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9989 gh_manager::auto_lock guard;
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9990
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9991 octave_value retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9992
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9993 if (args.length () == 3 || args.length () == 2)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9994 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9995 double h = args(0).double_value ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9996
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
9997 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9998 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9999 std::string pname = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10000
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10001 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10002 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10003 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10004
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10005 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10006 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10007 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10008
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10009 if (args.length () == 2)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10010 go.delete_property_listener (pname, octave_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10011 POSTSET);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10012 else
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10013 {
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10014 caseless_str persistent = args(2).string_value ();
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10015 if (persistent.compare ("persistent"))
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10016 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10017 go.delete_property_listener (pname, octave_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10018 PERSISTENT);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10019 go.delete_property_listener (pname, octave_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10020 POSTSET);
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10021 }
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10022 else
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10023 go.delete_property_listener (pname, args(2), POSTSET);
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
10024 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10025 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10026 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10027 error ("dellistener: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10028 h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10029 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10030 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10031 error ("dellistener: invalid property name, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10032 }
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10033 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10034 error ("dellistener: invalid handle");
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10035 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10036 else
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10037 print_usage ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10038
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10039 return retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10040 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
10041
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10042 DEFUN (addproperty, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10043 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
10044 @deftypefn {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type})\n\
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
10045 @deftypefnx {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type}, @var{arg}, @dots{})\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10046 Create a new property named @var{name} in graphics object @var{h}.\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10047 @var{type} determines the type of the property to create. @var{args}\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10048 usually contains the default value of the property, but additional\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10049 arguments might be given, depending on the type of the property.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10050 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10051 The supported property types are:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10052 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10053 @table @code\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10054 @item string\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10055 A string property. @var{arg} contains the default string value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10056 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10057 @item any\n\
16826
a4969508008e doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents: 16814
diff changeset
10058 An @nospell{un-typed} property. This kind of property can hold any octave\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10059 value. @var{args} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10060 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10061 @item radio\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10062 A string property with a limited set of accepted values. The first\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10063 argument must be a string with all accepted values separated by\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10064 a vertical bar ('|'). The default value can be marked by enclosing\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10065 it with a '@{' '@}' pair. The default value may also be given as\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10066 an optional second string argument.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10067 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10068 @item boolean\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10069 A boolean property. This property type is equivalent to a radio\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10070 property with \"on|off\" as accepted values. @var{arg} contains\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10071 the default property value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10072 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10073 @item double\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10074 A scalar double property. @var{arg} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10075 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10076 @item handle\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10077 A handle property. This kind of property holds the handle of a\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10078 graphics object. @var{arg} contains the default handle value.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10079 When no default value is given, the property is initialized to\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10080 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10081 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10082 @item data\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10083 A data (matrix) property. @var{arg} contains the default data\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10084 value. When no default value is given, the data is initialized to\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10085 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10086 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10087 @item color\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10088 A color property. @var{arg} contains the default color value.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10089 When no default color is given, the property is set to black.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10090 An optional second string argument may be given to specify an\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10091 additional set of accepted string values (like a radio property).\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10092 @end table\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10093 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10094 @var{type} may also be the concatenation of a core object type and\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10095 a valid property name for that object type. The property created\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10096 then has the same characteristics as the referenced property (type,\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
10097 possible values, hidden state@dots{}). This allows to clone an existing\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10098 property into the graphics object @var{h}.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10099 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10100 Examples:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10101 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10102 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
10103 @group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10104 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10105 addproperty (\"my_radio\", gcf, \"radio\", \"val_1|val_2|@{val_3@}\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10106 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
10107 @end group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10108 @end example\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10109 \n\
17486
b4343603f7ab doc: Add seealso links between hggroup, addproperty, addlistener.
Rik <rik@octave.org>
parents: 17483
diff changeset
10110 @seealso{addlistener, hggroup}\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10111 @end deftypefn")
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10112 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10113 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10114
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10115 octave_value retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10116
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10117 if (args.length () >= 3)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10118 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10119 std::string name = args(0).string_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10120
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10121 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10122 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10123 double h = args(1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10124
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10125 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10126 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10127 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10128
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10129 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10130 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10131 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10132
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10133 std::string type = args(2).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10134
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10135 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10136 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10137 if (! go.get_properties ().has_property (name))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10138 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10139 property p = property::create (name, gh, type,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10140 args.splice (0, 3));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10141
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10142 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10143 go.get_properties ().insert_property (name, p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10144 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10145 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
10146 error ("addproperty: a '%s' property already exists in the graphics object",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10147 name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10148 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10149 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
10150 error ("addproperty: invalid property TYPE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10151 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10152 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10153 error ("addproperty: invalid graphics object (= %g)", h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10154 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10155 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10156 error ("addproperty: invalid handle value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10157 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10158 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
10159 error ("addproperty: invalid property NAME, expected a string value");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10160 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10161 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10162 print_usage ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10163
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10164 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10165 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
10166
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10167 octave_value
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
10168 get_property_from_handle (double handle, const std::string& property,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10169 const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10170 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10171 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10172
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10173 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10174 octave_value retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10175
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10176 if (obj)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
10177 retval = obj.get (caseless_str (property));
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10178 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
10179 error ("%s: invalid handle (= %g)", func.c_str (), handle);
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10180
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10181 return retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10182 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10183
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10184 bool
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
10185 set_property_in_handle (double handle, const std::string& property,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10186 const octave_value& arg, const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10187 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10188 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10189
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10190 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10191 int ret = false;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10192
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10193 if (obj)
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10194 {
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
10195 obj.set (caseless_str (property), arg);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
10196
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
10197 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10198 ret = true;
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10199 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10200 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
10201 error ("%s: invalid handle (= %g)", func.c_str (), handle);
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10202
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10203 return ret;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
10204 }
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10205
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10206 static bool
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10207 compare_property_values (const octave_value& o1, const octave_value& o2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10208 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10209 octave_value_list args (2);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10210
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10211 args(0) = o1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10212 args(1) = o2;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10213
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10214 octave_value_list result = feval ("isequal", args, 1);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10215
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10216 if (! error_state && result.length () > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10217 return result(0).bool_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10218
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10219 return false;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10220 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10221
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10222 static std::map<uint32_t, bool> waitfor_results;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10223
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10224 static void
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10225 cleanup_waitfor_id (uint32_t id)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10226 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10227 waitfor_results.erase (id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10228 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10229
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10230 static void
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10231 do_cleanup_waitfor_listener (const octave_value& listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10232 listener_mode mode = POSTSET)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10233 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10234 Cell c = listener.cell_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10235
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10236 if (c.numel () >= 4)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10237 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10238 double h = c(2).double_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10239
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10240 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10241 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10242 caseless_str pname = c(3).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10243
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10244 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10245 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10246 gh_manager::auto_lock guard;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10247
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10248 graphics_handle handle = gh_manager::lookup (h);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10249
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10250 if (handle.ok ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10251 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10252 graphics_object go = gh_manager::get_object (handle);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10253
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10254 if (go.get_properties ().has_property (pname))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10255 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10256 go.get_properties ().delete_listener (pname, listener,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10257 mode);
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10258 if (mode == POSTSET)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10259 go.get_properties ().delete_listener (pname, listener,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10260 PERSISTENT);
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10261 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10262 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10263 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10264 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10265 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10266 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10267
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10268 static void
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
10269 cleanup_waitfor_postset_listener (const octave_value& listener)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10270 { do_cleanup_waitfor_listener (listener, POSTSET); }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10271
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10272 static void
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
10273 cleanup_waitfor_predelete_listener (const octave_value& listener)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10274 { do_cleanup_waitfor_listener (listener, PREDELETE); }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10275
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10276 static octave_value_list
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10277 waitfor_listener (const octave_value_list& args, int)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10278 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10279 if (args.length () > 3)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10280 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10281 uint32_t id = args(2).uint32_scalar_value ().value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10282
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10283 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10284 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10285 if (args.length () > 5)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10286 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10287 double h = args(0).double_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10288
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10289 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10290 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10291 caseless_str pname = args(4).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10292
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10293 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10294 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10295 gh_manager::auto_lock guard;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10296
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10297 graphics_handle handle = gh_manager::lookup (h);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10298
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10299 if (handle.ok ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10300 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10301 graphics_object go = gh_manager::get_object (handle);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10302 octave_value pvalue = go.get (pname);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10303
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10304 if (compare_property_values (pvalue, args(5)))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10305 waitfor_results[id] = true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10306 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10307 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10308 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10309 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10310 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10311 waitfor_results[id] = true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10312 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10313 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10314
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10315 return octave_value_list ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10316 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10317
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10318 static octave_value_list
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10319 waitfor_del_listener (const octave_value_list& args, int)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10320 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10321 if (args.length () > 2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10322 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10323 uint32_t id = args(2).uint32_scalar_value ().value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10324
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10325 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10326 waitfor_results[id] = true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10327 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10328
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10329 return octave_value_list ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10330 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10331
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10332 DEFUN (waitfor, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10333 "-*- texinfo -*-\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10334 @deftypefn {Built-in Function} {} waitfor (@var{h})\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10335 @deftypefnx {Built-in Function} {} waitfor (@var{h}, @var{prop})\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10336 @deftypefnx {Built-in Function} {} waitfor (@var{h}, @var{prop}, @var{value})\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10337 @deftypefnx {Built-in Function} {} waitfor (@dots{}, \"timeout\", @var{timeout})\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10338 Suspend the execution of the current program until a condition is\n\
17483
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10339 satisfied on the graphics handle @var{h}.\n\
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10340 \n\
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10341 While the program is suspended graphics events are still being processed\n\
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10342 normally, allowing callbacks to modify the state of graphics objects. This\n\
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10343 function is reentrant and can be called from a callback, while another\n\
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10344 @code{waitfor} call is pending at the top-level.\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10345 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10346 In the first form, program execution is suspended until the graphics object\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10347 @var{h} is destroyed. If the graphics handle is invalid, the function\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10348 returns immediately.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10349 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10350 In the second form, execution is suspended until the graphics object is\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10351 destroyed or the property named @var{prop} is modified. If the graphics\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10352 handle is invalid or the property does not exist, the function returns\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10353 immediately.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10354 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10355 In the third form, execution is suspended until the graphics object is\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10356 destroyed or the property named @var{prop} is set to @var{value}. The\n\
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10357 function @code{isequal} is used to compare property values. If the graphics\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10358 handle is invalid, the property does not exist or the property is already\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10359 set to @var{value}, the function returns immediately.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10360 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10361 An optional timeout can be specified using the property @code{timeout}.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10362 This timeout value is the number of seconds to wait for the condition to be\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10363 true. @var{timeout} must be at least 1. If a smaller value is specified, a\n\
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
10364 warning is issued and a value of 1 is used instead. If the timeout value is\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10365 not an integer, it is truncated towards 0.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10366 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10367 To define a condition on a property named @code{timeout}, use the string\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10368 @code{\\timeout} instead.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10369 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10370 In all cases, typing CTRL-C stops program execution immediately.\n\
17483
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10371 @seealso{waitforbuttonpress, isequal}\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10372 @end deftypefn")
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10373 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10374 if (args.length () > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10375 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10376 double h = args(0).double_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10377
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10378 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10379 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10380 caseless_str pname;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10381
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10382 unwind_protect frame;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10383
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10384 static uint32_t id_counter = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10385 uint32_t id = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10386
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10387 int max_arg_index = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10388 int timeout_index = -1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10389
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10390 int timeout = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10391
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10392 if (args.length () > 1)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10393 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10394 pname = args(1).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10395 if (! error_state
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10396 && ! pname.empty ()
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10397 && ! pname.compare ("timeout"))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10398 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10399 if (pname.compare ("\\timeout"))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10400 pname = "timeout";
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10401
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10402 static octave_value wf_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10403
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10404 if (! wf_listener.is_defined ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10405 wf_listener =
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10406 octave_value (new octave_builtin (waitfor_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10407 "waitfor_listener"));
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10408
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10409 max_arg_index++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10410 if (args.length () > 2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10411 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10412 if (args(2).is_string ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10413 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10414 caseless_str s = args(2).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10415
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10416 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10417 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10418 if (s.compare ("timeout"))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10419 timeout_index = 2;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10420 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10421 max_arg_index++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10422 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10423 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10424 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10425 max_arg_index++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10426 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10427
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10428 Cell listener (1, max_arg_index >= 2 ? 5 : 4);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10429
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10430 id = id_counter++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10431 frame.add_fcn (cleanup_waitfor_id, id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10432 waitfor_results[id] = false;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10433
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10434 listener(0) = wf_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10435 listener(1) = octave_uint32 (id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10436 listener(2) = h;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10437 listener(3) = pname;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10438
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10439 if (max_arg_index >= 2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10440 listener(4) = args(2);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10441
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10442 octave_value ov_listener (listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10443
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10444 gh_manager::auto_lock guard;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10445
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10446 graphics_handle handle = gh_manager::lookup (h);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10447
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10448 if (handle.ok ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10449 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10450 graphics_object go = gh_manager::get_object (handle);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10451
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10452 if (max_arg_index >= 2
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10453 && compare_property_values (go.get (pname),
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10454 args(2)))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10455 waitfor_results[id] = true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10456 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10457 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10458
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10459 frame.add_fcn (cleanup_waitfor_postset_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10460 ov_listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10461 go.add_property_listener (pname, ov_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10462 POSTSET);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10463 go.add_property_listener (pname, ov_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10464 PERSISTENT);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10465
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10466 if (go.get_properties ()
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10467 .has_dynamic_property (pname))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10468 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10469 static octave_value wf_del_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10470
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10471 if (! wf_del_listener.is_defined ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10472 wf_del_listener =
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10473 octave_value (new octave_builtin
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10474 (waitfor_del_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10475 "waitfor_del_listener"));
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10476
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10477 Cell del_listener (1, 4);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10478
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10479 del_listener(0) = wf_del_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10480 del_listener(1) = octave_uint32 (id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10481 del_listener(2) = h;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10482 del_listener(3) = pname;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10483
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10484 octave_value ov_del_listener (del_listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10485
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10486 frame.add_fcn (cleanup_waitfor_predelete_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10487 ov_del_listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10488 go.add_property_listener (pname, ov_del_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10489 PREDELETE);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10490 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10491 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10492 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10493 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10494 else if (error_state || pname.empty ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10495 error ("waitfor: invalid property name, expected a non-empty string value");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10496 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10497
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10498 if (! error_state
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10499 && timeout_index < 0
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10500 && args.length () > (max_arg_index + 1))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10501 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10502 caseless_str s = args(max_arg_index + 1).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10503
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10504 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10505 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10506 if (s.compare ("timeout"))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10507 timeout_index = max_arg_index + 1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10508 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
10509 error ("waitfor: invalid parameter '%s'", s.c_str ());
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10510 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10511 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
10512 error ("waitfor: invalid parameter, expected 'timeout'");
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10513 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10514
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10515 if (! error_state && timeout_index >= 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10516 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10517 if (args.length () > (timeout_index + 1))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10518 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10519 timeout = static_cast<int>
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10520 (args(timeout_index + 1).scalar_value ());
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10521
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10522 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10523 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10524 if (timeout < 1)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10525 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10526 warning ("waitfor: the timeout value must be >= 1, using 1 instead");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10527 timeout = 1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10528 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10529 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10530 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10531 error ("waitfor: invalid timeout value, expected a value >= 1");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10532 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10533 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10534 error ("waitfor: missing timeout value");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10535 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10536
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10537 // FIXME: There is still a "hole" in the following loop. The code
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10538 // assumes that an object handle is unique, which is a fair
17483
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
10539 // assumption, except for figures. If a figure is destroyed
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10540 // then recreated with the same figure ID, within the same
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10541 // run of event hooks, then the figure destruction won't be
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10542 // caught and the loop will not stop. This is an unlikely
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10543 // possibility in practice, though.
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10544 //
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10545 // Using deletefcn callback is also unreliable as it could be
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10546 // modified during a callback execution and the waitfor loop
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10547 // would not stop.
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10548 //
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10549 // The only "good" implementation would require object
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10550 // listeners, similar to property listeners.
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10551
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10552 time_t start = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10553
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10554 if (timeout > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10555 start = time (0);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10556
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10557 while (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10558 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10559 if (true)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10560 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10561 gh_manager::auto_lock guard;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10562
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10563 graphics_handle handle = gh_manager::lookup (h);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10564
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10565 if (handle.ok ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10566 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10567 if (! pname.empty () && waitfor_results[id])
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10568 break;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10569 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10570 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10571 break;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10572 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10573
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10574 octave_usleep (100000);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10575
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10576 OCTAVE_QUIT;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10577
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10578 command_editor::run_event_hooks ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10579
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10580 if (timeout > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10581 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10582 if (start + timeout < time (0))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10583 break;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10584 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10585 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10586 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10587 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10588 error ("waitfor: invalid handle value.");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10589 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10590 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10591 print_usage ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10592
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10593 return octave_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
10594 }